ppc64: Call _bfd_elf_add_dynamic_tags

Message ID 20200623121525.213029-1-hjl.tools@gmail.com
State New
Headers show
Series
  • ppc64: Call _bfd_elf_add_dynamic_tags
Related show

Commit Message

David Faust via Binutils June 23, 2020, 12:15 p.m.
* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Call
	_bfd_elf_add_dynamic_tags.
---
 bfd/elf64-ppc.c | 33 +++------------------------------
 1 file changed, 3 insertions(+), 30 deletions(-)

-- 
2.26.2

Comments

David Faust via Binutils June 25, 2020, 8:02 a.m. | #1
On Tue, Jun 23, 2020 at 05:15:25AM -0700, H.J. Lu wrote:
> 	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Call

> 	_bfd_elf_add_dynamic_tags.


No, the _bfd_elf_add_dynamic_tags warning about ifuncs is wrong for
ppc64.  ifunc_resolvers may be set later than size_dynamic_sections.

-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 8d710848ba..7fd9b29e2a 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -10195,19 +10195,12 @@  ppc64_elf_size_dynamic_sections (bfd *output_bfd,
 #define add_dynamic_entry(TAG, VAL) \
   _bfd_elf_add_dynamic_entry (info, TAG, VAL)
 
-      if (bfd_link_executable (info))
-	{
-	  if (!add_dynamic_entry (DT_DEBUG, 0))
-	    return FALSE;
-	}
+      if (!_bfd_elf_add_dynamic_tags (output_bfd, info, relocs))
+	return FALSE;
 
       if (htab->elf.splt != NULL && htab->elf.splt->size != 0)
 	{
-	  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)
-	      || !add_dynamic_entry (DT_PPC64_GLINK, 0))
+	  if (!add_dynamic_entry (DT_PPC64_GLINK, 0))
 	    return FALSE;
 	}
 
@@ -10228,26 +10221,6 @@  ppc64_elf_size_dynamic_sections (bfd *output_bfd,
 	  if (!add_dynamic_entry (DT_PPC64_OPT, tls_opt ? PPC64_OPT_TLS : 0))
 	    return FALSE;
 	}
-
-      if (relocs)
-	{
-	  if (!add_dynamic_entry (DT_RELA, 0)
-	      || !add_dynamic_entry (DT_RELASZ, 0)
-	      || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_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)
-	    {
-	      if (!add_dynamic_entry (DT_TEXTREL, 0))
-		return FALSE;
-	    }
-	}
     }
 #undef add_dynamic_entry