Hello, I have problems when I am trying to link together a project example which I found on the net (I have attached the important files, just type make main.elf in the terminal). When the following command is executed: arm-elf-ld -v -lc -Map main.map -nostartfiles -T ld_flash.cmd -o main.elf crt.o main.o I get this error message: main.o(.text+0x1e4): In function `main': home.../main.c:153: undefined reference to `__gccmain' I suppose it is some library problem and I have tried a lot of different ways of including libc.a, but still I have not got it to work? /Dan
I successfully build the project using Codesourcery ARM 2011.03.
Thank you for the replies. @ Rolf Magnus, I have tired libgcc as well. When I run the command using libgcc: arm-elf-ld -v -g -O0 -T ld_flash.cmd -o main.elf crt.o main.o -L/usr/local/lib/gcc-lib/arm-elf/2.95.3 -L/usr/local/arm-elf/lib/ -lgcc I get the following error message: /usr/local/lib/gcc-lib/arm-elf/2.95.3/libgcc.a(__main.o)(.text+0xbc): In function `__do_global_ctors': : undefined reference to `atexit' /usr/local/lib/gcc-lib/arm-elf/2.95.3/libgcc.a(__main.o)(.text+0xc4): In function `__do_global_ctors': : undefined reference to `__CTOR_LIST__' /usr/local/lib/gcc-lib/arm-elf/2.95.3/libgcc.a(__main.o)(.data+0x0): undefined reference to `__DTOR_LIST__' When I run the command with libc: arm-elf-ld -v -g -O0 -T ld_flash.cmd -o main.elf crt.o main.o -L/usr/local/lib/gcc-lib/arm-elf/2.95.3 -L/usr/local/arm-elf/lib/ -lc I get: main.o(.text+0x1e0): In function `main': home.../ArmPrj/main.c:153: undefined reference to `__gccmain' @ skriptkiddy, Nice to hear, if I don't get this to work I will also try Codesourcery ARM 2011.03. Could you please run: arm-elf-gcc -S main.c -o main.s and attach the assembler file here. I have detected a strange line in my assembler file: bl __gccmain Which stands for branch to the label __gccmain, but there isn't any label named __gccmain and I can't see the reason why there is a branch there at all. /Dan
I found the solution at: http://www.embedinfo.com/en/FAQ/FAQanswer.asp?id=19 The problem could simply be solved by changing the name of int main() to int _gccmain(). /Dan
Usually it´s better to use the gcc command also for linking as it takes care for the correct libs, unlike the ld command which requires the libs to be specified explicitely.
Do you mean the arm-elf-gcc instead of the arm-elf-ld command? I still get an error when I am running: arm-elf-gcc -v -g -O0 -T ld_flash.cmd -o main.elf crt.o main.o The output is: /usr/local/lib/gcc-lib/arm-elf/2.95.3/collect2 -X -o main.elf /usr/local/arm-elf/lib/crt0.o -L/usr/local/lib/gcc-lib/arm-elf/2.95.3 -L/usr/local/arm-elf/lib crt.o main.o -lgcc -lg -lc -lgcc -T ld_flash.cmd /usr/local/arm-elf/bin/ld.real: warning: no memory region specified for section `.note.ABI-tag' /usr/local/arm-elf/bin/ld.real: section .note.ABI-tag [00000000 -> 0000001f] overlaps section .text [00000000 -> 00001e3b] /usr/local/lib/gcc-lib/arm-elf/2.95.3/libgcc.a(__main.o)(.text+0xc4): In function `__do_global_ctors': : undefined reference to `__CTOR_LIST__' /usr/local/lib/gcc-lib/arm-elf/2.95.3/libgcc.a(__main.o)(.data+0x0): undefined reference to `__DTOR_LIST__ /Dan
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.