This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[arm] Implement R_ARM_TARGET1
- From: Paul Brook <paul at codesourcery dot com>
- To: binutils at sources dot redhat dot com
- Cc: Richard Earnshaw <rearnsha at gcc dot gnu dot org>
- Date: Mon, 13 Sep 2004 14:29:53 +0100
- Subject: [arm] Implement R_ARM_TARGET1
- Organization: CodeSourcery
The patch below renames R_ARM_RELABS32 to R_ARM_TARGET1, and implements it.
It also adds commandline and target specific mechanisms for defining its
value.
This relocation is used for pointers in the .init_array section. On some
targets it is equivalent to R_ARM_ABS32, on others R_ARM_REL32.
Ok?
Paul
2004-09-10 Paul Brook <paul@codesourcery.com>
bfd/
* bfd-in.h (bfd_elf32_arm_process_before_allocation): Update
prototype.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* elf32-arm.h (elf32_arm_link_hash_table): Add target1_is_rel.
(elf32_arm_link_hash_table_create): Set target1_is_rel.
(bfd_elf32_arm_process_before_allocation): Ditto.
(elf32_arm_final_link_relocate): Handle R_ARM_TARGET1.
(elf32_arm_gc_sweep_hook, elf32_arm_check_relocs): Ditto.
* elfarm-nabi.c (elf32_arm_howto_table): Rename RELABS to TARGET1.
* recloc.c: Ditto.
gas/
* config/tc-arm.c: Rename RELABS to TARGET1.
gas/testsuite/
* gas/arm/pic.d: Rename RELABS to TARGET1.
* gas/arm/pic.s: Ditto.
include/
* elf/arm.h: Rename RELABS to TARGET1.
ld/
* emulparams/armsymbian.sh: Set TARGET1_IS_REL.
* emultempl/armelf.em: Use TARGET1_IS_REL. Add --target1-{rel,abs}.
Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.87
diff -u -p -r1.87 bfd-in.h
--- bfd/bfd-in.h 21 Jul 2004 15:42:56 -0000 1.87
+++ bfd/bfd-in.h 10 Sep 2004 23:42:45 -0000
@@ -814,7 +814,7 @@ extern bfd_boolean bfd_elf32_arm_allocat
(struct bfd_link_info *);
extern bfd_boolean bfd_elf32_arm_process_before_allocation
- (bfd *, struct bfd_link_info *, int, int);
+ (bfd *, struct bfd_link_info *, int, int, int);
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
(bfd *, struct bfd_link_info *);
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.298
diff -u -p -r1.298 bfd-in2.h
--- bfd/bfd-in2.h 28 Aug 2004 03:05:18 -0000 1.298
+++ bfd/bfd-in2.h 10 Sep 2004 23:42:46 -0000
@@ -821,7 +821,7 @@ extern bfd_boolean bfd_elf32_arm_allocat
(struct bfd_link_info *);
extern bfd_boolean bfd_elf32_arm_process_before_allocation
- (bfd *, struct bfd_link_info *, int, int);
+ (bfd *, struct bfd_link_info *, int, int, int);
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
(bfd *, struct bfd_link_info *);
@@ -2641,7 +2641,7 @@ field in the instruction. */
/* Pc-relative or absolute relocation depending on target. Used for
entries in .init_array sections. */
- BFD_RELOC_ARM_RELABS32,
+ BFD_RELOC_ARM_TARGET1,
/* Read-only segment base relative address. */
BFD_RELOC_ARM_ROSEGREL32,
Index: bfd/elf32-arm.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.h,v
retrieving revision 1.139
diff -u -p -r1.139 elf32-arm.h
--- bfd/elf32-arm.h 6 Sep 2004 20:55:22 -0000 1.139
+++ bfd/elf32-arm.h 10 Sep 2004 23:42:47 -0000
@@ -182,6 +182,10 @@ struct elf32_arm_link_hash_table
/* Nonzero to output a BE8 image. */
int byteswap_code;
+ /* Zero if R_ARM_TARGET1 means R_ARM_ABS32.
+ Nonzero if R_ARM_TARGET1 means R_ARM_ABS32. */
+ int target1_is_rel;
+
/* The number of bytes in the initial entry in the PLT. */
bfd_size_type plt_header_size;
@@ -373,6 +377,7 @@ elf32_arm_link_hash_table_create (bfd *a
ret->bfd_of_glue_owner = NULL;
ret->no_pipeline_knowledge = 0;
ret->byteswap_code = 0;
+ ret->target1_is_rel = 0;
#ifdef FOUR_WORD_PLT
ret->plt_header_size = 16;
ret->plt_entry_size = 16;
@@ -752,7 +757,8 @@ bfd_boolean
bfd_elf32_arm_process_before_allocation (bfd *abfd,
struct bfd_link_info *link_info,
int no_pipeline_knowledge,
- int byteswap_code)
+ int byteswap_code,
+ int target1_is_rel)
{
Elf_Internal_Shdr *symtab_hdr;
Elf_Internal_Rela *internal_relocs = NULL;
@@ -775,6 +781,7 @@ bfd_elf32_arm_process_before_allocation
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
globals->no_pipeline_knowledge = no_pipeline_knowledge;
+ globals->target1_is_rel = target1_is_rel;
if (byteswap_code && !bfd_big_endian (abfd))
{
_bfd_error_handler (_("%B: BE8 images only valid in big-endian mode."),
@@ -1174,6 +1181,22 @@ elf32_arm_final_link_relocate (reloc_how
bfd_signed_vma signed_addend;
struct elf32_arm_link_hash_table * globals;
+ globals = elf32_arm_hash_table (info);
+
+#ifndef OLD_ARM_ABI
+ /* Some relocation type map to different relocations depending on the
+ target. We pick the right one here. */
+ if (r_type == R_ARM_TARGET1)
+ {
+ if (globals->target1_is_rel)
+ r_type = R_ARM_REL32;
+ else
+ r_type = R_ARM_ABS32;
+
+ howto = &elf32_arm_howto_table[r_type];
+ }
+#endif /* OLD_ARM_ABI */
+
/* If the start address has been set, then set the EF_ARM_HASENTRY
flag. Setting this more than once is redundant, but the cost is
not too high, and it keeps the code simple.
@@ -1186,8 +1209,6 @@ elf32_arm_final_link_relocate (reloc_how
if (bfd_get_start_address (output_bfd) != 0)
elf_elfheader (output_bfd)->e_flags |= EF_ARM_HASENTRY;
- globals = elf32_arm_hash_table (info);
-
dynobj = elf_hash_table (info)->dynobj;
if (dynobj)
{
@@ -2738,6 +2760,7 @@ elf32_arm_gc_sweep_hook (bfd *
case R_ARM_ABS32:
case R_ARM_REL32:
+ case R_ARM_TARGET1:
case R_ARM_PC24:
case R_ARM_PLT32:
r_symndx = ELF32_R_SYM (rel->r_info);
@@ -2753,7 +2776,8 @@ elf32_arm_gc_sweep_hook (bfd *
h->plt.refcount -= 1;
if (ELF32_R_TYPE (rel->r_info) == R_ARM_ABS32
- || ELF32_R_TYPE (rel->r_info) == R_ARM_REL32)
+ || ELF32_R_TYPE (rel->r_info) == R_ARM_REL32
+ || ELF32_R_TYPE (rel->r_info) == R_ARM_TARGET1)
{
eh = (struct elf32_arm_link_hash_entry *) h;
@@ -2864,6 +2888,7 @@ elf32_arm_check_relocs (bfd *abfd, struc
case R_ARM_ABS32:
case R_ARM_REL32:
+ case R_ARM_TARGET1:
case R_ARM_PC24:
case R_ARM_PLT32:
if (h != NULL)
@@ -2906,7 +2931,8 @@ elf32_arm_check_relocs (bfd *abfd, struc
&& (sec->flags & SEC_ALLOC) != 0
&& ((ELF32_R_TYPE (rel->r_info) != R_ARM_PC24
&& ELF32_R_TYPE (rel->r_info) != R_ARM_PLT32
- && ELF32_R_TYPE (rel->r_info) != R_ARM_REL32)
+ && ELF32_R_TYPE (rel->r_info) != R_ARM_REL32
+ && ELF32_R_TYPE (rel->r_info) != R_ARM_TARGET1)
|| (h != NULL
&& (! info->symbolic
|| (h->elf_link_hash_flags
@@ -2991,7 +3017,8 @@ elf32_arm_check_relocs (bfd *abfd, struc
}
if (ELF32_R_TYPE (rel->r_info) == R_ARM_ABS32
- || ELF32_R_TYPE (rel->r_info) == R_ARM_REL32)
+ || ELF32_R_TYPE (rel->r_info) == R_ARM_REL32
+ || ELF32_R_TYPE (rel->r_info) == R_ARM_TARGET1)
p->count += 1;
}
break;
Index: bfd/elfarm-nabi.c
===================================================================
RCS file: /cvs/src/src/bfd/elfarm-nabi.c,v
retrieving revision 1.22
diff -u -p -r1.22 elfarm-nabi.c
--- bfd/elfarm-nabi.c 6 Sep 2004 20:55:22 -0000 1.22
+++ bfd/elfarm-nabi.c 10 Sep 2004 23:42:48 -0000
@@ -595,7 +595,7 @@ static reloc_howto_type elf32_arm_howto_
0x0ff00000, /* dst_mask */
FALSE), /* pcrel_offset */
- HOWTO (R_ARM_RELABS32, /* type */
+ HOWTO (R_ARM_TARGET1, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
32, /* bitsize */
@@ -603,7 +603,7 @@ static reloc_howto_type elf32_arm_howto_
0, /* bitpos */
complain_overflow_dont,/* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
- "R_ARM_RELABS32", /* name */
+ "R_ARM_TARGET1", /* name */
FALSE, /* partial_inplace */
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
@@ -769,7 +769,7 @@ static const struct elf32_arm_reloc_map
{BFD_RELOC_ARM_GOTPC, R_ARM_GOTPC},
{BFD_RELOC_ARM_GOT32, R_ARM_GOT32},
{BFD_RELOC_ARM_PLT32, R_ARM_PLT32},
- {BFD_RELOC_ARM_RELABS32, R_ARM_RELABS32},
+ {BFD_RELOC_ARM_TARGET1, R_ARM_TARGET1},
{BFD_RELOC_ARM_ROSEGREL32, R_ARM_ROSEGREL32},
{BFD_RELOC_ARM_SBREL32, R_ARM_SBREL32}
};
Index: bfd/libbfd.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.h,v
retrieving revision 1.123
diff -u -p -r1.123 libbfd.h
--- bfd/libbfd.h 28 Aug 2004 03:05:18 -0000 1.123
+++ bfd/libbfd.h 10 Sep 2004 23:42:48 -0000
@@ -1134,7 +1134,7 @@ 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_TARGET1",
"BFD_RELOC_ARM_ROSEGREL32",
"BFD_RELOC_ARM_SBREL32",
"BFD_RELOC_SH_PCDISP8BY2",
Index: bfd/reloc.c
===================================================================
RCS file: /cvs/src/src/bfd/reloc.c,v
retrieving revision 1.111
diff -u -p -r1.111 reloc.c
--- bfd/reloc.c 25 Aug 2004 12:54:14 -0000 1.111
+++ bfd/reloc.c 10 Sep 2004 23:42:49 -0000
@@ -2609,7 +2609,7 @@ 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
+ BFD_RELOC_ARM_TARGET1
ENUMDOC
Pc-relative or absolute relocation depending on target. Used for
entries in .init_array sections.
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.175
diff -u -p -r1.175 tc-arm.c
--- gas/config/tc-arm.c 3 Sep 2004 17:15:40 -0000 1.175
+++ gas/config/tc-arm.c 10 Sep 2004 23:42:51 -0000
@@ -12487,7 +12487,7 @@ md_apply_fix3 (fixP, valP, seg)
case BFD_RELOC_RVA:
case BFD_RELOC_32:
- case BFD_RELOC_ARM_RELABS32:
+ case BFD_RELOC_ARM_TARGET1:
case BFD_RELOC_ARM_ROSEGREL32:
case BFD_RELOC_ARM_SBREL32:
if (fixP->fx_done || fixP->fx_pcrel)
@@ -12777,7 +12777,7 @@ 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_TARGET1:
case BFD_RELOC_ARM_ROSEGREL32:
case BFD_RELOC_ARM_SBREL32:
code = fixp->fx_r_type;
@@ -14149,7 +14149,7 @@ 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 ("(target1)", BFD_RELOC_ARM_TARGET1),
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.6
diff -u -p -r1.6 pic.d
--- gas/testsuite/gas/arm/pic.d 6 Aug 2004 16:18:11 -0000 1.6
+++ gas/testsuite/gas/arm/pic.d 10 Sep 2004 23:42:51 -0000
@@ -15,5 +15,5 @@ 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
+ 18: R_ARM_TARGET1 foo2
1c: R_ARM_SBREL32 foo3
Index: gas/testsuite/gas/arm/pic.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/pic.s,v
retrieving revision 1.2
diff -u -p -r1.2 pic.s
--- gas/testsuite/gas/arm/pic.s 6 Aug 2004 16:18:11 -0000 1.2
+++ gas/testsuite/gas/arm/pic.s 10 Sep 2004 23:42:51 -0000
@@ -9,5 +9,5 @@
.word sym(GOTOFF)
1:
.word _GLOBAL_OFFSET_TABLE_ - 1b
- .word foo2(RELABS)
+ .word foo2(TARGET1)
.word foo3(SBREL)
Index: include/elf/arm.h
===================================================================
RCS file: /cvs/src/src/include/elf/arm.h,v
retrieving revision 1.14
diff -u -p -r1.14 arm.h
--- include/elf/arm.h 6 Aug 2004 16:18:11 -0000 1.14
+++ include/elf/arm.h 10 Sep 2004 23:42:52 -0000
@@ -127,7 +127,7 @@ START_RELOC_NUMBERS (elf_arm_reloc_type)
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_TARGET1, 38)
RELOC_NUMBER (R_ARM_ROSEGREL32, 39)
RELOC_NUMBER (R_ARM_V4BX, 40)
RELOC_NUMBER (R_ARM_STKCHK, 41)
Index: ld/emulparams/armsymbian.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/armsymbian.sh,v
retrieving revision 1.2
diff -u -p -r1.2 armsymbian.sh
--- ld/emulparams/armsymbian.sh 6 Sep 2004 20:55:23 -0000 1.2
+++ ld/emulparams/armsymbian.sh 10 Sep 2004 23:42:52 -0000
@@ -4,6 +4,7 @@ GENERATE_COMBRELOC_SCRIPT=1
OUTPUT_FORMAT="elf32-littlearm-symbian"
BIG_OUTPUT_FORMAT="elf32-bigarm-symbian"
LITTLE_OUTPUT_FORMAT="$OUTPUT_FORMAT"
+TARGET1_IS_REL=1
# This value should match ELF_MAXPAGESIZE in BFD. Otherwise, elf.c
# will not place read-write sections in a separate ELF segment from
Index: ld/emultempl/armelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armelf.em,v
retrieving revision 1.38
diff -u -p -r1.38 armelf.em
--- ld/emultempl/armelf.em 25 May 2004 06:33:50 -0000 1.38
+++ ld/emultempl/armelf.em 10 Sep 2004 23:42:52 -0000
@@ -28,6 +28,7 @@ static int no_pipeline_knowledge = 0;
static char *thumb_entry_symbol = NULL;
static bfd *bfd_for_interwork;
static int byteswap_code = 0;
+static int target1_is_rel = 0${TARGET1_IS_REL};
static void
gld${EMULATION_NAME}_before_parse (void)
@@ -120,7 +121,8 @@ arm_elf_before_allocation (void)
{
if (!bfd_elf32_arm_process_before_allocation (is->the_bfd, & link_info,
no_pipeline_knowledge,
- byteswap_code))
+ byteswap_code,
+ target1_is_rel))
{
/* xgettext:c-format */
einfo (_("Errors encountered processing file %s"), is->filename);
@@ -188,6 +190,8 @@ EOF
PARSE_AND_LIST_PROLOGUE='
#define OPTION_THUMB_ENTRY 301
#define OPTION_BE8 302
+#define OPTION_TARGET1_REL 303
+#define OPTION_TARGET1_ABS 304
'
PARSE_AND_LIST_SHORTOPTS=p
@@ -196,12 +200,16 @@ PARSE_AND_LIST_LONGOPTS='
{ "no-pipeline-knowledge", no_argument, NULL, '\'p\''},
{ "thumb-entry", required_argument, NULL, OPTION_THUMB_ENTRY},
{ "be8", no_argument, NULL, OPTION_BE8},
+ { "target1-rel", no_argument, NULL, OPTION_TARGET1_REL},
+ { "target1-abs", no_argument, NULL, OPTION_TARGET1_ABS},
'
PARSE_AND_LIST_OPTIONS='
fprintf (file, _(" -p --no-pipeline-knowledge Stop the linker knowing
about the pipeline length\n"));
fprintf (file, _(" --thumb-entry=<sym> Set the entry point to be
Thumb symbol <sym>\n"));
fprintf (file, _(" --be8 Oputput BE8 format
image\n"));
+ fprintf (file, _(" --target1-rel Interpret R_ARM_TARGET1 as
R_AMR_REL32\n"));
+ fprintf (file, _(" --target1-abs Interpret R_ARM_TARGET1 as
R_AMR_ABS32\n"));
'
PARSE_AND_LIST_ARGS_CASES='
@@ -216,6 +224,14 @@ PARSE_AND_LIST_ARGS_CASES='
case OPTION_BE8:
byteswap_code = 1;
break;
+
+ case OPTION_TARGET1_REL:
+ target1_is_rel = 1;
+ break;
+
+ case OPTION_TARGET1_ABS:
+ target1_is_rel = 0;
+ break;
'
# We have our own after_open and before_allocation functions, but they call