This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

HOWTO: Add underscores to symbols with ELF


Hello,
I am having trouble making a cross-compiler that generates ELF object
files with an underscore ("_") added to the beginning of the symbol
names.

Here is my setup:
Windows NT 4.0 Server
Cygwin 1.1.2
binutils-2.10
gcc-2.95.2
newlib-1.8.2
target=m68k-elf
prefix=/gcc-m68k

Edited /source/gcc-2.95.2/gcc/config/m68k/m68kelf.h: changed
  USER_LABEL_PREFIX from "" to "_"
prior to running "configure" and "make"

The compiler build goes ok and everything seems to work until it tries
to link, when I get undefined symbols. When I use objdump on my object
files, global symbols do not have underscores as I would expect (e.g. my
main.o contains the symbol "main" instead of "_main"). However, the file
"crt0.o" generated while building the compiler contains the symbol
"_start", not "start", which it should. It seems that the use of the
SYM() macro in an assembly-language file does appropriately prepend the
underscore to symbol names. For some reason the C compiler does not seem
to be doing this however.

Should I do something else? I need to add the underscores in order to
make the compiled code compatible with stuff built by another compiler.
Using COFF works just fine, changing "USER_LABEL_PREFIX" in "coff.h" as
opposed to "m68kelf.h" allows me to build an m68k-coff compiler that
properly adds the underscores and I get no linker errors. However, for
other reasons I would rather use ELF.

Anyone know if there is a bug in the way USER_LABEL_PREFIX is used in
the ELF source code?

Thanks a lot for any help you can offer
Chris


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]