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] ARC_PC32 dynamic reloc incorrectly generated.


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

commit cd6402916febae6d8a4e62c572ea6fd487eebb61
Author: Cupertino Miranda <cmiranda@synopsys.com>
Date:   Wed Nov 30 14:07:20 2016 +0100

    [ARC] ARC_PC32 dynamic reloc incorrectly generated.
    
    Fixed issue related to the generation of ARC_PC32 dynamic relocs when symbol
    is dynamic but still defined in a non shared object.
    
    bfd/ChangeLog:
    
        Cupertino Miranda  <cmiranda@synopsys.com>
    
    	elf32-arc.c (elf_arc_relocate_section): Small refactor and condition
    	changes.

Diff:
---
 bfd/ChangeLog   |  5 +++++
 bfd/elf32-arc.c | 23 +++++++++++++----------
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7fd3322..f746908 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2018-06-08  Cupertino Miranda  <cmiranda@synopsys.com>
+
+	* elf32-arc.c (elf_arc_relocate_section): Small refactor and condition
+	changes.
+
 2017-06-08  Cupertino Miranda  <cmiranda@synopsys.com>
 
 	* config/tc-arc.c (md_undefined_symbol): Changed.
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 26e1bd4..b1a1697 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1713,16 +1713,22 @@ elf_arc_relocate_section (bfd *		          output_bfd,
 	    }
 	}
 
+
+#define IS_ARC_PCREL_TYPE(TYPE) \
+  (   (TYPE == R_ARC_PC32)      \
+   || (TYPE == R_ARC_32_PCREL))
+
       switch (r_type)
 	{
 	  case R_ARC_32:
 	  case R_ARC_32_ME:
 	  case R_ARC_PC32:
 	  case R_ARC_32_PCREL:
-	    if ((bfd_link_pic (info))
-		&& ((r_type != R_ARC_PC32 && r_type != R_ARC_32_PCREL)
+	    if (bfd_link_pic (info)
+		&& (!IS_ARC_PCREL_TYPE (r_type)
 		    || (h != NULL
 			&& h->dynindx != -1
+			&& !h->def_regular
 			&& (!info->symbolic || !h->def_regular))))
 	      {
 		Elf_Internal_Rela outrel;
@@ -1739,6 +1745,7 @@ elf_arc_relocate_section (bfd *		          output_bfd,
 							   info,
 							   input_section,
 							   rel->r_offset);
+
 		if (outrel.r_offset == (bfd_vma) -1)
 		  skip = TRUE;
 
@@ -1746,10 +1753,6 @@ elf_arc_relocate_section (bfd *		          output_bfd,
 		outrel.r_offset += (input_section->output_section->vma
 				    + input_section->output_offset);
 
-#define IS_ARC_PCREL_TYPE(TYPE) \
-  (   (TYPE == R_ARC_PC32)      \
-   || (TYPE == R_ARC_32_PCREL))
-
 		if (skip)
 		  {
 		    memset (&outrel, 0, sizeof outrel);
@@ -1757,10 +1760,10 @@ elf_arc_relocate_section (bfd *		          output_bfd,
 		  }
 		else if (h != NULL
 			 && h->dynindx != -1
-			 && ((IS_ARC_PCREL_TYPE (r_type))
-			 || !(bfd_link_executable (info)
-			      || SYMBOLIC_BIND (info, h))
-			 || ! h->def_regular))
+			 && (IS_ARC_PCREL_TYPE (r_type)
+			     || !(bfd_link_executable (info)
+				  || SYMBOLIC_BIND (info, h))
+			     || ! h->def_regular))
 		  {
 		    BFD_ASSERT (h != NULL);
 		    if ((input_section->flags & SEC_ALLOC) != 0)


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