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] Do not choose a non-ELF format input file to hold the linker created GOT sections.


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

commit b7a18930e3925c4092bd975e95bc3603aa1418d9
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Aug 7 10:09:51 2017 +0100

    Do not choose a non-ELF format input file to hold the linker created GOT sections.
    
    	PR 21884
    	* elf32-i386.c (elf_i386_link_setup_gnu_properties): If the dynobj
    	has not been set then use the bfd returned by
    	_bfd_elf_link_setup_gnu_properties.  If that is null then search
    	through all the input bfds selecting the first normal, ELF format
    	one.
    	* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Likewise.

Diff:
---
 bfd/ChangeLog      | 10 ++++++++++
 bfd/elf32-i386.c   | 39 ++++++++++++++++++++++++---------------
 bfd/elf64-x86-64.c |  5 +++--
 3 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 49ef45f..694675f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+2017-08-07  Nick Clifton  <nickc@redhat.com>
+
+	PR 21884
+	* elf32-i386.c (elf_i386_link_setup_gnu_properties): If the dynobj
+	has not been set then use the bfd returned by
+	_bfd_elf_link_setup_gnu_properties.  If that is null then search
+	through all the input bfds selecting the first normal, ELF format
+	one.
+	* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Likewise.
+
 2017-08-06  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* elf32-i386.c (elf_i386_link_hash_entry): Change tls_get_addr
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 14f018e..f1fcd21 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -6886,20 +6886,29 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
      set it in check_relocs.  */
   if (dynobj == NULL)
     {
-      bfd *abfd;
-
-      /* Find a normal input file to hold linker created
-	 sections.  */
-      for (abfd = info->input_bfds;
-	   abfd != NULL;
-	   abfd = abfd->link.next)
-	if ((abfd->flags
-	     & (DYNAMIC | BFD_LINKER_CREATED | BFD_PLUGIN)) == 0)
-	  {
-	    htab->elf.dynobj = abfd;
-	    dynobj = abfd;
-	    break;
-	  }
+      if (pbfd != NULL)
+	{
+	  htab->elf.dynobj = pbfd;
+	  dynobj = pbfd;
+	}
+      else
+	{
+	  bfd *abfd;
+
+	  /* Find a normal input file to hold linker created
+	     sections.  */
+	  for (abfd = info->input_bfds;
+	       abfd != NULL;
+	       abfd = abfd->link.next)
+	    if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+		&& (abfd->flags
+		    & (DYNAMIC | BFD_LINKER_CREATED | BFD_PLUGIN)) == 0)
+	      {
+		htab->elf.dynobj = abfd;
+		dynobj = abfd;
+		break;
+	      }
+	}
     }
 
   /* Even when lazy binding is disabled by "-z now", the PLT0 entry may
@@ -6991,7 +7000,7 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
     return pbfd;
 
   /* Since create_dynamic_sections isn't always called, but GOT
-     relocations need GOT relocations, create them here so that we
+     relocations need GOT sections, create them here so that we
      don't need to do it in check_relocs.  */
   if (htab->elf.sgot == NULL
       && !_bfd_elf_create_got_section (dynobj, info))
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index e5f4681..8364384 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -7427,8 +7427,9 @@ error_alignment:
 	  for (abfd = info->input_bfds;
 	       abfd != NULL;
 	       abfd = abfd->link.next)
-	    if ((abfd->flags
-		 & (DYNAMIC | BFD_LINKER_CREATED | BFD_PLUGIN)) == 0)
+	    if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
+		&& (abfd->flags
+		    & (DYNAMIC | BFD_LINKER_CREATED | BFD_PLUGIN)) == 0)
 	      {
 		htab->elf.dynobj = abfd;
 		dynobj = abfd;


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