This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 5/9] [ARC] ARC_PC32 dynamic reloc incorrectly generated.
- From: Cupertino Miranda <Cupertino dot Miranda at synopsys dot com>
- To: binutils at sourceware dot org
- Cc: Cupertino dot Miranda at synopsys dot com, Claudiu dot Zissulescu at synopsys dot com, Francois dot Bedard at synopsys dot com
- Date: Tue, 23 May 2017 17:40:52 +0200
- Subject: [PATCH 5/9] [ARC] ARC_PC32 dynamic reloc incorrectly generated.
- Authentication-results: sourceware.org; auth=none
- References: <20170523154056.19234-1-cmiranda@synopsys.com>
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.
---
bfd/elf32-arc.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 784bc0a..901218a 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1709,16 +1709,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;
@@ -1735,6 +1741,7 @@ elf_arc_relocate_section (bfd * output_bfd,
info,
input_section,
rel->r_offset);
+
if (outrel.r_offset == (bfd_vma) -1)
skip = TRUE;
@@ -1742,10 +1749,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);
@@ -1753,10 +1756,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)
--
2.9.0