* linking custom executable
@ 2004-06-22 17:49 Alexander Gdalevich
0 siblings, 0 replies; only message in thread
From: Alexander Gdalevich @ 2004-06-22 17:49 UTC (permalink / raw)
To: gcc-help
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/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-06-22 17:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-22 17:49 linking custom executable Alexander Gdalevich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).