wrapper functions that ``call themselves'' break mn10300 -mrelax

Alexandre Oliva aoliva@redhat.com
Tue Jul 29 06:11:00 GMT 2003


I couldn't figure out what exactly broke the long-standing fact that
dejagnu/testglue.c, used in mn10300-sim and several other dejagnu
baseboards, contains wrapper functions that call the original
unwrapped names, e.g., __wrap_abort() calls __real_abort() and then
abort().  Also, __wrap_main() calls __real_main() and then exit() (as
opposed to either __wrap_exit() or __real_exit()).

This causes a very serious problem to the mn10300 linker, when doing
linker relaxations.

The problem is that say __wrap_exit is added to the symbol table of
the testglue.o abfd twice: once when the symbol is first defined, and
once when elf_merge_symbol() calls bfd_wrapped_link_hash_lookup() for
the undefined symbol entry corresponding to abort() or exit() is
encountered, that is mapped to the same hash.

This causes a problem when mn10300 attempts to do adjust the symbol
values within their sections, after removing some bytes from before
them, near the end of mn10300_elf_relax_delete_bytes().

I've been trying to find a clean and efficient way to get
elf_merge_symbols() to skip such duplicate definitions, but I couldn't
think of any.  I'm not even sure it would be correct to arrange for
elf_merge_symbols() to remove duplicate entries from the symhashes
array of a bfd.  Even if it is, there's no efficient way to remove
duplicates, other than creating a per-bfd hash table.  Does anyone
have any clever ideas?

As for dejagnu, I managed to work around the problem by replacing
explicit references to exit() and abort() with references to
ORIG_EXIT() and ORIG_ABORT(), but I'm not sure this would be
appropriate either.  Another work around, that fixed the problem in
this particular platform, was to tell dejagnu that the mn10300 sim
does actually return the exit status from the programs, which I found
to be true but not reflected in the mn10300-sim.exp baseboard file.
Here's the patch for the file.  Ok for the GDB tree?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dejagnu-mn10300-sim-no-wrapper.patch
Type: text/x-patch
Size: 954 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20030729/d50848cb/attachment.bin>
-------------- next part --------------

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer


More information about the Binutils mailing list