* elf64-ppc.c (opd_entry_value): Handle case where symbol
authorAlan Modra <amodra@gmail.com>
Mon, 6 May 2013 09:32:55 +0000 (09:32 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 6 May 2013 09:32:55 +0000 (09:32 +0000)
hashes are not available.

bfd/ChangeLog
bfd/elf64-ppc.c

index 0434e70e7dd882d003390012869893f4d8beca15..8e2308ef87a109a7cf4903d85e8911ef9a968e4d 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-06  Alan Modra  <amodra@gmail.com>
+
+       * elf64-ppc.c (opd_entry_value): Handle case where symbol
+       hashes are not available.
+
 2013-05-06  Alan Modra  <amodra@gmail.com>
 
        * elflink.c (elf_link_add_object_symbols): Don't save symbol
index cb33821a76c3c2f8346c804b5dfd0468b2589fe5..d4415e4576b78d49dad056f5bc7eb9e672342c34 100644 (file)
@@ -5665,11 +5665,30 @@ opd_entry_value (asection *opd_sec,
 
                  sym_hashes = elf_sym_hashes (opd_bfd);
                  rh = sym_hashes[symndx - symtab_hdr->sh_info];
-                 rh = elf_follow_link (rh);
-                 BFD_ASSERT (rh->root.type == bfd_link_hash_defined
-                             || rh->root.type == bfd_link_hash_defweak);
-                 val = rh->root.u.def.value;
-                 sec = rh->root.u.def.section;
+                 if (rh != NULL)
+                   {
+                     rh = elf_follow_link (rh);
+                     BFD_ASSERT (rh->root.type == bfd_link_hash_defined
+                                 || rh->root.type == bfd_link_hash_defweak);
+                     val = rh->root.u.def.value;
+                     sec = rh->root.u.def.section;
+                   }
+                 else
+                   {
+                     /* Handle the odd case where we can be called
+                        during bfd_elf_link_add_symbols before the
+                        symbol hashes have been fully populated.  */
+                     Elf_Internal_Sym *sym;
+
+                     sym = bfd_elf_get_elf_syms (opd_bfd, symtab_hdr, 1,
+                                                 symndx, NULL, NULL, NULL);
+                     if (sym == NULL)
+                       break;
+
+                     val = sym->st_value;
+                     sec = bfd_section_from_elf_index (opd_bfd, sym->st_shndx);
+                     free (sym);
+                   }
                }
              val += look->r_addend;
              if (code_off != NULL)