Search code examples
osx-snow-leopardarmcross-compiling

problems with arm-elf-gcc cross compiler on OS X


I'm trying to compile my first linux ARM hello world program and when I copy and run the binary to my target linux board (linuxstamp Atmel arm 9g20) I get "Illegal instruction"

I am running arm-elf-gcc-4.6 on OS X from macports. I am using Eclipse for and IDE. It looks like the build is more for a stand alone non OS program rather then code to run in linux user space. Could someone point me in the right direction? Thanks.

code:

#include<stdio.h>

int main(){
    printf("hello world\n");
    return 0;
}

Build of configuration Release for project ArmTest **

make all Building target: ArmTest.elf Invoking: ARM Mac OS X GCC C Linker /opt/local/bin/arm-elf-gcc-4.6 -nostartfiles -Wl,-Map,ArmTest.map -mcpu=arm920 -mthumb -o"ArmTest.elf" ./main.o
/opt/local/lib/gcc/arm-elf/4.6.0/../../../../arm-elf/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000008000 Finished building target: ArmTest.elf

Invoking: ARM Mac OS X GNU Create Flash Image /opt/local/bin/arm-elf-objcopy -O binary ArmTest.elf "ArmTest.hex" Finished building: ArmTest.hex

Invoking: ARM Mac OS X GNU Create Listing /opt/local/bin/arm-elf-objdump -h -S ArmTest.elf >"ArmTest.lst" Finished building: ArmTest.lst

Invoking: ARM Mac OS X GNU Print Size /opt/local/bin/arm-elf-size --format=berkeley ArmTest.elf text data bss dec hex filename 8112 2104 232 10448 28d0 ArmTest.elf Finished building: ArmTest.siz


Solution

  • I am running arm-elf-gcc-4.6 on OS X from macports [...] It looks like the build is more for a stand alone non OS program rather then code to run in linux user space.

    Indeed, this is for embedded ARM devices without Linux OS. The Linux variant of gcc as cross compiler for ARM should have "linux" somewhere in its name like "arm-linux-gcc".