* elf.c (_bfd_elf_rela_local_sym): New.
authorJakub Jelinek <jakub@redhat.com>
Fri, 23 Nov 2001 12:17:21 +0000 (12:17 +0000)
committerJakub Jelinek <jakub@redhat.com>
Fri, 23 Nov 2001 12:17:21 +0000 (12:17 +0000)
* elflink.h (elf_link_input_bfd): Don't consider empty
merged sections as removed in relocation tests.
* elf-bfd.h (_bfd_elf_rela_local_sym): Add prototype.
* elf32-i386.c (elf_i386_relocate_section): Handle relocs
against STT_SECTION symbol of SHF_MERGE section.
* elf32-arm.h (elf32_arm_relocate_section): Likewise.
* elf32-avr.c (elf32_avr_relocate_section): Call
_bfd_elf_rela_local_sym.
* elf32-cris.c (cris_elf_relocate_section): Likewise.
* elf32-d10v.c (elf32_d10v_relocate_section): Likewise.
* elf32-fr30.c (fr30_final_link_relocate): 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-openrisc.c (openrisc_elf_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
* elf32-s390.c (elf_s390_relocate_section): Likewise.
* elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
* elf32-v850.c (v850_elf_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-sparc.c (sparc64_elf_relocate_section): Likewise.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
* elf-hppa.h (elf_hppa_relocate_section): Likewise.
* elf-m10200.c (mn10200_elf_relocate_section): Likewise.
* elf-m10300.c (mn10300_elf_relocate_section): Likewise.
* elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise.
* elf32-sh.c (sh_elf_relocate_section): Likewise for
!partial_inplace relocs. Handle relocs against STT_SECTION
symbol of SHF_MERGE for partial_inplace relocs.

* config/tc-alpha.c (tc_gen_reloc): Remove SEC_MERGE test.
* write.c (adjust_reloc_syms): Don't handle relocs against
SEC_MERGE section symbols specially.
(fixup_segment): Likewise.

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-d10v.c
bfd/elf32-fr30.c
bfd/elf32-h8300.c
bfd/elf32-hppa.c
bfd/elf32-i370.c
bfd/elf32-i386.c
bfd/elf32-i860.c
bfd/elf32-m32r.c
bfd/elf32-m68k.c
bfd/elf32-mcore.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/elf64-alpha.c
bfd/elf64-mmix.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elf64-sparc.c
bfd/elf64-x86-64.c
bfd/elflink.h
bfd/elfxx-ia64.c
gas/ChangeLog
gas/config/tc-alpha.c
gas/write.c

index 5759b1b4c98aafc380a3c2a3137fb3e0b951e627..0b3cd6299d3ccbb31169db6ecb390080c3c9b310 100644 (file)
@@ -1,3 +1,43 @@
+2001-11-23  Jakub Jelinek  <jakub@redhat.com>
+
+       * elf.c (_bfd_elf_rela_local_sym): New.
+       * elflink.h (elf_link_input_bfd): Don't consider empty
+       merged sections as removed in relocation tests.
+       * elf-bfd.h (_bfd_elf_rela_local_sym): Add prototype.
+       * elf32-i386.c (elf_i386_relocate_section): Handle relocs
+       against STT_SECTION symbol of SHF_MERGE section.
+       * elf32-arm.h (elf32_arm_relocate_section): Likewise.
+       * elf32-avr.c (elf32_avr_relocate_section): Call
+       _bfd_elf_rela_local_sym.
+       * elf32-cris.c (cris_elf_relocate_section): Likewise.
+       * elf32-d10v.c (elf32_d10v_relocate_section): Likewise.
+       * elf32-fr30.c (fr30_final_link_relocate): 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-openrisc.c (openrisc_elf_relocate_section): Likewise.
+       * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+       * elf32-s390.c (elf_s390_relocate_section): Likewise.
+       * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
+       * elf32-v850.c (v850_elf_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-sparc.c (sparc64_elf_relocate_section): Likewise.
+       * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
+       * elf-hppa.h (elf_hppa_relocate_section): Likewise.
+       * elf-m10200.c (mn10200_elf_relocate_section): Likewise.
+       * elf-m10300.c (mn10300_elf_relocate_section): Likewise.
+       * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise.
+       * elf32-sh.c (sh_elf_relocate_section): Likewise for
+       !partial_inplace relocs. Handle relocs against STT_SECTION
+       symbol of SHF_MERGE for partial_inplace relocs.
+
 2001-11-21  Nick Clifton  <nickc@cambridge.redhat.com>
 
        * po/Make-in (distclean): Move SRC-POTFILES.in and
index b621327ed08e2230ca27e5be4eee483859c8d826..026d8cf4224195e155a06ca4078f6182ddd294ee 100644 (file)
@@ -1140,6 +1140,8 @@ extern void _bfd_elf_fprintf_vma
 
 extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
   PARAMS ((const Elf_Internal_Rela *));
+extern bfd_vma _bfd_elf_rela_local_sym
+  PARAMS ((bfd *, Elf_Internal_Sym *, asection *, Elf_Internal_Rela *));
 
 extern unsigned long bfd_elf_hash
   PARAMS ((const char *));
index e584bb9476579898d822c791c48b480b827c0a0d..cca760dad3499072391f0eaad87112a3a72d8059 100644 (file)
@@ -1325,10 +1325,7 @@ elf_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
          /* This is a local symbol.  */
          sym = local_syms + r_symndx;
          sym_sec = local_sections[r_symndx];
-         relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION
-                          ? 0 : sym->st_value)
-                        + sym_sec->output_offset
-                        + sym_sec->output_section->vma);
+         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 b73ebec33d78f1cfc6d192b382bd7b2172e36d6d..aebae335d714b758165cbb5231954f44c740a02e 100644 (file)
@@ -394,9 +394,7 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index ff883508321b3366c31a1afa7fffac9256c541f7..9bec736aa3ebb4fe5def44b927d3cd554f6d2763 100644 (file)
@@ -610,9 +610,7 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index 7bffecdb40f9eb6419795addba3c6f8ffaaaae00..51ae3dbdbf707a5dfcf55495905cf8b236d0d84e 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6370,3 +6370,35 @@ _bfd_elf_reloc_type_class (rela)
 {
   return reloc_class_normal;
 }
+
+/* For RELA architectures, return what the relocation value for
+   relocation against a local symbol.  */
+
+bfd_vma
+_bfd_elf_rela_local_sym (abfd, sym, sec, rel)
+     bfd *abfd;
+     Elf_Internal_Sym *sym;
+     asection *sec;
+     Elf_Internal_Rela *rel;
+{
+  bfd_vma relocation;
+
+  relocation = (sec->output_section->vma
+               + sec->output_offset
+               + sym->st_value);
+  if ((sec->flags & SEC_MERGE)
+      && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+    {
+      asection *msec;
+
+      msec = sec;
+      rel->r_addend =
+       _bfd_merged_section_offset (abfd, &msec,
+                                   elf_section_data (sec)->merge_info,
+                                   sym->st_value + rel->r_addend,
+                                   (bfd_vma) 0)
+       - relocation;
+      rel->r_addend += msec->output_section->vma + msec->output_offset;
+    }
+  return relocation;
+}
index 83a2d6d7ff06b73b0fe7e761ae7967c5b4acabaf..6bd1fbb5cdecb0ca1c2b40721ff9081de26eab77 100644 (file)
@@ -1858,9 +1858,51 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
+#ifdef USE_REL
          relocation = (sec->output_section->vma
                        + sec->output_offset
                        + sym->st_value);
+         if ((sec->flags & SEC_MERGE)
+                  && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+           {
+             asection *msec;
+             bfd_vma addend, value;
+
+             if (howto->rightshift)
+               {
+                 (*_bfd_error_handler)
+                   (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
+                    bfd_archive_filename (input_bfd),
+                    bfd_get_section_name (input_bfd, input_section),
+                    (long) rel->r_offset, howto->name);
+                 return false;
+               }
+
+             value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+
+             /* Get the (signed) value from the instruction.  */
+             addend = value & howto->src_mask;
+             if (addend & ((howto->src_mask + 1) >> 1))
+               {
+                 bfd_signed_vma mask;
+
+                 mask = -1;
+                 mask &= ~ howto->src_mask;
+                 addend |= mask;
+               }
+             msec = sec;
+             addend =
+               _bfd_merged_section_offset (output_bfd, &msec,
+                                           elf_section_data (sec)->merge_info,
+                                           sym->st_value + addend, (bfd_vma) 0)
+               - relocation;
+             addend += msec->output_section->vma + msec->output_offset;
+             value = (value & ~ howto->dst_mask) | (addend & howto->dst_mask);
+             bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+           }
+#else
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+#endif
        }
       else
        {
index 1081b51046fb86d439da739170a37b1df1a04652..3efd24886b3e4a0e420d8f63258c3d497a02a40c 100644 (file)
@@ -778,9 +778,7 @@ elf32_avr_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         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 f8f072563146962fa7d8ef0a62c262210ce7da91..674a7b12e26088e2b669f3076410850a28039973 100644 (file)
@@ -870,9 +870,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         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));
index 5b6ed270890c519cfd335a288a65bef2e67b706d..9ec0aa5ae77a1a946ea6b414e70c6318fd4b7485 100644 (file)
@@ -356,7 +356,7 @@ elf32_d10v_check_relocs (abfd, info, sec, relocs)
 static boolean
 elf32_d10v_relocate_section (output_bfd, info, input_bfd, input_section,
                            contents, relocs, local_syms, local_sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
+     bfd *output_bfd;
      struct bfd_link_info *info;
      bfd *input_bfd;
      asection *input_section;
@@ -422,9 +422,7 @@ elf32_d10v_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index 320a3c169bf195f1def523f3e9877d04d46c5cd8..86f70efc1c78585a2f4f62fdc7c12afdf6238ce4 100644 (file)
@@ -503,7 +503,7 @@ fr30_final_link_relocate (howto, input_bfd, input_section, contents, rel, reloca
 static boolean
 fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                           contents, relocs, local_syms, local_sections)
-     bfd *                   output_bfd ATTRIBUTE_UNUSED;
+     bfd *                   output_bfd;
      struct bfd_link_info *  info;
      bfd *                   input_bfd;
      asection *              input_section;
@@ -571,9 +571,7 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         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 0c37002b91bd116822dcdff6ede326271b43840b..5ca695520a99deb1faf24253fb43b878fec4f566 100644 (file)
@@ -473,9 +473,7 @@ elf32_h8_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index 481bde7e5d0e48d918e9560d9ddbce5e79e48625..9f1357691a34a2198d6336c8d4ddb34399466632 100644 (file)
@@ -3650,10 +3650,7 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
          /* This is a local symbol, h defaults to NULL.  */
          sym = local_syms + r_symndx;
          sym_sec = local_sections[r_symndx];
-         relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION
-                          ? 0 : sym->st_value)
-                        + sym_sec->output_offset
-                        + sym_sec->output_section->vma);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
        }
       else
        {
index 3f9c9c1e210e0d42ed304c44ad3fc8f36bb84814..3b9ad347e6e8101157bed433efc9a1b7e995c194 100644 (file)
@@ -1367,9 +1367,8 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          sec = local_sections[r_symndx];
          sym_name = "<local symbol>";
 
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         addend = rel->r_addend;
        }
       else
        {
index 238772e4c6192d02e3e81b6ab157c82f6e4d0913..9299b1c27c08b7e479f876b7d6b607d2a2b3ae97 100644 (file)
@@ -1770,6 +1770,32 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
          relocation = (sec->output_section->vma
                        + sec->output_offset
                        + sym->st_value);
+         if ((sec->flags & SEC_MERGE)
+             && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+           {
+             asection *msec;
+             bfd_vma addend;
+
+             if (howto->src_mask != 0xffffffff)
+               {
+                 (*_bfd_error_handler)
+                   (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
+                    bfd_archive_filename (input_bfd),
+                    bfd_get_section_name (input_bfd, input_section),
+                    (long) rel->r_offset, howto->name);
+                 return false;
+               }
+
+             addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
+             msec = sec;
+             addend =
+               _bfd_merged_section_offset (output_bfd, &msec,
+                                           elf_section_data (sec)->merge_info,
+                                           sym->st_value + addend, (bfd_vma) 0)
+               - relocation;
+             addend += msec->output_section->vma + msec->output_offset;
+             bfd_put_32 (input_bfd, addend, contents + rel->r_offset);
+           }
        }
       else
        {
index 142d1385853eae47897a141c8fb0d3ee651d0a3f..7b5d0520c214d31c72d0b6daf7de060f225dc35f 100644 (file)
@@ -934,9 +934,7 @@ elf32_i860_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         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 eb2237f19aad26ebce0cd1334c6b8da66e3d1924..214fed172f19ad97234bcfbbbaf51e37b3758dfa 100644 (file)
@@ -1106,9 +1106,16 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              sym = local_syms + r_symndx;
              sec = local_sections[r_symndx];
              sym_name = "<local symbol>";
+#ifndef USE_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
+                symbols.  See elf32-i386.c for how to do this.  */
              relocation = (sec->output_section->vma
                            + sec->output_offset
                            + sym->st_value);
+#endif
            }
          else
            {
index a613024c24a8ece88f1dea608967931fe4c9167b..68f4a23005c49449dfac7930aec860a82085f375 100644 (file)
@@ -1389,9 +1389,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index 669ba51be32bd7d341d688122a96560789f572cb..8275965c9a80dbaf2b5efcdf2c41ac3fb27c10e5 100644 (file)
@@ -410,7 +410,7 @@ mcore_elf_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
 static boolean
 mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                          contents, relocs, local_syms, local_sections)
-     bfd * output_bfd ATTRIBUTE_UNUSED;
+     bfd * output_bfd;
      struct bfd_link_info * info;
      bfd * input_bfd;
      asection * input_section;
@@ -510,9 +510,8 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         addend = rel->r_addend;
        }
       else
        {
index 20358e09e38423e7eb380523b99747ec2796b212..5a7b42ff61d8f7a0edd04fcb1c5043572344b083 100644 (file)
@@ -324,7 +324,7 @@ openrisc_final_link_relocate (howto, input_bfd, input_section, contents, rel,
 static boolean
 openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                               contents, relocs, local_syms, local_sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
+     bfd *output_bfd;
      struct bfd_link_info *info;
      bfd *input_bfd;
      asection *input_section;
@@ -394,8 +394,7 @@ openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset + sym->st_value);
+         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 cd6bd959607c4d846ade80797e344154dede04bb..2af84004ab423d09b6be0e6e9355d4f5d0959ed8 100644 (file)
@@ -2998,9 +2998,8 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          sec = local_sections[r_symndx];
          sym_name = "<local symbol>";
 
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         addend = rel->r_addend;
          /* Relocs to local symbols are always resolved.  */
          will_become_local = 1;
        }
index 2153a4c5e84190c3e241aedbd699faedbbd1c101..f608fb0aa6dbefaa88b6ca9a7e2ef2439bd114ff 100644 (file)
@@ -1664,9 +1664,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index 35ebf1ab6e622270274f8550d64f7773e91260c3..74b725a0ee264fec867a674f71792d276a8bcd06 100644 (file)
@@ -2960,7 +2960,7 @@ sh_elf_discard_copies (h, ignore)
 static boolean
 sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                         contents, relocs, local_syms, local_sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
+     bfd *output_bfd;
      struct bfd_link_info *info;
      bfd *input_bfd;
      asection *input_section;
@@ -3041,7 +3041,6 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          relocation = (sec->output_section->vma
                        + sec->output_offset
                        + sym->st_value);
-
          if (info->relocateable)
            {
              /* This is a relocateable link.  We don't have to change
@@ -3079,6 +3078,37 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
              continue;
            }
+         else if (! howto->partial_inplace)
+           {
+             relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+             addend = rel->r_addend;
+           }
+         else if ((sec->flags & SEC_MERGE)
+                  && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+           {
+             asection *msec;
+
+             if (howto->rightshift || howto->src_mask != 0xffffffff)
+               {
+                 (*_bfd_error_handler)
+                   (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
+                    bfd_archive_filename (input_bfd),
+                    bfd_get_section_name (input_bfd, input_section),
+                    (long) rel->r_offset, howto->name);
+                 return false;
+               }
+
+              addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
+              msec = sec;
+              addend =
+               _bfd_merged_section_offset (output_bfd, &msec,
+                                           elf_section_data (sec)->merge_info,
+                                           sym->st_value + addend, (bfd_vma) 0)
+               - relocation;
+             addend += msec->output_section->vma + msec->output_offset;
+             bfd_put_32 (input_bfd, addend, contents + rel->r_offset);
+             addend = 0;
+           }
        }
       else
        {
index 96fc3e9c8d9b3bd86bd12cfcab527d0bb1f49ed0..9458061909257e5950e7d94f003c7e635879115f 100644 (file)
@@ -1176,9 +1176,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index b65702004897d9a110850df15becb7e8ab570f99..c873ed9a651762fdb62b7fa501f7a95b6e30b1c8 100644 (file)
@@ -1597,9 +1597,7 @@ v850_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
 #if 0
          {
            char * name;
index 69cfef9797b8843d5ac595bdfba3429e3bf63969..783f01030805b9d9dc304805258d2955c089e0b5 100644 (file)
@@ -3318,9 +3318,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index 68dc96ae194d965734b67dbca18c7dfc8f2e6c6d..95cbd76f1bc4a15fd0ef53026d44a29e98a50fd8 100644 (file)
@@ -1091,9 +1091,7 @@ mmix_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         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 97aa485c9d9a83f2b497179c8ce976b777adac94..02d2913d3b6dc43b24527bd8e6d1e6b650044145 100644 (file)
@@ -3140,9 +3140,8 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          sec = local_sections[r_symndx];
          sym_name = "<local symbol>";
 
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         addend = rel->r_addend;
        }
       else
        {
index f4c10754af9c2716528e02014086cef5440bc640..222e1e44bf810a5376c54fa8263436fc947cd301 100644 (file)
@@ -1643,9 +1643,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index 9e06d605d75e408fc27dde24d26a5547df24dac7..6af2b15166ce340df1b5ff71272b611d6729c68a 100644 (file)
@@ -1969,9 +1969,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
index df303e7e034727faea743bd9c3bd1f697f6bb70c..349540f2700605ee88999f65872723abfcb8b2ca 100644 (file)
@@ -1229,9 +1229,7 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rela);
        }
       else
        {
index 6b06bd0b6586ed1339ef1674feb5a833c70026ee..26b28f2e53d1fb5a2197232c9083d38af5a37046 100644 (file)
@@ -6317,7 +6317,9 @@ elf_link_input_bfd (finfo, input_bfd)
                           || h->root.type == bfd_link_hash_defweak)
                          && ! bfd_is_abs_section (h->root.u.def.section)
                          && bfd_is_abs_section (h->root.u.def.section
-                                                ->output_section))
+                                                ->output_section)
+                         && elf_section_data (h->root.u.def.section)->merge_info
+                            == NULL)
                        {
 #if BFD_VERSION_DATE < 20031005
                          if ((o->flags & SEC_DEBUGGING) != 0)
@@ -6348,7 +6350,8 @@ elf_link_input_bfd (finfo, input_bfd)
 
                      if (sec != NULL
                          && ! bfd_is_abs_section (sec)
-                         && bfd_is_abs_section (sec->output_section))
+                         && bfd_is_abs_section (sec->output_section)
+                         && elf_section_data (sec)->merge_info == NULL)
                        {
 #if BFD_VERSION_DATE < 20031005
                          if ((o->flags & SEC_DEBUGGING) != 0
index 05ae66840d0c58b7587b5390e75b97f26e58a197..ed06f546440cc09470969ee2f3169c6d44ade362 100644 (file)
@@ -3481,9 +3481,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
          /* Reloc against local symbol.  */
          sym = local_syms + r_symndx;
          sym_sec = local_sections[r_symndx];
-         value  = (sym_sec->output_section->vma
-                   + sym_sec->output_offset
-                   + sym->st_value);
+         value = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
        }
       else
        {
index 9440e1447ac67fbed0fd27501c0a8351cf8e293f..b2caa0b36d25ff17daf9ff6064206e3477fd46a6 100644 (file)
@@ -1,3 +1,10 @@
+2001-11-23  Jakub Jelinek  <jakub@redhat.com>
+
+       * config/tc-alpha.c (tc_gen_reloc): Remove SEC_MERGE test.
+       * write.c (adjust_reloc_syms): Don't handle relocs against
+       SEC_MERGE section symbols specially.
+       (fixup_segment): Likewise.
+
 2001-11-21  Richard Sandiford  <rsandifo@redhat.com>
 
        * config/tc-mips.c (mips_need_elf_addend_fixup): New, extracted from...
index f73c8628e477229e1a591b86009105b2c9705fa9..f9908e7924ac1553383bf27080efe6770d7e49ad 100644 (file)
@@ -1507,8 +1507,7 @@ tc_gen_reloc (sec, fixp)
        * at assembly time.  bfd_perform_reloc doesn't know about this sort
        * of thing, and as a result we need to fake it out here.
        */
-      if ((S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy)
-          || (S_GET_SEGMENT (fixp->fx_addsy)->flags & SEC_MERGE))
+      if ((S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy))
          && !S_IS_COMMON (fixp->fx_addsy))
        reloc->addend -= symbol_get_bfdsym (fixp->fx_addsy)->value;
 #endif
index 817633589bfa9eea9daf4b218bb4dec37073792a..5397aa09949dc4d28d1b7b68cfaccb856b8e8a99 100644 (file)
@@ -873,13 +873,6 @@ adjust_reloc_syms (abfd, sec, xxx)
            symbol_mark_used_in_reloc (fixp->fx_addsy);
            goto done;
          }
-
-       /* Never adjust a reloc against local symbol in a merge section.  */
-       if (symsec->flags & SEC_MERGE)
-         {
-           symbol_mark_used_in_reloc (fixp->fx_addsy);
-           goto done;
-         }
 #endif
 
        /* Is there some other reason we can't adjust this one?  (E.g.,
@@ -2815,9 +2808,6 @@ fixup_segment (fixP, this_segment_type)
              else if (add_symbol_segment == undefined_section
 #ifdef BFD_ASSEMBLER
                       || bfd_is_com_section (add_symbol_segment)
-                      || (bfd_get_section_flags (stdoutput,
-                                                 add_symbol_segment)
-                          & SEC_MERGE) != 0
 #endif
                       )
                {