This is the mail archive of the binutils@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]

[PATCH 1/2][ARC] Add BFD_RELOC_ARC_32_PCREL relocation.


These patches are fixing the observed ARC backend's GAS dejagnu errors.

Please review,
Claudiu

ChangeLog BFD:
2015-10-20  Cupertino Miranda  <cmiranda@synopsys.com>

	* reloc.c (BFD_RELOC_ARC_32_PCREL): New entry.
	* arc-reloc.def (ARC_32_PCREL): New definition.
	(ARC_TLS_DTPOFF): Arrange it in order.
	* elf32-arc.c (arc_elf_howto_ini): Update formula.
	(get_middle_endian_relocation): New function.
	(PDATA): Define.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
---
 bfd/bfd-in2.h             |    1 +
 bfd/elf32-arc.c           |   19 ++++++++++++++++++-
 bfd/libbfd.h              |    1 +
 bfd/reloc.c               |    2 ++
 include/elf/arc-reloc.def |   20 +++++++++++++-------
 5 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 60d7e45..1b2aa8a 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -3664,6 +3664,7 @@ pc-relative or some form of GOT-indirect relocation.  */
   BFD_RELOC_ARC_SECTOFF_1,
   BFD_RELOC_ARC_SECTOFF_2,
   BFD_RELOC_ARC_SDA16_ST2,
+  BFD_RELOC_ARC_32_PCREL,
   BFD_RELOC_ARC_PC32,
   BFD_RELOC_ARC_GOT32,
   BFD_RELOC_ARC_GOTPC32,
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 68a47ca..37a426c 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -229,7 +229,8 @@ static struct reloc_howto_struct elf_arc_howto_table[] =
 static void arc_elf_howto_init (void)
 {
 #define ARC_RELOC_HOWTO(TYPE, VALUE, SIZE, BITSIZE, RELOC_FUNCTION, OVERFLOW, FORMULA) \
-  elf_arc_howto_table[TYPE].pc_relative = (strstr (#FORMULA, " P ") != NULL);
+  elf_arc_howto_table[TYPE].pc_relative = \
+    (strstr (#FORMULA, " P ") != NULL || strstr (#FORMULA, " PDATA ") != NULL);
 
   #include "elf/arc-reloc.def"
 }
@@ -473,6 +474,17 @@ debug_arc_reloc (struct arc_relocation_data reloc_data)
     fprintf (stderr, "	input section is NULL\n");
 }
 
+static ATTRIBUTE_UNUSED bfd_vma
+get_middle_endian_relocation (bfd_vma reloc)
+{
+  bfd_vma ret =
+	      ((reloc & 0xffff0000) >> 16) |
+	      ((reloc & 0xffff) << 16);
+  return ret;
+}
+
+#define ME(RELOC) (get_middle_endian_reloction(RELOC))
+
 #define S (reloc_data.sym_value \
 	   + reloc_data.sym_section->output_offset \
 	   + reloc_data.sym_section->output_section->vma)
@@ -491,6 +503,11 @@ debug_arc_reloc (struct arc_relocation_data reloc_data)
 	     + reloc_data.input_section->output_offset \
 	     + (reloc_data.reloc_offset - (bitsize >= 32 ? 4 : 0)) \
 	    ) & ~0x3)
+#define PDATA ( \
+	    (reloc_data.input_section->output_section->vma \
+	     + reloc_data.input_section->output_offset \
+	     + (reloc_data.reloc_offset) \
+	    ) & ~0x3)
 #define SECTSTAR (reloc_data.input_section->output_offset)
 #define SECTSTART (reloc_data.input_section->output_offset)
 #define _SDA_BASE_ (reloc_data.sdata_begin_symbol_vma)
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 9ae9ba2..07d3693 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -1704,6 +1704,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
   "BFD_RELOC_ARC_SECTOFF_1",
   "BFD_RELOC_ARC_SECTOFF_2",
   "BFD_RELOC_ARC_SDA16_ST2",
+  "BFD_RELOC_ARC_32_PCREL",
   "BFD_RELOC_ARC_PC32",
   "BFD_RELOC_ARC_GOT32",
   "BFD_RELOC_ARC_GOTPC32",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 886c63e..82ebd0c 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -3597,6 +3597,8 @@ ENUMX
 ENUMX
   BFD_RELOC_ARC_SDA16_ST2
 ENUMX
+  BFD_RELOC_ARC_32_PCREL
+ENUMX
   BFD_RELOC_ARC_PC32
 ENUMX
   BFD_RELOC_ARC_GOT32
diff --git a/include/elf/arc-reloc.def b/include/elf/arc-reloc.def
index e2ff871..893291f 100644
--- a/include/elf/arc-reloc.def
+++ b/include/elf/arc-reloc.def
@@ -1,4 +1,3 @@
-
 ARC_RELOC_HOWTO(ARC_NONE, 0, \
                 2, \
                 32, \
@@ -286,6 +285,13 @@ ARC_RELOC_HOWTO(ARC_SDA16_ST2, 48, \
                 signed, \
                 ( ( ( S + A ) - _SDA_BASE_ ) >> 2 ))
 
+ARC_RELOC_HOWTO(ARC_32_PCREL, 49, \
+                2, \
+                32, \
+                replace_word32, \
+                signed, \
+                ( ( S + A ) - PDATA ))
+
 ARC_RELOC_HOWTO(ARC_PC32, 50, \
                 2, \
                 32, \
@@ -377,42 +383,42 @@ ARC_RELOC_HOWTO(ARC_TLS_DTPMOD, 66, \
                 dont, \
                 0)
 
-ARC_RELOC_HOWTO(ARC_TLS_DTPOFF, 67, \
+ARC_RELOC_HOWTO(ARC_TLS_TPOFF, 68, \
                 2, \
                 32, \
                 replace_word32, \
                 dont, \
                 0)
 
-ARC_RELOC_HOWTO(ARC_TLS_TPOFF, 68, \
+ARC_RELOC_HOWTO(ARC_TLS_GD_GOT, 69, \
                 2, \
                 32, \
                 replace_word32, \
                 dont, \
                 0)
 
-ARC_RELOC_HOWTO(ARC_TLS_GD_GOT, 69, \
+ARC_RELOC_HOWTO(ARC_TLS_GD_LD, 70, \
                 2, \
                 32, \
                 replace_word32, \
                 dont, \
                 0)
 
-ARC_RELOC_HOWTO(ARC_TLS_GD_LD, 70, \
+ARC_RELOC_HOWTO(ARC_TLS_GD_CALL, 71, \
                 2, \
                 32, \
                 replace_word32, \
                 dont, \
                 0)
 
-ARC_RELOC_HOWTO(ARC_TLS_GD_CALL, 71, \
+ARC_RELOC_HOWTO(ARC_TLS_IE_GOT, 72, \
                 2, \
                 32, \
                 replace_word32, \
                 dont, \
                 0)
 
-ARC_RELOC_HOWTO(ARC_TLS_IE_GOT, 72, \
+ARC_RELOC_HOWTO(ARC_TLS_DTPOFF, 67, \
                 2, \
                 32, \
                 replace_word32, \
-- 
1.7.0.4


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