]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
csky: Don't generate unnecessary dynamic tags
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 24 Jun 2020 13:14:18 +0000 (06:14 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 24 Jun 2020 13:14:28 +0000 (06:14 -0700)
Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there
are relocation entries for PLT.  Don't generate them if there are no
relocation entries for PLT.

bfd/

PR ld/26083
* elf32-csky.c (csky_elf_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.

ld/

PR ld/26083
* testsuite/ld-csky/tls-ie-v1.d: Updated.
* testsuite/ld-csky/tls-ie.d: Likewise.

bfd/ChangeLog
bfd/elf32-csky.c
ld/ChangeLog
ld/testsuite/ld-csky/tls-ie-v1.d
ld/testsuite/ld-csky/tls-ie.d

index f0d7414dc73bc85dec8455ca8877acd1ed15fa30..943139ebf4f786d618f0447688537e3a2c7db732 100644 (file)
@@ -1,3 +1,9 @@
+2020-06-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/26083
+       * elf32-csky.c (csky_elf_size_dynamic_sections): Call
+       _bfd_elf_add_dynamic_tags.
+
 2020-06-24  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/26083
index 43828beed03296c5847729a45a2f531a60d612ed..ea58e14c004b6075e4d4ca11395dfc24fde07774 100644 (file)
@@ -2093,49 +2093,8 @@ csky_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
     }
 
   if (htab->elf.dynamic_sections_created)
-    {
-      /* Add some entries to the .dynamic section.  We fill in the
-        values later, in csky_elf_finish_dynamic_sections, but we
-        must add the entries now so that we get the correct size for
-        the .dynamic section.  The DT_DEBUG entry is filled in by the
-        dynamic linker and used by the debugger.  */
-#define add_dynamic_entry(TAG, VAL) \
-  _bfd_elf_add_dynamic_entry (info, TAG, VAL)
-
-      if (bfd_link_executable (info) && !add_dynamic_entry (DT_DEBUG, 0))
-       return FALSE;
-
-      if (htab->elf.sgot->size != 0 || htab->elf.splt->size)
-       {
-         if (!add_dynamic_entry (DT_PLTGOT, 0)
-             || !add_dynamic_entry (DT_PLTRELSZ, 0)
-             || !add_dynamic_entry (DT_PLTREL, DT_RELA)
-             || !add_dynamic_entry (DT_JMPREL, 0))
-           return FALSE;
-       }
-
-      if (relocs)
-       {
-         if (!add_dynamic_entry (DT_RELA, 0)
-             || !add_dynamic_entry (DT_RELASZ, 0)
-             || !add_dynamic_entry (DT_RELAENT,
-                                    sizeof (Elf32_External_Rela)))
-           return FALSE;
-
-         /* If any dynamic relocs apply to a read-only section,
-            then we need a DT_TEXTREL entry.  */
-         if ((info->flags & DF_TEXTREL) == 0)
-           elf_link_hash_traverse (&htab->elf,
-                                   _bfd_elf_maybe_set_textrel, info);
-
-         if ((info->flags & DF_TEXTREL) != 0
-             && !add_dynamic_entry (DT_TEXTREL, 0))
-           return FALSE;
-       }
-    }
-#undef add_dynamic_entry
-
-  return TRUE;
+    htab->elf.dt_pltgot_required = htab->elf.sgot->size != 0;
+  return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs);
 }
 
 /* Finish up dynamic symbol handling.  We set the contents of various
index 47500a11b86c29698b9828c9fc14d3ffb9557bf4..bf171da0fa9014b67519d8b48a3a8996cc87118b 100644 (file)
@@ -1,3 +1,9 @@
+2020-06-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/26083
+       * testsuite/ld-csky/tls-ie-v1.d: Updated.
+       * testsuite/ld-csky/tls-ie.d: Likewise.
+
 2020-06-24  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/26083
index 1f5f446e780288d14b6be4edeef753f82eb3cf6a..af1858c3b81a0dc4a911689eede19a4ec0eeb4b8 100644 (file)
@@ -4,7 +4,7 @@
 #ld: -shared --hash-style=sysv
 #readelf: -d -r
 
-Dynamic section at offset 0x[0-9a-f]+ contains 13 entries:
+Dynamic section at offset 0x[0-9a-f]+ contains 10 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       .*
  0x00000005 \(STRTAB\)                     .*
@@ -12,9 +12,6 @@ Dynamic section at offset 0x[0-9a-f]+ contains 13 entries:
  0x0000000a \(STRSZ\)                      .* \(bytes\)
  0x0000000b \(SYMENT\)                     .* \(bytes\)
  0x00000003 \(PLTGOT\)                     0x[0-9a-f]+
- 0x00000002 \(PLTRELSZ\)                   0 \(bytes\)
- 0x00000014 \(PLTREL\)                     RELA
- 0x00000017 \(JMPREL\)                     0x[0-9a-f]+
  0x00000007 \(RELA\)                       0x[0-9a-f]+
  0x00000008 \(RELASZ\)                     12 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)
index 45a8a1184a4e9363960cdd5d1bb25e0596a8efb0..38c2a911def1cf06ea3b320ad656015802261ce3 100644 (file)
@@ -3,7 +3,7 @@
 #ld: -shared --hash-style=sysv
 #readelf: -d -r
 
-Dynamic section at offset 0x[0-9a-f]+ contains 13 entries:
+Dynamic section at offset 0x[0-9a-f]+ contains 10 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       .*
  0x00000005 \(STRTAB\)                     .*
@@ -11,9 +11,6 @@ Dynamic section at offset 0x[0-9a-f]+ contains 13 entries:
  0x0000000a \(STRSZ\)                      .* \(bytes\)
  0x0000000b \(SYMENT\)                     .* \(bytes\)
  0x00000003 \(PLTGOT\)                     0x[0-9a-f]+
- 0x00000002 \(PLTRELSZ\)                   0 \(bytes\)
- 0x00000014 \(PLTREL\)                     RELA
- 0x00000017 \(JMPREL\)                     0x[0-9a-f]+
  0x00000007 \(RELA\)                       0x[0-9a-f]+
  0x00000008 \(RELASZ\)                     12 \(bytes\)
  0x00000009 \(RELAENT\)                    12 \(bytes\)