[arm-gnu] undefined reference to _init

Brad Badke BBadke at hemispheregps.com
Thu Oct 18 18:18:52 UTC 2012


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.

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.

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.

-----Original Message-----
From: arm-gnu-bounces at codesourcery.com [mailto:arm-gnu-bounces at codesourcery.com] On Behalf Of Freddie Chopin
Sent: Wednesday, October 17, 2012 11:24 PM
To: arm-gnu at codesourcery.com
Subject: Re: [arm-gnu] undefined reference to _init

You could try downloading one of my example projects for ARM microcontrollers from my website - www.freddiechopin.info > Download > ARM > examples . These have linker scripts, Makefiles and startups that REALLY work without any voodoo with strange functions from strange libraries. They have what you need, which is C++ initialization/deinitialization using __libc_init_array and __libc_fini_array - you could use that as a reference point, as I see you use something bigger than microcontroller...

Then you can switch to some other toolchain, for example linaro, as they actually provide support for their releases via launchpad answers - https://launchpad.net/gcc-arm-embedded

In case of doubts - ask (;

4\/3!!
_______________________________________________
arm-gnu mailing list
arm-gnu at codesourcery.com
http://sourcerytools.com/cgi-bin/mailman/listinfo/arm-gnu



More information about the arm-gnu mailing list