* elf.c (_bfd_elf_rela_local_sym): Accept asection **, and return
authorAlan Modra <amodra@gmail.com>
Wed, 5 Nov 2003 13:17:09 +0000 (13:17 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 5 Nov 2003 13:17:09 +0000 (13:17 +0000)
updated section in case of merged section.
* elf-bfd.h (_bfd_elf_rela_local_sym): Update declaration.
* elf-hppa.h (elf_hppa_relocate_section): Adjust call.
* elf-m10200.c (mn10200_elf_relocate_section): Likewise.
* elf-m10300.c (mn10300_elf_relocate_section): Likewise.
* elf32-arm.h (elf32_arm_relocate_section): Likewise.
* elf32-avr.c (elf32_avr_relocate_section): Likewise.
* elf32-cris.c (cris_elf_relocate_section): Likewise.
* elf32-fr30.c (fr30_elf_relocate_section): Likewise.
* elf32-frv.c (elf32_frv_relocate_section): Likewise.
* elf32-h8300.c (elf32_h8_relocate_section): Likewise.
* elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
* elf32-i370.c (i370_elf_relocate_section): Likewise.
* elf32-i860.c (elf32_i860_relocate_section): Likewise.
* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
* elf32-mcore.c (mcore_elf_relocate_section): Likewise.
* elf32-msp430.c (elf32_msp430_relocate_section): Likewise.
* elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
* elf32-s390.c (elf_s390_relocate_section): Likewise.
* elf32-sh.c (sh_elf_relocate_section): Likewise.
* elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
* elf32-v850.c (v850_elf_relocate_section) Likewise.
* elf32-vax.c (elf_vax_relocate_section): Likewise.
* elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise.
* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
* elf64-mmix.c (mmix_elf_relocate_section): Likewise.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
* elf64-s390.c (elf_s390_relocate_section): Likewise.
* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
* elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
* elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise.

* elf32-cris.c (cris_elf_relocate_section): Don't recalculate symbol
section for reloc output.
* elf32-i370.c (i370_elf_relocate_section): Likewise.
* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
* elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
* elf32-vax.c (elf_vax_relocate_section): Likewise.
* elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.

* elf32-ppc.c (ppc_elf_relocate_section): Don't recalculate everything
for R_PPC_RELAX32 reloc.  Don't bother checking ppc_elf_install_value
return value.
* elf64-ppc.c (ppc64_elf_relocate_section <R_PPC64_TOC>): Sanity check
sec->id.

36 files changed:
bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf-hppa.h
bfd/elf-m10200.c
bfd/elf-m10300.c
bfd/elf.c
bfd/elf32-arm.h
bfd/elf32-avr.c
bfd/elf32-cris.c
bfd/elf32-fr30.c
bfd/elf32-frv.c
bfd/elf32-h8300.c
bfd/elf32-hppa.c
bfd/elf32-i370.c
bfd/elf32-i860.c
bfd/elf32-m32r.c
bfd/elf32-m68k.c
bfd/elf32-mcore.c
bfd/elf32-msp430.c
bfd/elf32-openrisc.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-sh.c
bfd/elf32-sparc.c
bfd/elf32-v850.c
bfd/elf32-vax.c
bfd/elf32-xstormy16.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-mmix.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elf64-sh64.c
bfd/elf64-sparc.c
bfd/elf64-x86-64.c
bfd/elfxx-ia64.c

index 7968601..d606e9b 100644 (file)
@@ -1,5 +1,59 @@
 2003-11-05  Alan Modra  <amodra@bigpond.net.au>
 
+       * elf.c (_bfd_elf_rela_local_sym): Accept asection **, and return
+       updated section in case of merged section.
+       * elf-bfd.h (_bfd_elf_rela_local_sym): Update declaration.
+       * elf-hppa.h (elf_hppa_relocate_section): Adjust call.
+       * elf-m10200.c (mn10200_elf_relocate_section): Likewise.
+       * elf-m10300.c (mn10300_elf_relocate_section): Likewise.
+       * elf32-arm.h (elf32_arm_relocate_section): Likewise.
+       * elf32-avr.c (elf32_avr_relocate_section): Likewise.
+       * elf32-cris.c (cris_elf_relocate_section): Likewise.
+       * elf32-fr30.c (fr30_elf_relocate_section): Likewise.
+       * elf32-frv.c (elf32_frv_relocate_section): Likewise.
+       * elf32-h8300.c (elf32_h8_relocate_section): Likewise.
+       * elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
+       * elf32-i370.c (i370_elf_relocate_section): Likewise.
+       * elf32-i860.c (elf32_i860_relocate_section): Likewise.
+       * elf32-m32r.c (m32r_elf_relocate_section): Likewise.
+       * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+       * elf32-mcore.c (mcore_elf_relocate_section): Likewise.
+       * elf32-msp430.c (elf32_msp430_relocate_section): Likewise.
+       * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
+       * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+       * elf32-s390.c (elf_s390_relocate_section): Likewise.
+       * elf32-sh.c (sh_elf_relocate_section): Likewise.
+       * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+       * elf32-v850.c (v850_elf_relocate_section) Likewise.
+       * elf32-vax.c (elf_vax_relocate_section): Likewise.
+       * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise.
+       * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
+       * elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
+       * elf64-mmix.c (mmix_elf_relocate_section): Likewise.
+       * elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
+       * elf64-s390.c (elf_s390_relocate_section): Likewise.
+       * elf64-sh64.c (sh_elf64_relocate_section): Likewise.
+       * elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
+       * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
+       * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise.
+
+       * elf32-cris.c (cris_elf_relocate_section): Don't recalculate symbol
+       section for reloc output.
+       * elf32-i370.c (i370_elf_relocate_section): Likewise.
+       * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+       * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+       * elf32-vax.c (elf_vax_relocate_section): Likewise.
+       * elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
+       * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
+
+       * elf32-ppc.c (ppc_elf_relocate_section): Don't recalculate everything
+       for R_PPC_RELAX32 reloc.  Don't bother checking ppc_elf_install_value
+       return value.
+       * elf64-ppc.c (ppc64_elf_relocate_section <R_PPC64_TOC>): Sanity check 
+       sec->id.
+
+2003-11-05  Alan Modra  <amodra@bigpond.net.au>
+
        * elf32-d10v.c (extract_rel_addend, insert_rel_addend): New functions.
        (elf32_d10v_relocate_section): Use them to handle -r reloc
        adjustments, and in place of _bfd_elf_rela_local_sym.
index 8059b4e..d5965d3 100644 (file)
@@ -1295,7 +1295,7 @@ extern void _bfd_elf_fprintf_vma
 extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
   (const Elf_Internal_Rela *);
 extern bfd_vma _bfd_elf_rela_local_sym
-  (bfd *, Elf_Internal_Sym *, asection *, Elf_Internal_Rela *);
+  (bfd *, Elf_Internal_Sym *, asection **, Elf_Internal_Rela *);
 extern bfd_vma _bfd_elf_rel_local_sym
   (bfd *, Elf_Internal_Sym *, asection **, bfd_vma);
 extern bfd_vma _bfd_elf_section_offset
index bdd7a74..0f15b0d 100644 (file)
@@ -1346,7 +1346,7 @@ elf_hppa_relocate_section (bfd *output_bfd,
          /* This is a local symbol.  */
          sym = local_syms + r_symndx;
          sym_sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sym_sec, rel);
 
          /* If this symbol has an entry in the PA64 dynamic hash
             table, then get it.  */
index 09d7d99..7373dc0 100644 (file)
@@ -373,7 +373,7 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
index 19ba0d2..8f69c52 100644 (file)
@@ -1576,7 +1576,7 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
index e9db1a0..e008cb7 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7368,9 +7368,10 @@ _bfd_elf_reloc_type_class (const Elf_Internal_Rela *rela ATTRIBUTE_UNUSED)
 bfd_vma
 _bfd_elf_rela_local_sym (bfd *abfd,
                         Elf_Internal_Sym *sym,
-                        asection *sec,
+                        asection **psec,
                         Elf_Internal_Rela *rel)
 {
+  asection *sec = *psec;
   bfd_vma relocation;
 
   relocation = (sec->output_section->vma
@@ -7380,16 +7381,14 @@ _bfd_elf_rela_local_sym (bfd *abfd,
       && ELF_ST_TYPE (sym->st_info) == STT_SECTION
       && sec->sec_info_type == ELF_INFO_TYPE_MERGE)
     {
-      asection *msec;
-
-      msec = sec;
       rel->r_addend =
-       _bfd_merged_section_offset (abfd, &msec,
+       _bfd_merged_section_offset (abfd, psec,
                                    elf_section_data (sec)->sec_info,
                                    sym->st_value + rel->r_addend,
-                                   0)
-       - relocation;
-      rel->r_addend += msec->output_section->vma + msec->output_offset;
+                                   0);
+      sec = *psec;
+      rel->r_addend -= relocation;
+      rel->r_addend += sec->output_section->vma + sec->output_offset;
     }
   return relocation;
 }
index a42f75a..efb713c 100644 (file)
@@ -2127,7 +2127,7 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
              bfd_put_32 (input_bfd, value, contents + rel->r_offset);
            }
 #else
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 #endif
        }
       else
index defa9ce..44f2b38 100644 (file)
@@ -750,7 +750,7 @@ elf32_avr_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
index 762101a..e145b26 100644 (file)
@@ -847,7 +847,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 
          symname = (bfd_elf_string_from_elf_section
                     (input_bfd, symtab_hdr->sh_link, sym->st_name));
@@ -1292,16 +1292,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                    {
                      long indx;
 
-                     if (h == NULL)
-                       sec = local_sections[r_symndx];
-                     else
-                       {
-                         BFD_ASSERT (h->root.type == bfd_link_hash_defined
-                                     || (h->root.type
-                                         == bfd_link_hash_defweak));
-                         sec = h->root.u.def.section;
-                       }
-                     if (sec != NULL && bfd_is_abs_section (sec))
+                     if (bfd_is_abs_section (sec))
                        indx = 0;
                      else if (sec == NULL || sec->owner == NULL)
                        {
index c4e2290..472a07a 100644 (file)
@@ -552,7 +552,7 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
index 582b0de..5157f40 100644 (file)
@@ -724,7 +724,7 @@ elf32_frv_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
index 3dc8ad7..452db27 100644 (file)
@@ -435,7 +435,7 @@ elf32_h8_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
index 5d60428..1fab847 100644 (file)
@@ -3439,7 +3439,7 @@ elf32_hppa_relocate_section (bfd *output_bfd,
          /* This is a local symbol, h defaults to NULL.  */
          sym = local_syms + r_symndx;
          sym_sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sym_sec, rel);
        }
       else
        {
index 4a06ac0..b4d305d 100644 (file)
@@ -1210,7 +1210,7 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          sec = local_sections[r_symndx];
          sym_name = "<local symbol>";
 
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
          addend = rel->r_addend;
        }
       else
@@ -1363,16 +1363,7 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                    {
                      long indx;
 
-                     if (h == NULL)
-                       sec = local_sections[r_symndx];
-                     else
-                       {
-                         BFD_ASSERT (h->root.type == bfd_link_hash_defined
-                                     || (h->root.type
-                                         == bfd_link_hash_defweak));
-                         sec = h->root.u.def.section;
-                       }
-                     if (sec != NULL && bfd_is_abs_section (sec))
+                     if (bfd_is_abs_section (sec))
                        indx = 0;
                      else if (sec == NULL || sec->owner == NULL)
                        {
index 209cbe6..8ab3c92 100644 (file)
@@ -1104,7 +1104,7 @@ elf32_i860_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
index 257a68c..7500f56 100644 (file)
@@ -1107,7 +1107,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              sec = local_sections[r_symndx];
              sym_name = "<local symbol>";
 #if !USE_REL
-             relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+             relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
              addend = rel->r_addend;
 #else
              /* FIXME: This won't handle local relocations against SEC_MERGE
index 7688bfd..849bfe8 100644 (file)
@@ -1403,7 +1403,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
@@ -1657,16 +1657,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
                    {
                      long indx;
 
-                     if (h == NULL)
-                       sec = local_sections[r_symndx];
-                     else
-                       {
-                         BFD_ASSERT (h->root.type == bfd_link_hash_defined
-                                     || (h->root.type
-                                         == bfd_link_hash_defweak));
-                         sec = h->root.u.def.section;
-                       }
-                     if (sec != NULL && bfd_is_abs_section (sec))
+                     if (bfd_is_abs_section (sec))
                        indx = 0;
                      else if (sec == NULL || sec->owner == NULL)
                        {
index 59c5840..6992a3d 100644 (file)
@@ -467,7 +467,7 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
          addend = rel->r_addend;
        }
       else
index b09ef87..306a798 100644 (file)
@@ -449,7 +449,7 @@ elf32_msp430_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 
          name = bfd_elf_string_from_elf_section
              (input_bfd, symtab_hdr->sh_link, sym->st_name);
index a9b6d1d..62f86d4 100644 (file)
@@ -375,7 +375,7 @@ openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
index 1b10e56..71a5d45 100644 (file)
@@ -4715,7 +4715,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
          sec = local_sections[r_symndx];
          sym_name = bfd_elf_local_sym_name (input_bfd, sym);
 
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
@@ -5441,44 +5441,9 @@ ppc_elf_relocate_section (bfd *output_bfd,
          break;
 
        case R_PPC_RELAX32:
-         {
-           unsigned long r_symndx;
-           Elf_Internal_Sym *sym;
-           asection *sym_sec;
-           bfd_byte *hit_addr = 0;
-           bfd_vma value = 0;
-
-           r_symndx = ELF32_R_SYM (rel->r_info);
-
-           if (r_symndx < symtab_hdr->sh_info)
-             {
-               sym = local_syms + r_symndx;
-               sym_sec = local_sections[r_symndx];
-
-               value = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
-             }
-           else
-             {
-               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;
-
-           r = ppc_elf_install_value (output_bfd, hit_addr, value, r_type);
-           if (r != bfd_reloc_ok)
-             break;
-           else
-             continue;
-         }
+         ppc_elf_install_value (output_bfd, contents + rel->r_offset,
+                                relocation + addend, r_type);
+         continue;
 
          /* Indirect .sdata relocation.  */
        case R_PPC_EMB_SDAI16:
index f594189..80a753a 100644 (file)
@@ -2325,7 +2325,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
index 34036e5..9ffd05b 100644 (file)
@@ -4805,7 +4805,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
            }
          else if (! howto->partial_inplace)
            {
-             relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+             relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
              addend = rel->r_addend;
            }
          else if ((sec->flags & SEC_MERGE)
index 85a2a2f..ea3a9b1 100644 (file)
@@ -2180,7 +2180,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
@@ -2457,16 +2457,8 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
 
                      if (is_plt)
                        sec = htab->splt;
-                     else if (h == NULL)
-                       sec = local_sections[r_symndx];
-                     else
-                       {
-                         BFD_ASSERT (h->root.type == bfd_link_hash_defined
-                                     || (h->root.type
-                                         == bfd_link_hash_defweak));
-                         sec = h->root.u.def.section;
-                       }
-                     if (sec != NULL && bfd_is_abs_section (sec))
+
+                     if (bfd_is_abs_section (sec))
                        indx = 0;
                      else if (sec == NULL || sec->owner == NULL)
                        {
index e2b8012..fb290eb 100644 (file)
@@ -1681,7 +1681,7 @@ v850_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 #if 0
          {
            char * name;
index 7d78e0f..5d729ef 100644 (file)
@@ -1483,7 +1483,7 @@ elf_vax_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
@@ -1737,16 +1737,7 @@ elf_vax_relocate_section (output_bfd, info, input_bfd, input_section,
                    {
                      long indx;
 
-                     if (h == NULL)
-                       sec = local_sections[r_symndx];
-                     else
-                       {
-                         BFD_ASSERT (h->root.type == bfd_link_hash_defined
-                                     || (h->root.type
-                                         == bfd_link_hash_defweak));
-                         sec = h->root.u.def.section;
-                       }
-                     if (sec != NULL && bfd_is_abs_section (sec))
+                     if (bfd_is_abs_section (sec))
                        indx = 0;
                      else if (sec == NULL || sec->owner == NULL)
                        {
index af9a048..1377ff2 100644 (file)
@@ -845,7 +845,7 @@ xstormy16_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
index 5cf45b6..31adf3b 100644 (file)
@@ -2004,7 +2004,7 @@ elf_xtensa_relocate_section (output_bfd, info, input_bfd,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
index 4933d28..ac16fb5 100644 (file)
@@ -4338,9 +4338,11 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
 
       if (r_symndx < symtab_hdr->sh_info)
        {
+         asection *msec;
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         value = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         msec = sec;
+         value = _bfd_elf_rela_local_sym (output_bfd, sym, &msec, rel);
 
          /* If this is a tp-relative relocation against sym 0,
             this is hackery from relax_section.  Force the value to
@@ -4368,7 +4370,6 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
              && !gotent->reloc_xlated)
            {
              struct alpha_elf_got_entry *ent;
-             asection *msec;
 
              for (ent = gotent; ent; ent = ent->next)
                {
index 5960e32..6440dcb 100644 (file)
@@ -1472,7 +1472,7 @@ mmix_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
index 4024a94..8ae3f12 100644 (file)
@@ -7391,7 +7391,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
          sec = local_sections[r_symndx];
          sym_name = bfd_elf_local_sym_name (input_bfd, sym);
          sym_type = ELF64_ST_TYPE (sym->st_info);
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
          if (elf_section_data (sec) != NULL)
            {
              long *opd_sym_adjust;
@@ -8184,7 +8184,9 @@ ppc64_elf_relocate_section (bfd *output_bfd,
          relocation = TOCstart;
          if (r_symndx == 0)
            relocation += htab->stub_group[input_section->id].toc_off;
-         else if (sec != NULL && !unresolved_reloc)
+         else if (unresolved_reloc)
+           ;
+         else if (sec != NULL && sec->id <= htab->top_id)
            relocation += htab->stub_group[sec->id].toc_off;
          else
            unresolved_reloc = TRUE;
index a55a191..6e72ced 100644 (file)
@@ -2295,7 +2295,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
index f7d1aff..db096a5 100644 (file)
@@ -1582,7 +1582,7 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
            }
          else if (! howto->partial_inplace)
            {
-             relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+             relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
              relocation |= ((sym->st_other & STO_SH5_ISA32) != 0);
            }
          else if ((sec->flags & SEC_MERGE)
index 8c99477..92609e2 100644 (file)
@@ -2070,7 +2070,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
@@ -2247,16 +2247,8 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
                        if (is_plt)
                          sec = splt;
-                       else if (h == NULL)
-                         sec = local_sections[r_symndx];
-                       else
-                         {
-                           BFD_ASSERT (h->root.type == bfd_link_hash_defined
-                                       || (h->root.type
-                                           == bfd_link_hash_defweak));
-                           sec = h->root.u.def.section;
-                         }
-                       if (sec != NULL && bfd_is_abs_section (sec))
+
+                       if (bfd_is_abs_section (sec))
                          indx = 0;
                        else if (sec == NULL || sec->owner == NULL)
                          {
index 44e60e8..4cfcba5 100644 (file)
@@ -1821,7 +1821,7 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
 
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
        }
       else
        {
@@ -2046,16 +2046,7 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                    {
                      long sindx;
 
-                     if (h == NULL)
-                       sec = local_sections[r_symndx];
-                     else
-                       {
-                         BFD_ASSERT (h->root.type == bfd_link_hash_defined
-                                     || (h->root.type
-                                         == bfd_link_hash_defweak));
-                         sec = h->root.u.def.section;
-                       }
-                     if (sec != NULL && bfd_is_abs_section (sec))
+                     if (bfd_is_abs_section (sec))
                        sindx = 0;
                      else if (sec == NULL || sec->owner == NULL)
                        {
index 8fae4ee..24d6079 100644 (file)
@@ -3846,9 +3846,11 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
       if (r_symndx < symtab_hdr->sh_info)
        {
          /* Reloc against local symbol.  */
+         asection *msec;
          sym = local_syms + r_symndx;
          sym_sec = local_sections[r_symndx];
-         value = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
+         msec = sym_sec;
+         value = _bfd_elf_rela_local_sym (output_bfd, sym, &msec, rel);
          if ((sym_sec->flags & SEC_MERGE)
              && ELF_ST_TYPE (sym->st_info) == STT_SECTION
              && sym_sec->sec_info_type == ELF_INFO_TYPE_MERGE)
@@ -3859,7 +3861,6 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
              if (loc_h && ! loc_h->sec_merge_done)
                {
                  struct elfNN_ia64_dyn_sym_info *dynent;
-                 asection *msec;
 
                  for (dynent = loc_h->info; dynent; dynent = dynent->next)
                    {