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] Check SEC_ALLOC before allocating dynamic relocation


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

commit 4c23f2ffa8fbd467bca51956130a1f30cfe34371
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jun 15 18:42:56 2016 -0700

    Check SEC_ALLOC before allocating dynamic relocation
    
    	* elf32-i386.c (elf_i386_check_relocs): Check SEC_ALLOC before
    	allocating dynamic relocation.
    	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.

Diff:
---
 bfd/ChangeLog      |  6 ++++++
 bfd/elf32-i386.c   | 27 +++++++++++++--------------
 bfd/elf64-x86-64.c | 27 +++++++++++++--------------
 3 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 38d28f3..344e08b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-15  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elf32-i386.c (elf_i386_check_relocs): Check SEC_ALLOC before
+	allocating dynamic relocation.
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+
 2016-06-14  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
 
 	PR ld/20254
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 686c068..793fb39 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2202,20 +2202,19 @@ do_size:
 	     may need to keep relocations for symbols satisfied by a
 	     dynamic library if we manage to avoid copy relocs for the
 	     symbol.  */
-	  if ((bfd_link_pic (info)
-	       && (sec->flags & SEC_ALLOC) != 0
-	       && (r_type != R_386_PC32
-		   || (h != NULL
-		       && (! (bfd_link_pie (info)
-			      || SYMBOLIC_BIND (info, h))
-			   || h->root.type == bfd_link_hash_defweak
-			   || !h->def_regular))))
-	      || (ELIMINATE_COPY_RELOCS
-		  && !bfd_link_pic (info)
-		  && (sec->flags & SEC_ALLOC) != 0
-		  && h != NULL
-		  && (h->root.type == bfd_link_hash_defweak
-		      || !h->def_regular)))
+	  if ((sec->flags & SEC_ALLOC) != 0
+	      && ((bfd_link_pic (info)
+		   && (r_type != R_386_PC32
+		       || (h != NULL
+			   && (! (bfd_link_pie (info)
+				  || SYMBOLIC_BIND (info, h))
+			       || h->root.type == bfd_link_hash_defweak
+			       || !h->def_regular))))
+		  || (ELIMINATE_COPY_RELOCS
+		      && !bfd_link_pic (info)
+		      && h != NULL
+		      && (h->root.type == bfd_link_hash_defweak
+			  || !h->def_regular))))
 	    {
 	      struct elf_dyn_relocs *p;
 	      struct elf_dyn_relocs **head;
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index b209604..8c8bcce 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2601,20 +2601,19 @@ do_size:
 	     may need to keep relocations for symbols satisfied by a
 	     dynamic library if we manage to avoid copy relocs for the
 	     symbol.  */
-	  if ((bfd_link_pic (info)
-	       && (sec->flags & SEC_ALLOC) != 0
-	       && (! IS_X86_64_PCREL_TYPE (r_type)
-		   || (h != NULL
-		       && (! (bfd_link_pie (info)
-			      || SYMBOLIC_BIND (info, h))
-			   || h->root.type == bfd_link_hash_defweak
-			   || !h->def_regular))))
-	      || (ELIMINATE_COPY_RELOCS
-		  && !bfd_link_pic (info)
-		  && (sec->flags & SEC_ALLOC) != 0
-		  && h != NULL
-		  && (h->root.type == bfd_link_hash_defweak
-		      || !h->def_regular)))
+	  if ((sec->flags & SEC_ALLOC) != 0
+	      && ((bfd_link_pic (info)
+		   && (! IS_X86_64_PCREL_TYPE (r_type)
+		       || (h != NULL
+			   && (! (bfd_link_pie (info)
+				  || SYMBOLIC_BIND (info, h))
+			       || h->root.type == bfd_link_hash_defweak
+			       || !h->def_regular))))
+		  || (ELIMINATE_COPY_RELOCS
+		      && !bfd_link_pic (info)
+		      && h != NULL
+		      && (h->root.type == bfd_link_hash_defweak
+			  || !h->def_regular))))
 	    {
 	      struct elf_dyn_relocs *p;
 	      struct elf_dyn_relocs **head;


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