Better handking for unresolved symbols
[deliverable/binutils-gdb.git] / bfd / elf32-ppc.c
index b78a64c0cf5b33ae5e93ae5fc218cdd29aa97120..3bffc70c7868575cba5f1f2a84b753047f8d6130 100644 (file)
@@ -4718,6 +4718,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
       unresolved_reloc = FALSE;
       warned = FALSE;
       r_symndx = ELF32_R_SYM (rel->r_info);
+
       if (r_symndx < symtab_hdr->sh_info)
        {
          sym = local_syms + r_symndx;
@@ -4728,44 +4729,12 @@ ppc_elf_relocate_section (bfd *output_bfd,
        }
       else
        {
-         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx,
+                                  symtab_hdr, relocation, sec,
+                                  unresolved_reloc, info,
+                                  warned);
+         
          sym_name = h->root.root.string;
-
-         relocation = 0;
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             /* Set a flag that will be cleared later if we find a
-                relocation value for this symbol.  output_section
-                is typically NULL for symbols satisfied by a shared
-                library.  */
-             if (sec->output_section == NULL)
-               unresolved_reloc = TRUE;
-             else
-               relocation = (h->root.u.def.value
-                             + sec->output_section->vma
-                             + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           ;
-         else if (!info->executable
-                  && !info->no_undefined
-                  && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
-           ;
-         else
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                    (info, h->root.root.string, input_bfd, input_section,
-                     rel->r_offset, (info->executable
-                                     || info->no_undefined
-                                     || ELF_ST_VISIBILITY (h->other)))))
-               return FALSE;
-             warned = TRUE;
-           }
        }
 
       /* TLS optimizations.  Replace instruction sequences and relocs
@@ -5500,49 +5469,16 @@ ppc_elf_relocate_section (bfd *output_bfd,
              }
            else
              {
-               long indx;
-
-               indx = r_symndx - symtab_hdr->sh_info;
-               h = elf_sym_hashes (input_bfd)[indx];
-               while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-                 h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-               value = 0;
-               if (h->root.type == bfd_link_hash_defined
-                   || h->root.type == bfd_link_hash_defweak)
-                 {
-                   sym_sec = h->root.u.def.section;
-
-                   /* Detect the cases that sym_sec->output_section is
-                      expected to be NULL -- all cases in which the symbol
-                      is defined in another shared module.  This includes
-                      PLT relocs for which we've created a PLT entry and
-                      other relocs for which we're prepared to create
-                      dynamic relocations.  */
-                   /* ??? Just accept it NULL and continue.  */
-
-                   if (sym_sec->output_section != NULL)
-                     {
-                       value = (h->root.u.def.value
-                                + sym_sec->output_section->vma
-                                + sym_sec->output_offset);
-                     }
-                 }
-               else if (!info->executable
-                        && !info->no_undefined
-                        && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
-                 ;
-               else
-                 {
-                   if (! ((*info->callbacks->undefined_symbol)
-                          (info, h->root.root.string, input_bfd,
-                           input_section, rel->r_offset,
-                           (info->executable || info->no_undefined
-                            || ELF_ST_VISIBILITY (h->other)))))
-                     return FALSE;
-                   continue;
-                 }
+               bfd_boolean warned;
+               bfd_boolean unresolved_reloc;
+
+               RELOC_FOR_GLOBAL_SYMBOL (h, elf_sym_hashes (input_bfd),
+                                        r_symndx, symtab_hdr,
+                                        value, sym_sec,
+                                        unresolved_reloc, info,
+                                        warned);
+               if (warned)
+                 continue;
              }
            hit_addr = contents + rel->r_offset;
            value += rel->r_addend;
This page took 0.027263 seconds and 4 git commands to generate.