linking custom executable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Greetings,


I am running into a strange problem using a pc-cygwin hosted GCC 3.4.0 cross compiler for the Hitachi sh4 (sh-elf) target.

I have to build an executable image for an embedded system. I order to call global constructors, the program has to call __do_global_ctors_aux() at some point before calling main(). This function (__do_global_ctors_aux) is in crtend.o. Normally, collect2 will generate the code to do all the initialization, call global constructors and call main(). However, I cannot do this since my program has to do some custom hardware initialization before running any user or library code. Hence, what I am trying to do is to call __do_global_ctors_aux() directly from my code after I am done with initialization.

I am, however, running into trouble linking the program.

This works:
ld crtbegin.o crtend.o my_program.o -lgcc

This, however, does not work:
ld ?oformat=binary crtbegin.o crtend.o my_program.o ?lgcc

crtbegin.o(.text+0x54): In function `___do_global_dtors_aux':
: undefined reference to `___deregister_frame_info'
crtbegin.o(.text+0xa8): In function `_frame_dummy':
: undefined reference to `___register_frame_info'
crtbegin.o(.text+0xb8): In function `_frame_dummy':
: undefined reference to `__Jv_RegisterClasses'


Is this a bug???



However, when I call __do_global_ctors_aux() from my program, it does not link no matter what. When I instructed the linker to produce map with ?M option, and looked at the file generated, I saw that even so .init, .text, and other sections from crtbegin.o and crtend.o are being linked in, no global symbols such as __do_global_ctors_aux and __do_global_dtors_aux appear in the list.



What am I doing wrong?



Thanks for your time.



Alexander Gdalevich



----------------------------------------------------------------
"Normal people ... believe that if it ain't broke, don't fix it. Engineers believe that if it ain't broke, it doesn't have enough features yet."


_________________________________________________________________
MSN 9 Dial-up Internet Access fights spam and pop-ups ? now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux