aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-06-24 04:00:19 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-06-24 04:00:31 -0700
commitc679ec98a1296d8da3b5920a9058ba14b47ca3a4 (patch)
tree1669a20b5d12c0e4cb2561dd58f25b06f5b71fbb /bfd
parent5376d47f66d0e4e07b3d42cb62ad07327cad4292 (diff)
downloadgdb-c679ec98a1296d8da3b5920a9058ba14b47ca3a4.zip
gdb-c679ec98a1296d8da3b5920a9058ba14b47ca3a4.tar.gz
gdb-c679ec98a1296d8da3b5920a9058ba14b47ca3a4.tar.bz2
cris: Don't generate unnecessary dynamic tags
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-cris.c (elf_cris_size_dynamic_sections): Call _bfd_elf_add_dynamic_tags. ld/ PR ld/26083 * testsuite/ld-cris/libdso-15b.d: Updated. * testsuite/ld-cris/libdso-1c.d: Likewise. * testsuite/ld-cris/libdso-1d.d: Likewise. * testsuite/ld-cris/libdso-15c.d: New file.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf32-cris.c49
2 files changed, 8 insertions, 47 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9c202b2..f0d7414 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2020-06-24 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/26083
+ * elf32-cris.c (elf_cris_size_dynamic_sections): Call
+ _bfd_elf_add_dynamic_tags.
+
2020-06-24 Alan Modra <amodra@gmail.com>
* vms-alpha.c (_bfd_vms_slurp_etir <ETIR__C_OPR_ASH>): Implement
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index bee7108..4360b54 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -3513,7 +3513,6 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
struct elf_cris_link_hash_table * htab;
bfd *dynobj;
asection *s;
- bfd_boolean plt;
bfd_boolean relocs;
htab = elf_cris_hash_table (info);
@@ -3569,7 +3568,6 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
/* The check_relocs and adjust_dynamic_symbol entry points have
determined the sizes of the various dynamic sections. Allocate
memory for them. */
- plt = FALSE;
relocs = FALSE;
for (s = dynobj->sections; s != NULL; s = s->next)
{
@@ -3584,8 +3582,7 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (strcmp (name, ".plt") == 0)
{
- /* Remember whether there is a PLT. */
- plt = s->size != 0;
+ ;
}
else if (strcmp (name, ".got.plt") == 0)
{
@@ -3650,49 +3647,7 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
return FALSE;
}
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Add some entries to the .dynamic section. We fill in the
- values later, in elf_cris_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_pic (info))
- {
- if (!add_dynamic_entry (DT_DEBUG, 0))
- return FALSE;
- }
-
- if (plt)
- {
- 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 ((info->flags & DF_TEXTREL) != 0)
- {
- if (!add_dynamic_entry (DT_TEXTREL, 0))
- return FALSE;
- info->flags |= DF_TEXTREL;
- }
- }
-#undef add_dynamic_entry
-
- return TRUE;
+ return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs);
}
/* This function is called via elf_cris_link_hash_traverse if we are