* elflink.h (elf_link_add_object_symbols): Revert 1999-09-02 hpux
authorAlan Modra <amodra@gmail.com>
Thu, 4 Jul 2002 13:26:30 +0000 (13:26 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 4 Jul 2002 13:26:30 +0000 (13:26 +0000)
fudge.
* elf.c (bfd_section_from_shdr): Work around broken hpux shared
libs here instead.

bfd/ChangeLog
bfd/elf.c
bfd/elflink.h

index 3098e0b8d7e334a573cfcd1a173b330c3f6fe9cb..e1cb88f02b4ac69279aa22ff4df6cd27f5c7b947 100644 (file)
@@ -1,3 +1,10 @@
+2002-07-04  Alan Modra  <amodra@bigpond.net.au>
+
+       * elflink.h (elf_link_add_object_symbols): Revert 1999-09-02 hpux
+       fudge.
+       * elf.c (bfd_section_from_shdr): Work around broken hpux shared
+       libs here instead.
+
 2002-07-02  Martin Schwidefsky  <schwidefsky@de.ibm.com>
 
        * elf64-s390.c (create_got_section): Set .got section alignment to
index 1cb91ee527d28fccd78e99cd159512a5cb7fb359..3188213d6d715bec8bba8f2becd1bf8fb3f1a6ac 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1661,7 +1661,6 @@ bfd_section_from_shdr (abfd, shindex)
       return true;
 
     case SHT_PROGBITS: /* Normal section with contents.  */
-    case SHT_DYNAMIC:  /* Dynamic linking information.  */
     case SHT_NOBITS:   /* .bss section.  */
     case SHT_HASH:     /* .hash section.  */
     case SHT_NOTE:     /* .note section.  */
@@ -1670,6 +1669,39 @@ bfd_section_from_shdr (abfd, shindex)
     case SHT_PREINIT_ARRAY:    /* .preinit_array section.  */
       return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
 
+    case SHT_DYNAMIC:  /* Dynamic linking information.  */
+      if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+       return false;
+      if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
+       {
+         Elf_Internal_Shdr *dynsymhdr;
+
+         /* The shared libraries distributed with hpux11 have a bogus
+            sh_link field for the ".dynamic" section.  Find the
+            string table for the ".dynsym" section instead.  */
+         if (elf_dynsymtab (abfd) != 0)
+           {
+             dynsymhdr = elf_elfsections (abfd)[elf_dynsymtab (abfd)];
+             hdr->sh_link = dynsymhdr->sh_link;
+           }
+         else
+           {
+             unsigned int i, num_sec;
+
+             num_sec = elf_numsections (abfd);
+             for (i = 1; i < num_sec; i++)
+               {
+                 dynsymhdr = elf_elfsections (abfd)[i];
+                 if (dynsymhdr->sh_type == SHT_DYNSYM)
+                   {
+                     hdr->sh_link = dynsymhdr->sh_link;
+                     break;
+                   }
+               }
+           }
+       }
+      break;
+
     case SHT_SYMTAB:           /* A symbol table */
       if (elf_onesymtab (abfd) == shindex)
        return true;
index 2a6428f22cb7803bfbe7853c5be9216e582d5419..6c1d0d92b8b9db43fc51ff5e0ddff869bd75e406 100644 (file)
@@ -1451,23 +1451,6 @@ elf_link_add_object_symbols (abfd, info)
            goto error_return;
          shlink = elf_elfsections (abfd)[elfsec]->sh_link;
 
-         {
-           /* The shared libraries distributed with hpux11 have a bogus
-              sh_link field for the ".dynamic" section.  This code detects
-              when SHLINK refers to a section that is not a string table
-              and tries to find the string table for the ".dynsym" section
-              instead.  */
-           Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[shlink];
-           if (shdr->sh_type != SHT_STRTAB)
-             {
-               asection *ds = bfd_get_section_by_name (abfd, ".dynsym");
-               int elfdsec = _bfd_elf_section_from_bfd_section (abfd, ds);
-               if (elfdsec == -1)
-                 goto error_return;
-               shlink = elf_elfsections (abfd)[elfdsec]->sh_link;
-             }
-         }
-
          extdyn = dynbuf;
          extdynend = extdyn + s->_raw_size / sizeof (Elf_External_Dyn);
          rpath = 0;