public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jeffrey A Law <law@cygnus.com>
To: binutils@sourceware.cygnus.com
Cc: drepper@cygnus.com
Subject: Dealing with broken ELF libraries
Date: Wed, 01 Sep 1999 15:47:00 -0000	[thread overview]
Message-ID: <23914.936225419@upchuck.cygnus.com> (raw)

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

             reply	other threads:[~1999-09-01 15:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-01 15:47 Jeffrey A Law [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23914.936225419@upchuck.cygnus.com \
    --to=law@cygnus.com \
    --cc=binutils@sourceware.cygnus.com \
    --cc=drepper@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).