This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] [ARC] Corrected conditions for dynamic sections creation.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e3d1d4088ad3b4d0fed39df62ad295ed60707807

commit e3d1d4088ad3b4d0fed39df62ad295ed60707807
Author: Cupertino Miranda <cmiranda@synopsys.com>
Date:   Tue May 23 13:36:33 2017 +0200

    [ARC] Corrected conditions for dynamic sections creation.
    
    Fixed conditions to create the dynamic sections.
    Previously there would be times where the dynamic sections would not be created
    although they were actually required for linking to work.
    
    Issue found through OpenADK build, more precisely the ublicb testsuite package.
    
    bfd/ChangeLog:
    
        Cupertino Miranda  <cmiranda@synopsys.com>
    
    	elf32-arc.c (elf_arc_check_relocs): Fixed conditions to generate
    	dynamic sections.

Diff:
---
 bfd/ChangeLog   |  5 +++++
 bfd/elf32-arc.c | 20 +++++++++++---------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 6c4baf8..e99ca85 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
 2017-06-08  Cupertino Miranda  <cmiranda@synopsys.com>
 
+	* elf32-arc.c (elf_arc_check_relocs): Fixed conditions to generate
+	dynamic sections.
+
+2017-06-08  Cupertino Miranda  <cmiranda@synopsys.com>
+
 	* elf32-arc.c (elf_arc_size_dynamic_sections): Changed condition to
 	require TEXTREL.
 
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 03c00c3..6903ad7 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1904,10 +1904,14 @@ elf_arc_check_relocs (bfd *			 abfd,
   const Elf_Internal_Rela *	rel_end;
   bfd *				dynobj;
   asection *			sreloc = NULL;
+  struct elf_link_hash_table *	htab = elf_hash_table (info);
 
   if (bfd_link_relocatable (info))
     return TRUE;
 
+  if (htab->dynobj == NULL)
+    htab->dynobj = abfd;
+
   dynobj = (elf_hash_table (info))->dynobj;
   symtab_hdr = &((elf_tdata (abfd))->symtab_hdr);
   sym_hashes = elf_sym_hashes (abfd);
@@ -1929,15 +1933,6 @@ elf_arc_check_relocs (bfd *			 abfd,
 	}
       howto = arc_elf_howto (r_type);
 
-      if (dynobj == NULL
-	  && (is_reloc_for_GOT (howto)
-	      || is_reloc_for_TLS (howto)))
-	{
-	  dynobj = elf_hash_table (info)->dynobj = abfd;
-	  if (! _bfd_elf_create_got_section (abfd, info))
-	    return FALSE;
-	}
-
       /* Load symbol information.  */
       r_symndx = ELF32_R_SYM (rel->r_info);
       if (r_symndx < symtab_hdr->sh_info) /* Is a local symbol.  */
@@ -1994,6 +1989,10 @@ elf_arc_check_relocs (bfd *			 abfd,
 	      {
 		if (sreloc == NULL)
 		  {
+		    if (info->dynamic
+			&& ! htab->dynamic_sections_created
+			&& ! _bfd_elf_link_create_dynamic_sections (abfd, info))
+		      return FALSE;
 		    sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj,
 								  2, abfd,
 								  /*rela*/
@@ -2021,6 +2020,9 @@ elf_arc_check_relocs (bfd *			 abfd,
       if (is_reloc_for_GOT (howto)
 	  || is_reloc_for_TLS (howto))
 	{
+	  if (! _bfd_elf_create_got_section (dynobj, info))
+	    return FALSE;
+
 	  arc_fill_got_info_for_reloc (
 		  arc_got_entry_type_for_reloc (howto),
 		  get_got_entry_list_for_symbol (abfd, r_symndx, h),


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]