public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Dealing with broken ELF libraries
@ 1999-09-01 15:47 Jeffrey A Law
  1999-09-01 16:03 ` Ulrich Drepper
  1999-09-02  6:55 ` Ian Lance Taylor
  0 siblings, 2 replies; 6+ messages in thread
From: Jeffrey A Law @ 1999-09-01 15:47 UTC (permalink / raw)
  To: binutils; +Cc: drepper

Ho hum.  In typical fashion HP made some goof's in their ELF implementation
which apparently nobody's noticed because nobody else in their right mind is
writing ELF tools to work on hpux11 :-)

Can someone spot the bug in these two header dumps?

readelf -S libc.so 
There are 42 section headers, starting at offset 0x1227b8:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf 
Al
  [ 0]                   NULL            00000000 ffffffff 000000 00      0   
0 0
  [ 1] .dynamic          DYNAMIC         000011c8 0001c8 000150 10  A   0   0 8
  [ 2] .dynsym           DYNSYM          00001318 000318 00a050 18  A   3   0 8
  [ 3] .dynstr           STRTAB          0000b368 00a368 00482f 00  A   0   0 1

[ ... ]

[law@portal /scr/hp-elf-native/ld/test] readelf -S libdl.so
There are 35 section headers, starting at offset 0x51c8:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf 
Al
  [ 0]                   NULL            00000000 ffffffff 000000 00      0   
0 0
  [ 1] .dynamic          DYNAMIC         000011c8 0001c8 000120 10  A   0   0 8
  [ 2] .dynsym           DYNSYM          000012e8 0002e8 000360 18  A   3   0 8
  [ 3] .dynstr           STRTAB          00001648 000648 000203 00  A   0   0 1


Stumped?  The link for the .dynamic field points back to section #0 instead
of pointing to section #3.  Opps.

This causes gld/bfd some problems:

elflink.c::elf_link_add_object_symbols

      s = bfd_get_section_by_name (abfd, ".dynamic");
[ ... blah blah blah ... ]

          elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
          if (elfsec == -1)
            goto error_return;
          link = elf_elfsections (abfd)[elfsec]->sh_link;

So we get a link of 0.  Of course section #0 is not a string table.  This
causes grief later when we do something like call
bfd_elf_string_from_elf_section.


So what do y'all think the best workaround might be?  Yes, I know HP should fix
their tools & libraries, but the libraries with the bogus link fields are
fairly widespread already.  And while HP may fix their tools, all the existing
sites lose if we can't find a good workaround.

We might be able to do something like recognize that LINK refers to a section
that is not of type STRTAB (and then fall back to looking for .dynsym's
string table).

Other options?

jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-09-02  9:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-01 15:47 Dealing with broken ELF libraries Jeffrey A Law
1999-09-01 16:03 ` Ulrich Drepper
1999-09-01 16:11   ` Jeffrey A Law
1999-09-02  6:57     ` Ian Lance Taylor
1999-09-02  9:09       ` Ulrich Drepper
1999-09-02  6:55 ` Ian Lance Taylor

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).