[arm-gnu] undefined reference to _init

Freddie Chopin freddie_chopin at op.pl
Fri Oct 19 06:35:02 UTC 2012


W dniu 2012-10-18 20:18, Brad Badke pisze:
> Thanks for your response. Your examples look well written. So I found I have to manually link in CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/lib/gcc/arm-none-eabi/4.6.3/crti.o to get rid of the _init problem. I have to do this even if I don't use the -nostartfiles flag.

I never had to explicitly link any library...

> Anyway, I am pretty new to the GCC stuff and make files but have been using ARM for 9 years (code warrior and eclipse IDEs). I have already converted my boot code over to GCC and am pretty happy with that --- but I did notice that GCC sprintf is a real space hog compared to ARM. If I don't use sprintf my ARM and GCC compile to within 2KB of each other. If I use sprintf, the GCC code is 18KB bigger than ARM. Rather significant since my boot code binary is only 38KB.

You could try "integer-only" version that does not support floats - 
siprintf(), iprintf(), fiprintf() etc. - these are smaller.

> Anyway, my boot code reads my app code .bin out of NAND flash and puts it in RAM. Then the boot jumps to the app startup and that is where my difficulty is. Anyway by the time I get to the app I am strictly in RAM but I still have to contend with C/C++ and initializing the run time library. So now I get my app to compile and link but at some point in __libc_init_array my app startup an exception occurs and dumps me back to my boot loader trap. Progress, but I clearly still don't have everything correct in my make file and/or my linker script.

If you're in a trap exception, you can check which instruction (address) 
generated the exception, this way you could get to the real culprit. Or 
just use a debugger - if you can (;

4\/3!!



More information about the arm-gnu mailing list