]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
elf_backend_dtrel_excludes_plt
authorAlan Modra <amodra@gmail.com>
Wed, 23 Nov 2016 04:37:17 +0000 (15:07 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 23 Nov 2016 05:13:25 +0000 (15:43 +1030)
Now that all targets creating .rel.plt/.rela.plt use the ELF hash
table shortcut srelplt, the generic ELF code can set up DT_RELSZ/
DT_RELASZ and DT_REL/DT_RELA for targets that don't want PLT relocs
included in those tags.

* elf-bfd.h (struct elf_backend_data): Add dtrel_excludes_plt.
* elfxx-target.h (elf_backend_dtrel_excludes_plt): Define.
(elfNN_bed): Init new field.
* elflink.c (bfd_elf_final_link): Add and use htab variable.  Handle
dtrel_excludes_plt.
* elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_sections): Delete
DT_RELASZ code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-arc.c (elf_arc_finish_dynamic_sections): Delete DT_RELASZ code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-arm.c (elf32_arm_finish_dynamic_sections): Delete code
subtracting off plt relocs from DT_RELSZ, DT_RELASZ.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-cr16.c (_bfd_cr16_elf_finish_dynamic_sections): Delete
DT_RELASZ code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-cris.c (elf_cris_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-hppa.c (elf32_hppa_finish_dynamic_sections): Delete DT_RELASZ
and DT_RELA code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-i386.c (elf_i386_finish_dynamic_sections): Delete DT_RELSZ
and DT_REL code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-lm32.c (lm32_elf_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-m32r.c (m32r_elf_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-m68k.c (elf_m68k_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-metag.c (elf_metag_finish_dynamic_sections): Delete DT_RELASZ
and DT_RELA code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-microblaze.c (microblaze_elf_finish_dynamic_sections): Delete
DT_RELASZ and DT_RELA code.  Use ELF htab shortcuts for other
dynamic sections.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-mips.c (elf_backend_dtrel_excludes_plt): Define.
* elf32-nds32.c (nds32_elf_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-nios2.c (nios2_elf32_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-or1k.c (or1k_elf_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-ppc.c (ppc_elf_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-sh.c (sh_elf_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-sparc.c (elf_backend_dtrel_excludes_plt): Define.
* elf32-vax.c (elf_vax_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf32-xtensa.c (elf_xtensa_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf64-alpha.c (elf64_alpha_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Delete DT_RELASZ
and DT_RELA code.
(elf_backend_dtrel_excludes_plt): Define.
* elf64-sh64.c (sh64_elf64_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_sections): Delete
DT_RELASZ code.
(elf_backend_dtrel_excludes_plt): Define.
* elfnn-ia64.c (elfNN_ia64_finish_dynamic_sections): Delete DT_RELASZ
code.
(elf_backend_dtrel_excludes_plt): Define.
* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Delete
DT_RELASZ code.
* elfxx-sparc.c (sparc_finish_dyn): Delete DT_RELASZ code.

33 files changed:
bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf-m10300.c
bfd/elf32-arc.c
bfd/elf32-arm.c
bfd/elf32-cr16.c
bfd/elf32-cris.c
bfd/elf32-hppa.c
bfd/elf32-i386.c
bfd/elf32-lm32.c
bfd/elf32-m32r.c
bfd/elf32-m68k.c
bfd/elf32-metag.c
bfd/elf32-microblaze.c
bfd/elf32-mips.c
bfd/elf32-nds32.c
bfd/elf32-nios2.c
bfd/elf32-or1k.c
bfd/elf32-ppc.c
bfd/elf32-sh.c
bfd/elf32-sparc.c
bfd/elf32-vax.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-ppc.c
bfd/elf64-sh64.c
bfd/elf64-x86-64.c
bfd/elflink.c
bfd/elfnn-aarch64.c
bfd/elfnn-ia64.c
bfd/elfxx-mips.c
bfd/elfxx-sparc.c
bfd/elfxx-target.h

index 3f43a5a3857751d3e73b1212d87cbeebf137b4eb..19a1026af36b026218216c511cc08d8221a07a67 100644 (file)
@@ -1,3 +1,91 @@
+2016-11-23  Alan Modra  <amodra@gmail.com>
+
+       * elf-bfd.h (struct elf_backend_data): Add dtrel_excludes_plt.
+       * elfxx-target.h (elf_backend_dtrel_excludes_plt): Define.
+       (elfNN_bed): Init new field.
+       * elflink.c (bfd_elf_final_link): Add and use htab variable.  Handle
+       dtrel_excludes_plt.
+       * elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_sections): Delete
+       DT_RELASZ code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-arc.c (elf_arc_finish_dynamic_sections): Delete DT_RELASZ code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-arm.c (elf32_arm_finish_dynamic_sections): Delete code
+       subtracting off plt relocs from DT_RELSZ, DT_RELASZ.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-cr16.c (_bfd_cr16_elf_finish_dynamic_sections): Delete
+       DT_RELASZ code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-cris.c (elf_cris_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-hppa.c (elf32_hppa_finish_dynamic_sections): Delete DT_RELASZ
+       and DT_RELA code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-i386.c (elf_i386_finish_dynamic_sections): Delete DT_RELSZ
+       and DT_REL code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-lm32.c (lm32_elf_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-m32r.c (m32r_elf_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-m68k.c (elf_m68k_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-metag.c (elf_metag_finish_dynamic_sections): Delete DT_RELASZ
+       and DT_RELA code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-microblaze.c (microblaze_elf_finish_dynamic_sections): Delete
+       DT_RELASZ and DT_RELA code.  Use ELF htab shortcuts for other
+       dynamic sections.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-mips.c (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-nds32.c (nds32_elf_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-nios2.c (nios2_elf32_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-or1k.c (or1k_elf_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-ppc.c (ppc_elf_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-sh.c (sh_elf_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-sparc.c (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-vax.c (elf_vax_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf32-xtensa.c (elf_xtensa_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf64-alpha.c (elf64_alpha_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Delete DT_RELASZ
+       and DT_RELA code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf64-sh64.c (sh64_elf64_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_sections): Delete
+       DT_RELASZ code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elfnn-ia64.c (elfNN_ia64_finish_dynamic_sections): Delete DT_RELASZ
+       code.
+       (elf_backend_dtrel_excludes_plt): Define.
+       * elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Delete
+       DT_RELASZ code.
+       * elfxx-sparc.c (sparc_finish_dyn): Delete DT_RELASZ code.
+
 2016-11-23  Alan Modra  <amodra@gmail.com>
 
        * elf-m10300.c (mn10300_elf_check_relocs): Use elf htab shortcuts
index 50151cbcbb0b0162c033105f3c93f9f23465708e..7c78899c34e509ebf5da479c91508a896b0beb45 100644 (file)
@@ -1427,6 +1427,10 @@ struct elf_backend_data
      backend relocate_section routine for relocatable linking.  */
   unsigned rela_normal : 1;
 
+  /* Set if DT_REL/DT_RELA/DT_RELSZ/DT_RELASZ should not include PLT
+     relocations.  */
+  unsigned dtrel_excludes_plt : 1;
+
   /* TRUE if addresses "naturally" sign extend.  This is used when
      swapping in from Elf32 when BFD64.  */
   unsigned sign_extend_vma : 1;
index 0b62fa9cc4828f34763b4b82805c4804de26b068..1ea5c27b4f5566e2d7e4054b841c8654fd431832 100644 (file)
@@ -5453,22 +5453,6 @@ _bfd_mn10300_elf_finish_dynamic_sections (bfd * output_bfd,
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* My reading of the SVR4 ABI indicates that the
-                procedure linkage table relocs (DT_JMPREL) should be
-                included in the overall relocs (DT_RELA).  This is
-                what Solaris does.  However, UnixWare can not handle
-                that case.  Therefore, we override the DT_RELASZ entry
-                here to make it not include the JMPREL relocs.  Since
-                the linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             s = htab->root.srelplt;
-             if (s != NULL)
-               dyn.d_un.d_val -= s->size;
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
        }
 
@@ -5609,5 +5593,6 @@ mn10300_elf_mkobject (bfd *abfd)
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    12
+#define elf_backend_dtrel_excludes_plt 1
 
 #include "elf32-target.h"
index 314a162dc9072fe2077d0d929c0f3d6a8d1bca46..3d39c3a1352b0789d03dd7baa156a85a95f6bf77 100644 (file)
@@ -2240,7 +2240,6 @@ elf_arc_finish_dynamic_sections (bfd * output_bfd,
              GET_SYMBOL_OR_SECTION (DT_PLTGOT, NULL, ".plt")
              GET_SYMBOL_OR_SECTION (DT_JMPREL, NULL, ".rela.plt")
              GET_SYMBOL_OR_SECTION (DT_PLTRELSZ, NULL, ".rela.plt")
-             GET_SYMBOL_OR_SECTION (DT_RELASZ, NULL, ".rela.plt")
              GET_SYMBOL_OR_SECTION (DT_VERSYM, NULL, ".gnu.version")
              GET_SYMBOL_OR_SECTION (DT_VERDEF, NULL, ".gnu.version_d")
              GET_SYMBOL_OR_SECTION (DT_VERNEED, NULL, ".gnu.version_r")
@@ -2290,12 +2289,6 @@ elf_arc_finish_dynamic_sections (bfd * output_bfd,
                    do_it = TRUE;
                    break;
 
-                 case DT_RELASZ:
-                   if (s != NULL)
-                     internal_dyn.d_un.d_val -= s->size;
-                   do_it = TRUE;
-                   break;
-
                  default:
                    break;
                }
@@ -2628,6 +2621,7 @@ elf32_arc_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
 #define elf_backend_rela_plts_and_copies_p 1
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    12
+#define elf_backend_dtrel_excludes_plt 1
 
 #define elf_backend_may_use_rel_p      0
 #define elf_backend_may_use_rela_p     1
index dced01aa00d7f1270558a08ba5d5a2867fd990d9..b1bec39d65dd64361403cc2c38a203dd231e54e3 100644 (file)
@@ -16489,35 +16489,15 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info
 
            case DT_RELSZ:
            case DT_RELASZ:
-             if (!htab->symbian_p)
-               {
-                 /* My reading of the SVR4 ABI indicates that the
-                    procedure linkage table relocs (DT_JMPREL) should be
-                    included in the overall relocs (DT_REL).  This is
-                    what Solaris does.  However, UnixWare can not handle
-                    that case.  Therefore, we override the DT_RELSZ entry
-                    here to make it not include the JMPREL relocs.  Since
-                    the linker script arranges for .rel(a).plt to follow all
-                    other relocation sections, we don't have to worry
-                    about changing the DT_REL entry.  */
-                 s = htab->root.srelplt;
-                 if (s != NULL)
-                   dyn.d_un.d_val -= s->size;
-                 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-                 break;
-               }
-             /* Fall through.  */
-
            case DT_REL:
            case DT_RELA:
              /* In the BPABI, the DT_REL tag must point at the file
                 offset, not the VMA, of the first relocation
                 section.  So, we use code similar to that in
                 elflink.c, but do not check for SHF_ALLOC on the
-                relcoation section, since relocations sections are
-                never allocated under the BPABI.  The comments above
-                about Unixware notwithstanding, we include all of the
-                relocations here.  */
+                relocation section, since relocation sections are
+                never allocated under the BPABI.  PLT relocs are also
+                included.  */
              if (htab->symbian_p)
                {
                  unsigned int i;
@@ -19419,6 +19399,7 @@ elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym)
 #define elf_backend_may_use_rel_p      1
 #define elf_backend_may_use_rela_p     0
 #define elf_backend_default_use_rela_p 0
+#define elf_backend_dtrel_excludes_plt 1
 
 #define elf_backend_got_header_size    12
 #define elf_backend_extern_protected_data 1
@@ -19980,6 +19961,8 @@ elf32_arm_symbian_plt_sym_val (bfd_vma i, const asection *plt,
 #define elf_backend_default_use_rela_p 0
 #undef  elf_backend_want_plt_sym
 #define elf_backend_want_plt_sym       0
+#undef  elf_backend_dtrel_excludes_plt
+#define elf_backend_dtrel_excludes_plt 0
 #undef  ELF_MAXPAGESIZE
 #define ELF_MAXPAGESIZE                        0x8000
 
index 631445d58c9c090c177e2ddf471fefd4072f3137..3424c77d70a4fbe8b65f2221c663a198c87e9ea9 100644 (file)
@@ -2735,22 +2735,6 @@ _bfd_cr16_elf_finish_dynamic_sections (bfd * output_bfd,
               dyn.d_un.d_val = s->size;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
               break;
-
-            case DT_RELASZ:
-              /* My reading of the SVR4 ABI indicates that the
-                 procedure linkage table relocs (DT_JMPREL) should be
-                 included in the overall relocs (DT_RELA).  This is
-                 what Solaris does.  However, UnixWare can not handle
-                 that case.  Therefore, we override the DT_RELASZ entry
-                 here to make it not include the JMPREL relocs.  Since
-                 the linker script arranges for .rela.plt to follow all
-                 other relocation sections, we don't have to worry
-                 about changing the DT_RELA entry.  */
-              s = elf_hash_table (info)->srelplt;
-              if (s != NULL)
-                dyn.d_un.d_val -= s->size;
-              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-              break;
             }
         }
 
@@ -2968,5 +2952,6 @@ _bfd_cr16_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSE
 #define elf_backend_plt_readonly        1
 #define elf_backend_want_plt_sym        0
 #define elf_backend_got_header_size     12
+#define elf_backend_dtrel_excludes_plt 1
 
 #include "elf32-target.h"
index 7d388018d3796a121ef90d3c91b76554cf15d043..3de29ec5074f240e76f7a046b7f211d119c9e660 100644 (file)
@@ -2360,20 +2360,6 @@ elf_cris_finish_dynamic_sections (bfd *output_bfd,
                dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* The procedure linkage table relocs (DT_JMPREL) should
-                not be included in the overall relocs (DT_RELA).
-                Therefore, we override the DT_RELASZ entry here to
-                make it not include the JMPREL relocs.  Since the
-                linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             s = elf_hash_table (info)->srelplt;
-             if (s != NULL)
-               dyn.d_un.d_val -= s->size;
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
        }
 
@@ -4338,6 +4324,7 @@ elf_cris_got_elt_size (bfd *abfd ATTRIBUTE_UNUSED,
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    12
 #define elf_backend_got_elt_size elf_cris_got_elt_size
+#define elf_backend_dtrel_excludes_plt 1
 
 /* Later, we my want to optimize RELA entries into REL entries for dynamic
    linking and libraries (if it's a win of any significance).  Until then,
index 63e9e69bea04397607b82fb5c4826629d2c8147b..de3b7ead52d7a9dcc98b3a326a44d9d817429b10 100644 (file)
@@ -4547,27 +4547,6 @@ elf32_hppa_finish_dynamic_sections (bfd *output_bfd,
              s = htab->etab.srelplt;
              dyn.d_un.d_val = s->size;
              break;
-
-           case DT_RELASZ:
-             /* Don't count procedure linkage table relocs in the
-                overall reloc count.  */
-             s = htab->etab.srelplt;
-             if (s == NULL)
-               continue;
-             dyn.d_un.d_val -= s->size;
-             break;
-
-           case DT_RELA:
-             /* We may not be using the standard ELF linker script.
-                If .rela.plt is the first .rela section, we adjust
-                DT_RELA to not include it.  */
-             s = htab->etab.srelplt;
-             if (s == NULL)
-               continue;
-             if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset)
-               continue;
-             dyn.d_un.d_ptr += s->size;
-             break;
            }
 
          bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -4670,6 +4649,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
 #define elf_backend_want_plt_sym            0
 #define elf_backend_got_header_size         8
 #define elf_backend_rela_normal                     1
+#define elf_backend_dtrel_excludes_plt      1
 
 #define TARGET_BIG_SYM         hppa_elf32_vec
 #define TARGET_BIG_NAME                "elf32-hppa"
index 311ca37cdb493c3935f673c8ac92791360ae8cfe..6b1f1b02a60bbfebc3f940fcebb8445864c928b8 100644 (file)
@@ -5746,31 +5746,6 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd,
              s = htab->elf.srelplt;
              dyn.d_un.d_val = s->size;
              break;
-
-           case DT_RELSZ:
-             /* My reading of the SVR4 ABI indicates that the
-                procedure linkage table relocs (DT_JMPREL) should be
-                included in the overall relocs (DT_REL).  This is
-                what Solaris does.  However, UnixWare can not handle
-                that case.  Therefore, we override the DT_RELSZ entry
-                here to make it not include the JMPREL relocs.  */
-             s = htab->elf.srelplt;
-             if (s == NULL)
-               continue;
-             dyn.d_un.d_val -= s->size;
-             break;
-
-           case DT_REL:
-             /* We may not be using the standard ELF linker script.
-                If .rel.plt is the first .rel section, we adjust
-                DT_REL to not include it.  */
-             s = htab->elf.srelplt;
-             if (s == NULL)
-               continue;
-             if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset)
-               continue;
-             dyn.d_un.d_ptr += s->size;
-             break;
            }
 
          bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -6075,6 +6050,7 @@ elf_i386_hash_symbol (struct elf_link_hash_entry *h)
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    12
 #define elf_backend_plt_alignment      4
+#define elf_backend_dtrel_excludes_plt 1
 #define elf_backend_extern_protected_data 1
 #define elf_backend_caches_rawsize     1
 
index 405768cf228f5e809f81f076334659ce90c3ff3a..23129e065b0b7eac9dee158a860a2464da900c79 100644 (file)
@@ -1428,24 +1428,6 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd,
              dyn.d_un.d_val = s->size;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
               break;
-
-            case DT_RELASZ:
-              /* My reading of the SVR4 ABI indicates that the
-                 procedure linkage table relocs (DT_JMPREL) should be
-                 included in the overall relocs (DT_RELA).  This is
-                 what Solaris does.  However, UnixWare can not handle
-                 that case.  Therefore, we override the DT_RELASZ entry
-                 here to make it not include the JMPREL relocs.  Since
-                 the linker script arranges for .rela.plt to follow all
-                 other relocation sections, we don't have to worry
-                 about changing the DT_RELA entry.  */
-              if (htab->root.srelplt != NULL)
-                {
-                  s = htab->root.srelplt;
-                 dyn.d_un.d_val -= s->size;
-                }
-              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-              break;
             }
         }
 
@@ -2656,6 +2638,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 #define elf_backend_want_got_plt                1
 #define elf_backend_want_plt_sym                0
 #define elf_backend_got_header_size             12
+#define elf_backend_dtrel_excludes_plt         1
 #define bfd_elf32_bfd_link_hash_table_create    lm32_elf_link_hash_table_create
 #define elf_backend_check_relocs                lm32_elf_check_relocs
 #define elf_backend_reloc_type_class            lm32_elf_reloc_type_class
index 9d1492553b856ed60fd1f7417d017910b91dd623..885917d4a8df6f2a292f54479db0e894b77dde95 100644 (file)
@@ -3330,24 +3330,6 @@ m32r_elf_finish_dynamic_sections (bfd *output_bfd,
              dyn.d_un.d_val = s->size;
               bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
               break;
-
-            case DT_RELASZ:
-              /* My reading of the SVR4 ABI indicates that the
-                 procedure linkage table relocs (DT_JMPREL) should be
-                 included in the overall relocs (DT_RELA).  This is
-                 what Solaris does.  However, UnixWare can not handle
-                 that case.  Therefore, we override the DT_RELASZ entry
-                 here to make it not include the JMPREL relocs.  Since
-                 the linker script arranges for .rela.plt to follow all
-                 other relocation sections, we don't have to worry
-                 about changing the DT_RELA entry.  */
-              if (htab->root.srelplt != NULL)
-                {
-                  s = htab->root.srelplt;
-                 dyn.d_un.d_val -= s->size;
-                }
-              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-              break;
             }
         }
 
@@ -4014,6 +3996,7 @@ m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
 #define elf_backend_plt_readonly 1
 #define elf_backend_want_plt_sym 0
 #define elf_backend_got_header_size 12
+#define elf_backend_dtrel_excludes_plt 1
 
 #define elf_backend_may_use_rel_p       1
 #ifdef USE_M32R_OLD_RELOC
@@ -4048,4 +4031,3 @@ m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
 #define elf32_bed               elf32_m32r_lin_bed
 
 #include "elf32-target.h"
-
index 58df4c9070541b1d2a2fc3b8301602b4cb0686f9..af3f02f2617d8d66d5303a4abab44bc370c6c0ba 100644 (file)
@@ -4471,20 +4471,6 @@ elf_m68k_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* The procedure linkage table relocs (DT_JMPREL) should
-                not be included in the overall relocs (DT_RELA).
-                Therefore, we override the DT_RELASZ entry here to
-                make it not include the JMPREL relocs.  Since the
-                linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             s = elf_hash_table (info)->srelplt;
-             if (s != NULL)
-               dyn.d_un.d_val -= s->size;
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
        }
 
@@ -4854,5 +4840,6 @@ elf_m68k_add_symbol_hook (bfd *abfd,
 #define elf_backend_want_plt_sym 0
 #define elf_backend_got_header_size    12
 #define elf_backend_rela_normal                1
+#define elf_backend_dtrel_excludes_plt 1
 
 #include "elf32-target.h"
index 60d47287a37fe47daa0077cde801aaebc23a3099..39d3fffcb66b76d3cafebb03ee9cdbabc075bb2a 100644 (file)
@@ -3331,28 +3331,6 @@ elf_metag_finish_dynamic_sections (bfd *output_bfd,
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* Don't count procedure linkage table relocs in the
-                overall reloc count.  */
-             if (htab->etab.srelplt) {
-               s = htab->etab.srelplt;
-               dyn.d_un.d_val -= s->size;
-             }
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
-
-           case DT_RELA:
-             /* We may not be using the standard ELF linker script.
-                If .rela.plt is the first .rela section, we adjust
-                DT_RELA to not include it.  */
-             if (htab->etab.srelplt) {
-               s = htab->etab.srelplt;
-               if (dyn.d_un.d_ptr == s->output_section->vma + s->output_offset)
-                 dyn.d_un.d_ptr += s->size;
-             }
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
 
        }
@@ -4314,6 +4292,7 @@ elf_metag_plt_sym_val (bfd_vma i, const asection *plt,
 #define elf_backend_want_got_sym               0
 #define elf_backend_want_plt_sym               0
 #define elf_backend_plt_readonly               1
+#define elf_backend_dtrel_excludes_plt         1
 
 #define bfd_elf32_bfd_reloc_type_lookup        metag_reloc_type_lookup
 #define bfd_elf32_bfd_reloc_name_lookup        metag_reloc_name_lookup
index c700bcb64ffe812ee2608e320aa2f517108e9dbe..c1691f857ca308168eaca6fb87b0e4967510d45f 100644 (file)
@@ -3331,47 +3331,52 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = htab->elf.splt;
-      BFD_ASSERT (splt != NULL && sdyn != NULL);
-
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
       dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
       for (; dyncon < dynconend; dyncon++)
         {
           Elf_Internal_Dyn dyn;
-          const char *name;
+         asection *s;
           bfd_boolean size;
 
           bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
 
           switch (dyn.d_tag)
             {
-            case DT_PLTGOT:   name = ".got.plt"; size = FALSE; break;
-            case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break;
-            case DT_JMPREL:   name = ".rela.plt"; size = FALSE; break;
-            case DT_RELA:     name = ".rela.dyn"; size = FALSE; break;
-            case DT_RELASZ:   name = ".rela.dyn"; size = TRUE; break;
-            default:     name = NULL; size = FALSE; break;
-            }
+           case DT_PLTGOT:
+             s = htab->elf.sgotplt;
+             size = FALSE;
+             break;
 
-          if (name != NULL)
-            {
-              asection *s;
+           case DT_PLTRELSZ:
+             s = htab->elf.srelplt;
+             size = TRUE;
+             break;
 
-              s = bfd_get_section_by_name (output_bfd, name);
-              if (s == NULL)
-                dyn.d_un.d_val = 0;
-              else
-                {
-                  if (! size)
-                    dyn.d_un.d_ptr = s->vma;
-                  else
-                    dyn.d_un.d_val = s->size;
-                }
-              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+           case DT_JMPREL:
+             s = htab->elf.srelplt;
+             size = FALSE;
+             break;
+
+           default:
+             continue;
             }
+
+         if (s == NULL)
+           dyn.d_un.d_val = 0;
+         else
+           {
+             if (!size)
+               dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
+             else
+               dyn.d_un.d_val = s->size;
+           }
+         bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
         }
 
+      splt = htab->elf.splt;
+      BFD_ASSERT (splt != NULL && sdyn != NULL);
+
       /* Clear the first entry in the procedure linkage table,
         and put a nop in the last four bytes.  */
       if (splt->size > 0)
@@ -3465,6 +3470,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
 #define elf_backend_plt_readonly               1
 #define elf_backend_got_header_size            12
 #define elf_backend_rela_normal                1
+#define elf_backend_dtrel_excludes_plt         1
 
 #define elf_backend_adjust_dynamic_symbol       microblaze_elf_adjust_dynamic_symbol
 #define elf_backend_create_dynamic_sections     microblaze_elf_create_dynamic_sections
index 4438ee83c2ac62cb80e25be34177d1b5e6a46a3d..d398810ce6342b92895c5cd1a1a8202ccd277af7 100644 (file)
@@ -2617,6 +2617,8 @@ mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
 #define elf_backend_default_use_rela_p         1
 #undef elf_backend_got_header_size
 #define elf_backend_got_header_size            (4 * 3)
+#undef elf_backend_dtrel_excludes_plt
+#define elf_backend_dtrel_excludes_plt         1
 
 #undef elf_backend_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_symbol \
index 8a06da5cc95205af99b395b5dbc99cb286fc6793..1722e1f83e11d16e7ba2994c620fd0766d2ccc8c 100644 (file)
@@ -5685,24 +5685,6 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* My reading of the SVR4 ABI indicates that the
-                procedure linkage table relocs (DT_JMPREL) should be
-                included in the overall relocs (DT_RELA).  This is
-                what Solaris does.  However, UnixWare can not handle
-                that case.  Therefore, we override the DT_RELASZ entry
-                here to make it not include the JMPREL relocs.  Since
-                the linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             if (htab->root.srelplt != NULL)
-               {
-                 s = htab->root.srelplt;
-                 dyn.d_un.d_val -= s->size;
-               }
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
        }
 
@@ -15694,6 +15676,7 @@ nds32_elf_ex9_itb_base (struct bfd_link_info *link_info)
 #define elf_backend_may_use_rel_p              1
 #define elf_backend_default_use_rela_p         1
 #define elf_backend_may_use_rela_p             1
+#define elf_backend_dtrel_excludes_plt         1
 
 #include "elf32-target.h"
 
index ad8eb45342c0065ecdaa238d98594988537b5484..c63932fd1b02049556ab726fe3207bbb7081deb0 100644 (file)
@@ -5366,20 +5366,6 @@ nios2_elf32_finish_dynamic_sections (bfd *output_bfd,
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
-           case DT_RELASZ:
-             /* The procedure linkage table relocs (DT_JMPREL) should
-                not be included in the overall relocs (DT_RELA).
-                Therefore, we override the DT_RELASZ entry here to
-                make it not include the JMPREL relocs.  Since the
-                linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             s = htab->root.srelplt;
-             if (s != NULL)
-               dyn.d_un.d_val -= s->size;
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
-
            case DT_NIOS2_GP:
              s = htab->root.sgotplt;
              dyn.d_un.d_ptr
@@ -6278,6 +6264,7 @@ const struct bfd_elf_special_section elf32_nios2_special_sections[] =
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_got_plt       1
 #define elf_backend_rela_normal                1
+#define elf_backend_dtrel_excludes_plt 1
 
 #define elf_backend_relocate_section     nios2_elf32_relocate_section
 #define elf_backend_section_flags        nios2_elf32_section_flags
index 3ec16aab3d63fd68ff8d8e029b67ce3500e7fed1..23de76221b91f9e6aef088127f70735ae7fd8efc 100644 (file)
@@ -1729,23 +1729,6 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
               s = htab->root.srelplt;
               dyn.d_un.d_val = s->size;
               break;
-
-            case DT_RELASZ:
-              /* My reading of the SVR4 ABI indicates that the
-                 procedure linkage table relocs (DT_JMPREL) should be
-                 included in the overall relocs (DT_RELA).  This is
-                 what Solaris does.  However, UnixWare can not handle
-                 that case.  Therefore, we override the DT_RELASZ entry
-                 here to make it not include the JMPREL relocs.  Since
-                 the linker script arranges for .rela.plt to follow all
-                 other relocation sections, we don't have to worry
-                 about changing the DT_RELA entry.  */
-              if (htab->root.srelplt != NULL)
-                {
-                  s = htab->root.srelplt;
-                  dyn.d_un.d_val -= s->size;
-                }
-              break;
             }
           bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
         }
@@ -2790,6 +2773,8 @@ elf32_or1k_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 #define elf_backend_want_got_plt                1
 #define elf_backend_want_plt_sym                0
 #define elf_backend_got_header_size             12
+#define elf_backend_dtrel_excludes_plt         1
+
 #define bfd_elf32_bfd_link_hash_table_create    or1k_elf_link_hash_table_create
 #define elf_backend_copy_indirect_symbol        or1k_elf_copy_indirect_symbol
 #define elf_backend_create_dynamic_sections     or1k_elf_create_dynamic_sections
index 35a505c4bc56cd9946c6d5f49fbd89189c44e602..323cc0f482e1db77f10ab202587a867f8f49f0e4 100644 (file)
@@ -10468,15 +10468,6 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
              dyn.d_un.d_ptr = got;
              break;
 
-           case DT_RELASZ:
-             if (htab->is_vxworks)
-               {
-                 if (htab->elf.srelplt)
-                   dyn.d_un.d_ptr -= htab->elf.srelplt->size;
-                 break;
-               }
-             continue;
-
            default:
              if (htab->is_vxworks
                  && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn))
@@ -11054,6 +11045,8 @@ ppc_elf_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
 #define elf_backend_plt_readonly               1
 #undef elf_backend_got_header_size
 #define elf_backend_got_header_size            12
+#undef elf_backend_dtrel_excludes_plt
+#define elf_backend_dtrel_excludes_plt         1
 
 #undef bfd_elf32_get_synthetic_symtab
 
index c9a9fc384f44dbb3447447e755c99121493cc048..5da1d088f573f6409c14ce461d41955a2cd3e081 100644 (file)
@@ -6974,24 +6974,6 @@ sh_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* My reading of the SVR4 ABI indicates that the
-                procedure linkage table relocs (DT_JMPREL) should be
-                included in the overall relocs (DT_RELA).  This is
-                what Solaris does.  However, UnixWare can not handle
-                that case.  Therefore, we override the DT_RELASZ entry
-                here to make it not include the JMPREL relocs.  Since
-                the linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             if (htab->root.srelplt != NULL)
-               {
-                 s = htab->root.srelplt->output_section;
-                 dyn.d_un.d_val -= s->size;
-               }
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
        }
 
@@ -7316,6 +7298,7 @@ sh_elf_encode_eh_address (bfd *abfd,
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    12
+#define elf_backend_dtrel_excludes_plt 1
 
 #if !defined INCLUDE_SHMEDIA && !defined SH_TARGET_ALREADY_DEFINED
 
index d93c93eee2afe25ba9cf0460d98eaaab990e7ac2..528cba29eac65339407dd04bd9e3f0e4e7158f3c 100644 (file)
@@ -332,6 +332,8 @@ elf32_sparc_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
 #define elf_backend_plt_readonly               1
 #undef  elf_backend_got_header_size
 #define elf_backend_got_header_size            12
+#undef  elf_backend_dtrel_excludes_plt
+#define elf_backend_dtrel_excludes_plt         1
 #undef  elf_backend_add_symbol_hook
 #define elf_backend_add_symbol_hook \
   elf_vxworks_add_symbol_hook
index d7c6137554ecd5d238f6bc17f60f5c41179d9a00..8912bf0c855e5d38b704dd878540c4ea06efb86e 100644 (file)
@@ -1905,20 +1905,6 @@ elf_vax_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* The procedure linkage table relocs (DT_JMPREL) should
-                not be included in the overall relocs (DT_RELA).
-                Therefore, we override the DT_RELASZ entry here to
-                make it not include the JMPREL relocs.  Since the
-                linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             s = elf_hash_table (info)->srelplt;
-             if (s != NULL)
-               dyn.d_un.d_val -= s->size;
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
        }
 
@@ -2026,5 +2012,6 @@ elf_vax_plt_sym_val (bfd_vma i, const asection *plt,
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    16
 #define elf_backend_rela_normal                1
+#define elf_backend_dtrel_excludes_plt 1
 
 #include "elf32-target.h"
index c4a00642834ba57b710c7825a85e7054d891f26f..5963458a810ef49f4f048e75a8f2a794c4cb1abe 100644 (file)
@@ -3429,17 +3429,6 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd,
        case DT_PLTRELSZ:
          dyn.d_un.d_val = htab->elf.srelplt->size;
          break;
-
-       case DT_RELASZ:
-         /* Adjust RELASZ to not include JMPREL.  This matches what
-            glibc expects and what is done for several other ELF
-            targets (e.g., i386, alpha), but the "correct" behavior
-            seems to be unresolved.  Since the linker script arranges
-            for .rela.plt to follow all other relocation sections, we
-            don't have to worry about changing the DT_RELA entry.  */
-         if (htab->elf.srelplt)
-           dyn.d_un.d_val -= htab->elf.srelplt->size;
-         break;
        }
 
       bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -11341,6 +11330,7 @@ static const struct bfd_elf_special_section elf_xtensa_special_sections[] =
 #define elf_backend_got_header_size    4
 #define elf_backend_want_dynbss                0
 #define elf_backend_want_got_plt       1
+#define elf_backend_dtrel_excludes_plt 1
 
 #define elf_info_to_howto                   elf_xtensa_info_to_howto_rela
 
index 54205bc930e63acec82da1a83677d8620d5b5804..44f2cfe0048fb4d4651bcb7e96cdbb7c273e7da6 100644 (file)
@@ -5057,16 +5057,6 @@ elf64_alpha_finish_dynamic_sections (bfd *output_bfd,
              dyn.d_un.d_ptr = srelaplt ? (srelaplt->output_section->vma
                                           + srelaplt->output_offset) : 0;
              break;
-
-           case DT_RELASZ:
-             /* My interpretation of the TIS v1.1 ELF document indicates
-                that RELASZ should not include JMPREL.  This is not what
-                the rest of the BFD does.  It is, however, what the
-                glibc ld.so wants.  Do this fixup here until we found
-                out who is right.  */
-             if (srelaplt)
-               dyn.d_un.d_val -= srelaplt->size;
-             break;
            }
 
          bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -5596,6 +5586,7 @@ static const struct elf_size_info alpha_elf_size_info =
 #define elf_backend_plt_readonly 0
 #define elf_backend_want_plt_sym 1
 #define elf_backend_got_header_size 0
+#define elf_backend_dtrel_excludes_plt 1
 
 #include "elf64-target.h"
 \f
index 41343e5b85234fd2a17a18ecae0ef38b41c92d1a..d011303555187db801c6d95bdef7b60877196fa4 100644 (file)
@@ -75,6 +75,7 @@ static bfd_vma opd_entry_value
 #define elf_backend_can_gc_sections 1
 #define elf_backend_can_refcount 1
 #define elf_backend_rela_normal 1
+#define elf_backend_dtrel_excludes_plt 1
 #define elf_backend_default_execstack 0
 
 #define bfd_elf64_mkobject                   ppc64_elf_mkobject
@@ -15564,27 +15565,6 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd,
            case DT_PLTRELSZ:
              dyn.d_un.d_val = htab->elf.srelplt->size;
              break;
-
-           case DT_RELASZ:
-             /* Don't count procedure linkage table relocs in the
-                overall reloc count.  */
-             s = htab->elf.srelplt;
-             if (s == NULL)
-               continue;
-             dyn.d_un.d_val -= s->size;
-             break;
-
-           case DT_RELA:
-             /* We may not be using the standard ELF linker script.
-                If .rela.plt is the first .rela section, we adjust
-                DT_RELA to not include it.  */
-             s = htab->elf.srelplt;
-             if (s == NULL)
-               continue;
-             if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset)
-               continue;
-             dyn.d_un.d_ptr += s->size;
-             break;
            }
 
          bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
index 352fd2973dc8d89cbb0098ed2dab1cd0edae562e..4739881ed70392b8b7b5cc88f65bb2642b661a3d 100644 (file)
@@ -3792,22 +3792,6 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd,
              dyn.d_un.d_val = s->size;
              bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* My reading of the SVR4 ABI indicates that the
-                procedure linkage table relocs (DT_JMPREL) should be
-                included in the overall relocs (DT_RELA).  This is
-                what Solaris does.  However, UnixWare can not handle
-                that case.  Therefore, we override the DT_RELASZ entry
-                here to make it not include the JMPREL relocs.  Since
-                the linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             s = elf_hash_table (info)->srelplt;
-             if (s != NULL)
-               dyn.d_un.d_val -= s->size;
-             bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
        }
 
@@ -3960,6 +3944,7 @@ static const struct bfd_elf_special_section sh64_elf64_special_sections[]=
 #define elf_backend_plt_readonly       1
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    24
+#define elf_backend_dtrel_excludes_plt 1
 
 #include "elf64-target.h"
 
index 05a4776c5a2c91bae5434a1c4f44a7c2e10c1d7f..2e21899f0e5c91d96284836ec22296fd8754e159 100644 (file)
@@ -6214,21 +6214,6 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
              dyn.d_un.d_val = s->size;
              break;
 
-           case DT_RELASZ:
-             /* The procedure linkage table relocs (DT_JMPREL) should
-                not be included in the overall relocs (DT_RELA).
-                Therefore, we override the DT_RELASZ entry here to
-                make it not include the JMPREL relocs.  Since the
-                linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             if (htab->elf.srelplt != NULL)
-               {
-                 s = htab->elf.srelplt->output_section;
-                 dyn.d_un.d_val -= s->size;
-               }
-             break;
-
            case DT_TLSDESC_PLT:
              s = htab->elf.splt;
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
@@ -6758,6 +6743,7 @@ static const struct bfd_elf_special_section
 #define elf_backend_plt_alignment           4
 #define elf_backend_extern_protected_data   1
 #define elf_backend_caches_rawsize         1
+#define elf_backend_dtrel_excludes_plt     1
 
 #define elf_info_to_howto                  elf_x86_64_info_to_howto
 
index daf4b82e9479d4e2af612493a2ceb8b916286ed3..ddbe80100d747a00949b7dfb452409d939a778d3 100644 (file)
@@ -11237,15 +11237,16 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
   asection *attr_section = NULL;
   bfd_vma attr_size = 0;
   const char *std_attrs_section;
+  struct elf_link_hash_table *htab = elf_hash_table (info);
 
-  if (! is_elf_hash_table (info->hash))
+  if (!is_elf_hash_table (htab))
     return FALSE;
 
   if (bfd_link_pic (info))
     abfd->flags |= DYNAMIC;
 
-  dynamic = elf_hash_table (info)->dynamic_sections_created;
-  dynobj = elf_hash_table (info)->dynobj;
+  dynamic = htab->dynamic_sections_created;
+  dynobj = htab->dynobj;
 
   emit_relocs = (bfd_link_relocatable (info)
                 || info->emitrelocations);
@@ -11462,8 +11463,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
     }
 
   if (! bfd_link_relocatable (info) && merged)
-    elf_link_hash_traverse (elf_hash_table (info),
-                           _bfd_elf_link_sec_merge_syms, abfd);
+    elf_link_hash_traverse (htab, _bfd_elf_link_sec_merge_syms, abfd);
 
   /* Figure out the file positions for everything but the symbol table
      and the relocs.  We set symcount to force assign_section_numbers
@@ -11526,11 +11526,10 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
 
   if (max_sym_count < 20)
     max_sym_count = 20;
-  elf_hash_table (info)->strtabsize = max_sym_count;
+  htab->strtabsize = max_sym_count;
   amt = max_sym_count * sizeof (struct elf_sym_strtab);
-  elf_hash_table (info)->strtab
-    = (struct elf_sym_strtab *) bfd_malloc (amt);
-  if (elf_hash_table (info)->strtab == NULL)
+  htab->strtab = (struct elf_sym_strtab *) bfd_malloc (amt);
+  if (htab->strtab == NULL)
     goto error_return;
   /* The real buffer will be allocated in elf_link_swap_symbols_out.  */
   flinfo.symshndxbuf
@@ -11642,12 +11641,12 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
        goto error_return;
     }
 
-  if (elf_hash_table (info)->tls_sec)
+  if (htab->tls_sec)
     {
       bfd_vma base, end = 0;
       asection *sec;
 
-      for (sec = elf_hash_table (info)->tls_sec;
+      for (sec = htab->tls_sec;
           sec && (sec->flags & SEC_THREAD_LOCAL);
           sec = sec->next)
        {
@@ -11663,13 +11662,12 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
            }
          end = sec->vma + size;
        }
-      base = elf_hash_table (info)->tls_sec->vma;
+      base = htab->tls_sec->vma;
       /* Only align end of TLS section if static TLS doesn't have special
         alignment requirements.  */
       if (bed->static_tls_alignment == 1)
-       end = align_power (end,
-                          elf_hash_table (info)->tls_sec->alignment_power);
-      elf_hash_table (info)->tls_size = end - base;
+       end = align_power (end, htab->tls_sec->alignment_power);
+      htab->tls_size = end - base;
     }
 
   /* Reorder SHF_LINK_ORDER sections.  */
@@ -11817,20 +11815,18 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
   symtab_hdr->sh_info = bfd_get_symcount (abfd);
 
   if (dynamic
-      && elf_hash_table (info)->dynsym != NULL
-      && (elf_hash_table (info)->dynsym->output_section
-         != bfd_abs_section_ptr))
+      && htab->dynsym != NULL
+      && htab->dynsym->output_section != bfd_abs_section_ptr)
     {
       Elf_Internal_Sym sym;
-      bfd_byte *dynsym = elf_hash_table (info)->dynsym->contents;
+      bfd_byte *dynsym = htab->dynsym->contents;
 
-      o = elf_hash_table (info)->dynsym->output_section;
-      elf_section_data (o)->this_hdr.sh_info
-       = elf_hash_table (info)->local_dynsymcount + 1;
+      o = htab->dynsym->output_section;
+      elf_section_data (o)->this_hdr.sh_info = htab->local_dynsymcount + 1;
 
       /* Write out the section symbols for the output sections.  */
       if (bfd_link_pic (info)
-         || elf_hash_table (info)->is_relocatable_executable)
+         || htab->is_relocatable_executable)
        {
          asection *s;
 
@@ -11861,10 +11857,10 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
        }
 
       /* Write out the local dynsyms.  */
-      if (elf_hash_table (info)->dynlocal)
+      if (htab->dynlocal)
        {
          struct elf_link_local_dynamic_entry *e;
-         for (e = elf_hash_table (info)->dynlocal; e ; e = e->next)
+         for (e = htab->dynlocal; e ; e = e->next)
            {
              asection *s;
              bfd_byte *dest;
@@ -12049,8 +12045,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
              {
                struct elf_link_hash_entry *h;
 
-               h = elf_link_hash_lookup (elf_hash_table (info), name,
-                                         FALSE, FALSE, TRUE);
+               h = elf_link_hash_lookup (htab, name, FALSE, FALSE, TRUE);
                if (h != NULL
                    && (h->root.type == bfd_link_hash_defined
                        || h->root.type == bfd_link_hash_defweak))
@@ -12172,6 +12167,18 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
                        }
                    }
                }
+             if (bed->dtrel_excludes_plt && htab->srelplt != NULL)
+               {
+                 /* Don't count procedure linkage table relocs in the
+                    overall reloc count.  */
+                 if (dyn.d_tag == DT_RELSZ || dyn.d_tag == DT_RELASZ)
+                   dyn.d_un.d_val -= htab->srelplt->size;
+                 /* If .rela.plt is the first .rela section, exclude
+                    it from DT_RELA.  */
+                 else if (dyn.d_un.d_ptr == (htab->srelplt->output_section->vma
+                                             + htab->srelplt->output_offset))
+                   dyn.d_un.d_ptr += htab->srelplt->size;
+               }
              break;
            }
          bed->s->swap_dyn_out (dynobj, &dyn, dyncon);
@@ -12224,9 +12231,9 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
                 created by _bfd_elf_link_create_dynamic_sections.  */
              continue;
            }
-         if (elf_hash_table (info)->stab_info.stabstr == o)
+         if (htab->stab_info.stabstr == o)
            continue;
-         if (elf_hash_table (info)->eh_info.hdr_sec == o)
+         if (htab->eh_info.hdr_sec == o)
            continue;
          if (strcmp (o->name, ".dynstr") != 0)
            {
@@ -12245,8 +12252,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
 
              off = elf_section_data (o->output_section)->this_hdr.sh_offset;
              if (bfd_seek (abfd, off, SEEK_SET) != 0
-                 || ! _bfd_elf_strtab_emit (abfd,
-                                            elf_hash_table (info)->dynstr))
+                 || !_bfd_elf_strtab_emit (abfd, htab->dynstr))
                goto error_return;
            }
        }
@@ -12262,9 +12268,9 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
     }
 
   /* If we have optimized stabs strings, output them.  */
-  if (elf_hash_table (info)->stab_info.stabstr != NULL)
+  if (htab->stab_info.stabstr != NULL)
     {
-      if (! _bfd_write_stab_strings (abfd, &elf_hash_table (info)->stab_info))
+      if (!_bfd_write_stab_strings (abfd, &htab->stab_info))
        goto error_return;
     }
 
index 0b5e655e3cdb5fda277bf19d2297802dfaecae7e..99b2a04f153a688855d7c34c4a0a562a37e7e5d6 100644 (file)
@@ -9066,21 +9066,6 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd,
              dyn.d_un.d_val = s->size;
              break;
 
-           case DT_RELASZ:
-             /* The procedure linkage table relocs (DT_JMPREL) should
-                not be included in the overall relocs (DT_RELA).
-                Therefore, we override the DT_RELASZ entry here to
-                make it not include the JMPREL relocs.  Since the
-                linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             if (htab->root.srelplt != NULL)
-               {
-                 s = htab->root.srelplt;
-                 dyn.d_un.d_val -= s->size;
-               }
-             break;
-
            case DT_TLSDESC_PLT:
              s = htab->root.splt;
              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
@@ -9410,6 +9395,7 @@ const struct elf_size_info elfNN_aarch64_size_info =
 #define elf_backend_may_use_rela_p     1
 #define elf_backend_default_use_rela_p 1
 #define elf_backend_rela_normal        1
+#define elf_backend_dtrel_excludes_plt 1
 #define elf_backend_got_header_size (GOT_ENTRY_SIZE * 3)
 #define elf_backend_default_execstack  0
 #define elf_backend_extern_protected_data 1
index ef6344728b81a113b337a233ab0c632ee8f999ce..32f94111db7322d4347c4db6373846f49aed24a5 100644 (file)
@@ -4663,13 +4663,6 @@ elfNN_ia64_finish_dynamic_sections (bfd *abfd,
              dyn.d_un.d_ptr = (sgotplt->output_section->vma
                                + sgotplt->output_offset);
              break;
-
-           case DT_RELASZ:
-             /* Do not have RELASZ include JMPREL.  This makes things
-                easier on ld.so.  This is not what the rest of BFD set up.  */
-             dyn.d_un.d_val -= (ia64_info->minplt_entries
-                                * sizeof (ElfNN_External_Rela));
-             break;
            }
 
          bfd_elfNN_swap_dyn_out (abfd, &dyn, dyncon);
@@ -5074,6 +5067,7 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
 #define elf_backend_fixup_symbol       _bfd_elf_link_hash_fixup_symbol
 #define elf_backend_reloc_type_class   elfNN_ia64_reloc_type_class
 #define elf_backend_rela_normal                1
+#define elf_backend_dtrel_excludes_plt 1
 #define elf_backend_special_sections   elfNN_ia64_special_sections
 #define elf_backend_default_execstack  0
 
index 029ea1c80d25d0eeedd1ba82c80169a9506a1a5a..0e56ffa361d0ef195a43610b9b89da116977b24c 100644 (file)
@@ -11714,13 +11714,6 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
              dyn.d_un.d_ptr = s->vma;
              break;
 
-           case DT_RELASZ:
-             BFD_ASSERT (htab->is_vxworks);
-             /* The count does not include the JUMP_SLOT relocations.  */
-             if (htab->root.srelplt)
-               dyn.d_un.d_val -= htab->root.srelplt->size;
-             break;
-
            case DT_PLTREL:
              BFD_ASSERT (htab->use_plts_and_copy_relocs);
              if (htab->is_vxworks)
index 916d33bc23ac7f8f396ee9431adb77172f616dd6..056a4b7550759183e9aa3ac763ef65a18c956844 100644 (file)
@@ -4582,17 +4582,7 @@ sparc_finish_dyn (bfd *output_bfd, struct bfd_link_info *info,
 
       bed->s->swap_dyn_in (dynobj, dyncon, &dyn);
 
-      if (htab->is_vxworks && dyn.d_tag == DT_RELASZ)
-       {
-         /* On VxWorks, DT_RELASZ should not include the relocations
-            in .rela.plt.  */
-         if (htab->elf.srelplt)
-           {
-             dyn.d_un.d_val -= htab->elf.srelplt->size;
-             bed->s->swap_dyn_out (output_bfd, &dyn, dyncon);
-           }
-       }
-      else if (htab->is_vxworks && dyn.d_tag == DT_PLTGOT)
+      if (htab->is_vxworks && dyn.d_tag == DT_PLTGOT)
        {
          /* On VxWorks, DT_PLTGOT should point to the start of the GOT,
             not to the start of the PLT.  */
index c6a9466904c78c9d2a84f1eae330eb01af4e45cc..5ff39dd4474f3d2bc7a4dbf3fa04ba3a51529fed 100644 (file)
 #define elf_backend_rela_normal 0
 #endif
 
+#ifndef elf_backend_dtrel_excludes_plt
+#define elf_backend_dtrel_excludes_plt 0
+#endif
+
 #ifndef elf_backend_plt_sym_val
 #define elf_backend_plt_sym_val NULL
 #endif
@@ -835,6 +839,7 @@ static struct elf_backend_data elfNN_bed =
   elf_backend_default_use_rela_p,
   elf_backend_rela_plts_and_copies_p,
   elf_backend_rela_normal,
+  elf_backend_dtrel_excludes_plt,
   elf_backend_sign_extend_vma,
   elf_backend_want_got_plt,
   elf_backend_plt_readonly,