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

[arm] bfd support for new relocations


The patch below adds preliminary bfd/gas support for several relocations 
defined by the ARM EABI. Further patches to implement the linker parts and 
use them should follow shortly.

Tested with cross to arm-none-elf.
Ok?

Paul

2004-07-07  Paul Brook  <paul@codesourcery.com>

bfd/
	* elfarm-nabi.c (elf32_arm_howto_table): Add new EABI relocations.
	(elf32_arm_reloc_map): Add BFD_RELOC_ARM_RELABS32,
	BFD_RELOC_ARM_ROSEGREL32 and BFD_RELOC_ARM_SBREL32.
	* reloc.c: Add BFD_RELOC_ARM_RELABS32, BFD_RELOC_ARM_ROSEGREL32
	and BFD_RELOC_ARM_SBREL32.
	* bfd-in2.h, bbfd.h: Regenerate.
gas/
	* config/tc-arm.c (md_apply_fix3, tc_gen_reloc, arm_parse_reloc):
	Handle new relocations.
	* include/elf/arm.h (elf_arm_reloc_type): Add new EABI relocations.
gase/testsuite/
	* gas/arm/pic.s,d: Test RELABS, ROSEGREL and SBREL relocations.

Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.287
diff -u -p -r1.287 bfd-in2.h
--- bfd/bfd-in2.h	2 Jul 2004 01:39:31 -0000	1.287
+++ bfd/bfd-in2.h	6 Jul 2004 23:50:42 -0000
@@ -2625,6 +2625,16 @@ field in the instruction.  */
   BFD_RELOC_ARM_GOTOFF,
   BFD_RELOC_ARM_GOTPC,
 
+/* PC-relative or absolute relocation depending on target.  Used for
+entries in .init_array sections.  */
+  BFD_RELOC_ARM_RELABS32,
+
+/* Read-only segment base relative address.  */
+  BFD_RELOC_ARM_ROSEGREL32,
+
+/* Data segment base relative address.  */
+  BFD_RELOC_ARM_SBREL32,
+
 /* Renesas / SuperH SH relocs.  Not all of these appear in object files.  */
   BFD_RELOC_SH_PCDISP8BY2,
   BFD_RELOC_SH_PCDISP12BY2,
Index: bfd/elfarm-nabi.c
===================================================================
RCS file: /cvs/src/src/bfd/elfarm-nabi.c,v
retrieving revision 1.19
diff -u -p -r1.19 elfarm-nabi.c
--- bfd/elfarm-nabi.c	24 Jun 2004 04:46:22 -0000	1.19
+++ bfd/elfarm-nabi.c	6 Jul 2004 23:50:43 -0000
@@ -557,6 +557,90 @@ static reloc_howto_type elf32_arm_howto_
 	 0x00000fff,		/* src_mask */
 	 0x00000fff,		/* dst_mask */
 	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_ARM_LDR_SBREL_11_0,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_ARM_LDR_SBREL_11_0",/* name */
+	 FALSE,			/* partial_inplace */
+	 0x00000fff,		/* src_mask */
+	 0x00000fff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_ARM_ALU_SBREL_19_12,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 12,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_ARM_ALU_SBREL_19_12",/* name */
+	 FALSE,			/* partial_inplace */
+	 0x000ff000,		/* src_mask */
+	 0x000ff000,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_ARM_ALU_SBREL_27_20,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 20,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_ARM_ALU_SBREL_27_20",/* name */
+	 FALSE,			/* partial_inplace */
+	 0x0ff00000,		/* src_mask */
+	 0x0ff00000,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_ARM_RELABS32,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_ARM_RELABS32",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_ARM_ROSEGREL32,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_ARM_ROSEGREL32",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_ARM_V4BX,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_ARM_V4BX",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
   /* GNU extension to record C++ vtable hierarchy */
@@ -689,7 +773,10 @@ static const struct elf32_arm_reloc_map 
     {BFD_RELOC_ARM_GOTOFF,           R_ARM_GOTOFF},
     {BFD_RELOC_ARM_GOTPC,            R_ARM_GOTPC},
     {BFD_RELOC_ARM_GOT32,            R_ARM_GOT32},
-    {BFD_RELOC_ARM_PLT32,            R_ARM_PLT32}
+    {BFD_RELOC_ARM_PLT32,            R_ARM_PLT32},
+    {BFD_RELOC_ARM_RELABS32,	     R_ARM_RELABS32},
+    {BFD_RELOC_ARM_ROSEGREL32,	     R_ARM_ROSEGREL32},
+    {BFD_RELOC_ARM_SBREL32,	     R_ARM_SBREL32}
   };
 
 static reloc_howto_type *
Index: bfd/libbfd.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.h,v
retrieving revision 1.114
diff -u -p -r1.114 libbfd.h
--- bfd/libbfd.h	28 Jun 2004 13:57:59 -0000	1.114
+++ bfd/libbfd.h	6 Jul 2004 23:50:43 -0000
@@ -1103,6 +1103,9 @@ static const char *const bfd_reloc_code_
   "BFD_RELOC_ARM_RELATIVE",
   "BFD_RELOC_ARM_GOTOFF",
   "BFD_RELOC_ARM_GOTPC",
+  "BFD_RELOC_ARM_RELABS32",
+  "BFD_RELOC_ARM_ROSEGREL32",
+  "BFD_RELOC_ARM_SBREL32",
   "BFD_RELOC_SH_PCDISP8BY2",
   "BFD_RELOC_SH_PCDISP12BY2",
   "BFD_RELOC_SH_IMM4",
Index: bfd/reloc.c
===================================================================
RCS file: /cvs/src/src/bfd/reloc.c,v
retrieving revision 1.106
diff -u -p -r1.106 reloc.c
--- bfd/reloc.c	29 Jun 2004 13:46:29 -0000	1.106
+++ bfd/reloc.c	6 Jul 2004 23:50:46 -0000
@@ -2608,6 +2608,19 @@ ENUMX
 ENUMDOC
   These relocs are only used within the ARM assembler.  They are not
   (at present) written to any object files.
+ENUM
+  BFD_RELOC_ARM_RELABS32
+ENUMDOC
+  Pc-relative or absolute relocation depending on target.  Used for
+  entries in .init_array sections.
+ENUM
+  BFD_RELOC_ARM_ROSEGREL32
+ENUMDOC
+  Read-only segment base relative address.
+ENUM
+  BFD_RELOC_ARM_SBREL32
+ENUMDOC
+  Data segment base relative address.
 
 ENUM
   BFD_RELOC_SH_PCDISP8BY2
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.169
diff -u -p -r1.169 tc-arm.c
--- gas/config/tc-arm.c	2 Jul 2004 11:12:29 -0000	1.169
+++ gas/config/tc-arm.c	6 Jul 2004 23:50:50 -0000
@@ -12558,6 +12558,9 @@ md_apply_fix3 (fixP, valP, seg)
 
     case BFD_RELOC_RVA:
     case BFD_RELOC_32:
+    case BFD_RELOC_ARM_RELABS32:
+    case BFD_RELOC_ARM_ROSEGREL32:
+    case BFD_RELOC_ARM_SBREL32:
       if (fixP->fx_done || fixP->fx_pcrel)
 	md_number_to_chars (buf, value, 4);
 #ifdef OBJ_ELF
@@ -12845,6 +12848,9 @@ tc_gen_reloc (section, fixp)
     case BFD_RELOC_ARM_GOT32:
     case BFD_RELOC_ARM_GOTOFF:
     case BFD_RELOC_ARM_PLT32:
+    case BFD_RELOC_ARM_RELABS32:
+    case BFD_RELOC_ARM_ROSEGREL32:
+    case BFD_RELOC_ARM_SBREL32:
       code = fixp->fx_r_type;
       break;
 #endif
@@ -14203,6 +14209,9 @@ arm_parse_reloc ()
     /* ScottB: Jan 30, 1998 - Added support for parsing "var(PLT)"
        branch instructions generated by GCC for PLT relocs.  */
     MAP ("(plt)",    BFD_RELOC_ARM_PLT32),
+    MAP ("(relabs)", BFD_RELOC_ARM_RELABS32),
+    MAP ("(rosegrel)", BFD_RELOC_ARM_ROSEGREL32),
+    MAP ("(sbrel)", BFD_RELOC_ARM_SBREL32),
     { NULL, 0,         BFD_RELOC_UNUSED }
 #undef MAP
   };
Index: gas/testsuite/gas/arm/pic.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/pic.d,v
retrieving revision 1.5
diff -u -p -r1.5 pic.d
--- gas/testsuite/gas/arm/pic.d	14 Nov 2003 15:12:43 -0000	1.5
+++ gas/testsuite/gas/arm/pic.d	6 Jul 2004 23:50:50 -0000
@@ -15,3 +15,6 @@ Disassembly of section .text:
 			c: R_ARM_GOT32	sym
 			10: R_ARM_GOTOFF	sym
 			14: R_ARM_GOTPC	_GLOBAL_OFFSET_TABLE_
+			18: R_ARM_RELABS32	foo2
+			1c: R_ARM_ROSEGREL32	foo3
+			23: R_ARM_SBREL32	foo4
Index: gas/testsuite/gas/arm/pic.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/pic.s,v
retrieving revision 1.1
diff -u -p -r1.1 pic.s
--- gas/testsuite/gas/arm/pic.s	1 Jan 2001 13:43:06 -0000	1.1
+++ gas/testsuite/gas/arm/pic.s	6 Jul 2004 23:50:50 -0000
@@ -9,3 +9,6 @@
 	.word	sym(GOTOFF)
 1:
 	.word	_GLOBAL_OFFSET_TABLE_ - 1b
+	.word foo2(RELABS)
+	.word foo3(ROSEGREL)
+	.word foo4(SBREL)
Index: include/elf/arm.h
===================================================================
RCS file: /cvs/src/src/include/elf/arm.h,v
retrieving revision 1.13
diff -u -p -r1.13 arm.h
--- include/elf/arm.h	23 Mar 2004 23:05:52 -0000	1.13
+++ include/elf/arm.h	6 Jul 2004 23:50:51 -0000
@@ -124,10 +124,15 @@ START_RELOC_NUMBERS (elf_arm_reloc_type)
   RELOC_NUMBER (R_ARM_ALU_PCREL7_0,    32)
   RELOC_NUMBER (R_ARM_ALU_PCREL15_8,   33)
   RELOC_NUMBER (R_ARM_ALU_PCREL23_15,  34)
-  RELOC_NUMBER (R_ARM_LDR_SBREL11_0,   35)
-  RELOC_NUMBER (R_ARM_ALU_SBREL19_12,  36)
-  RELOC_NUMBER (R_ARM_ALU_SBREL27_20,  37)
-  FAKE_RELOC   (FIRST_INVALID_RELOC2,  38)
+  RELOC_NUMBER (R_ARM_LDR_SBREL_11_0,  35)
+  RELOC_NUMBER (R_ARM_ALU_SBREL_19_12, 36)
+  RELOC_NUMBER (R_ARM_ALU_SBREL_27_20, 37)
+  RELOC_NUMBER (R_ARM_RELABS32,        38)
+  RELOC_NUMBER (R_ARM_ROSEGREL32,      39)
+  RELOC_NUMBER (R_ARM_V4BX,            40)
+  RELOC_NUMBER (R_ARM_STKCHK,          41)
+  RELOC_NUMBER (R_ARM_THM_STKCHK,      42)
+  FAKE_RELOC   (FIRST_INVALID_RELOC2,  43)
   FAKE_RELOC   (LAST_INVALID_RELOC2,   99)
   RELOC_NUMBER (R_ARM_GNU_VTENTRY,    100)
   RELOC_NUMBER (R_ARM_GNU_VTINHERIT,  101)


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