Cross compiling and Linking

  • Compilation
    arm-uclinuxeabi-gcc  -g  -Os   -g2 -mthumb -mcpu=cortex-m3 -fsigned-char -O2 -fno-builtin-puts -fno-common -ffixed-r8 -D__KERNEL__ -I -fno-builtin -ffreestanding -isystem  -pipe  -DCONFIG_ARM -D__ARM__ -D<MACRO="(VALUE)"> -Wall -Wstrict-prototypes -fno-stack-protector   -o   -c
    
  • De-assemble
    arm-uclinuxeabi-objdump -S <O_FILE>
    
  • Library
    arm-uclinuxeabi-ar crv <A_FILENAME> <O_FILES> 
    
  • Linking
    arm-uclinuxeabi-ld -Bstatic -T<LDS_FILENAME> -u<UNDEFINED_SYMBOLS> <O_FILES> <A_FILES> -lgcc -Map <MAP_FILE> -o <OUT_FILENAME>
    

    Example linker script:

    OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
    OUTPUT_ARCH(arm)
    ENTRY(main)
    
    MEMORY
    {
     /* SmartFusion internal eSRAM */
     ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64k
    }
    
    SECTIONS
    {
     .text :
     {
       . = ALIGN(4);
        *(.text*)
    	. = ALIGN(4);
        _etext = .;
     } >ram
    }
    end = .;
  • Other format output
    arm-none-eabi-objcopy --gap-fill=0xff -O ihex myprog  "myprog.hex"
    arm-none-eabi-objcopy --gap-fill=0xff -O binary myprog  "myprog.bin"
    arm-none-eabi-objcopy -O srec myprog "myprog.srec"
    arm-none-eabi-objdump -h -S myprog > "myprog.lst"