This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Added R_M32R_REL32 relocation
- From: Kazuhiro Inaoka <inaoka dot kazuhiro at renesas dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: "binutils at sources dot redhat dot com" <binutils at sources dot redhat dot com>
- Date: Wed, 20 Jul 2005 17:00:09 +0900
- Subject: [PATCH] Added R_M32R_REL32 relocation
Hi Nick,
Thease are pathes to add a relocation of R_M32R_REL32.
Please commit them.
Regards,
Kazuhiro Inaoka
2005-07-20 Kazuhiro Inaoka <inaoka.kazuhiro@renesas.com>
* elf32-m32r.c (m32r_elf_howto_table): Support R_M32R_REL32.
(m32r_reloc_map): Likewise.
(m32r_elf_relocate_section): Likewise.
(m32r_elf_gc_sweep_hook): Likewise.
(m32r_elf_check_relocs): Likewise.
Index: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.69
diff -u -r1.69 elf32-m32r.c
--- bfd/elf32-m32r.c 8 Jul 2005 06:19:59 -0000 1.69
+++ bfd/elf32-m32r.c 20 Jul 2005 02:13:25 -0000
@@ -877,7 +877,21 @@
0, /* dst_mask */
FALSE), /* pcrel_offset */
- EMPTY_HOWTO (45),
+ /* A 32 bit PC relative relocation. */
+ HOWTO (R_M32R_REL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ TRUE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc,/* special_function */
+ "R_M32R_REL32", /* name */
+ FALSE, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ TRUE), /* pcrel_offset */
+
EMPTY_HOWTO (46),
EMPTY_HOWTO (47),
@@ -1193,6 +1207,7 @@
{ BFD_RELOC_M32R_SDA16, R_M32R_SDA16_RELA },
{ BFD_RELOC_VTABLE_INHERIT, R_M32R_RELA_GNU_VTINHERIT },
{ BFD_RELOC_VTABLE_ENTRY, R_M32R_RELA_GNU_VTENTRY },
+ { BFD_RELOC_32_PCREL, R_M32R_REL32 },
{ BFD_RELOC_M32R_GOT24, R_M32R_GOT24 },
{ BFD_RELOC_M32R_26_PLTREL, R_M32R_26_PLTREL },
@@ -2611,6 +2626,7 @@
|| r_type == R_M32R_HI16_SLO_RELA
|| r_type == R_M32R_LO16_RELA)
&& !h->forced_local)
+ || r_type == R_M32R_REL32
|| r_type == R_M32R_10_PCREL_RELA
|| r_type == R_M32R_18_PCREL_RELA
|| r_type == R_M32R_26_PCREL_RELA)
@@ -2854,6 +2870,7 @@
case R_M32R_16_RELA:
case R_M32R_24_RELA:
case R_M32R_32_RELA:
+ case R_M32R_REL32:
case R_M32R_18_PCREL_RELA:
case R_M32R_26_PCREL_RELA:
case R_M32R_HI16_ULO_RELA:
@@ -2862,7 +2879,8 @@
&& r_symndx != 0
&& (input_section->flags & SEC_ALLOC) != 0
&& ((r_type != R_M32R_18_PCREL_RELA
- && r_type != R_M32R_26_PCREL_RELA)
+ && r_type != R_M32R_26_PCREL_RELA
+ && r_type != R_M32R_REL32)
|| (h != NULL
&& h->dynindx != -1
&& (! info->symbolic
@@ -2912,7 +2930,8 @@
if (skip)
memset (&outrel, 0, sizeof outrel);
else if (r_type == R_M32R_18_PCREL_RELA
- || r_type == R_M32R_26_PCREL_RELA)
+ || r_type == R_M32R_26_PCREL_RELA
+ || r_type == R_M32R_REL32)
{
BFD_ASSERT (h != NULL && h->dynindx != -1);
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
@@ -3683,6 +3702,7 @@
case R_M32R_16_RELA:
case R_M32R_24_RELA:
case R_M32R_32_RELA:
+ case R_M32R_REL32:
case R_M32R_HI16_ULO_RELA:
case R_M32R_HI16_SLO_RELA:
case R_M32R_LO16_RELA:
@@ -3704,7 +3724,8 @@
if (p->sec == sec)
{
if (ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA
- || ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA)
+ || ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA
+ || ELF32_R_TYPE (rel->r_info) == R_M32R_REL32)
p->pc_count -= 1;
p->count -= 1;
if (p->count == 0)
@@ -3864,6 +3885,7 @@
case R_M32R_16_RELA:
case R_M32R_24_RELA:
case R_M32R_32_RELA:
+ case R_M32R_REL32:
case R_M32R_HI16_ULO_RELA:
case R_M32R_HI16_SLO_RELA:
case R_M32R_LO16_RELA:
@@ -3899,7 +3921,8 @@
if ((info->shared
&& (sec->flags & SEC_ALLOC) != 0
&& ((r_type != R_M32R_26_PCREL_RELA
- && r_type != R_M32R_18_PCREL_RELA)
+ && r_type != R_M32R_18_PCREL_RELA
+ && r_type != R_M32R_REL32)
|| (h != NULL
&& (! info->symbolic
|| h->root.type == bfd_link_hash_defweak
2005-07-20 Kazuhiro Inaoka <inaoka.kazuhiro@renesas.com>
* elf/m32r.h (R_M32R_REL32): Added R_M32R_REL32.
Index: include/elf/m32r.h
===================================================================
RCS file: /cvs/src/src/include/elf/m32r.h,v
retrieving revision 1.9
diff -u -r1.9 m32r.h
--- include/elf/m32r.h 10 May 2005 10:21:10 -0000 1.9
+++ include/elf/m32r.h 20 Jul 2005 02:11:27 -0000
@@ -52,6 +52,8 @@
RELOC_NUMBER (R_M32R_SDA16_RELA, 42)
RELOC_NUMBER (R_M32R_RELA_GNU_VTINHERIT, 43)
RELOC_NUMBER (R_M32R_RELA_GNU_VTENTRY, 44)
+
+ RELOC_NUMBER (R_M32R_REL32, 45)
RELOC_NUMBER (R_M32R_GOT24, 48)
RELOC_NUMBER (R_M32R_26_PLTREL, 49)
@@ -70,6 +72,7 @@
RELOC_NUMBER (R_M32R_GOTOFF_HI_ULO, 62)
RELOC_NUMBER (R_M32R_GOTOFF_HI_SLO, 63)
RELOC_NUMBER (R_M32R_GOTOFF_LO, 64)
+
END_RELOC_NUMBERS (R_M32R_max)
/* Processor specific section indices. These sections do not actually
2005-07-20 Kazuhiro Inaoka <inaoka.kazuhiro@renesas.com>
* config/tc-m32r.c (tc_gen_reloc): Check BFD_RELOC_32_PCREL and
BFD_RELOC_16_PCREL to Support R_M32R_REL32.
Index: gas/config/tc-m32r.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m32r.c,v
retrieving revision 1.45
diff -u -r1.45 tc-m32r.c
--- gas/config/tc-m32r.c 8 Jun 2005 14:39:54 -0000 1.45
+++ gas/config/tc-m32r.c 20 Jul 2005 02:12:00 -0000
@@ -2258,6 +2258,17 @@
reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
+
+ if (fixP->fx_pcrel)
+ {
+ if (fixP->fx_r_type == BFD_RELOC_32)
+ fixP->fx_r_type = BFD_RELOC_32_PCREL;
+ else if (fixP->fx_r_type == BFD_RELOC_16)
+ {
+ fixP->fx_r_type = BFD_RELOC_16_PCREL;
+ bfd_set_error (bfd_error_bad_value);
+ }
+ }
code = fixP->fx_r_type;
if (pic_code)
@@ -2327,7 +2338,8 @@
/* Use fx_offset for these cases. */
if ( fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY
- || fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT)
+ || fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
+ || fixP->fx_r_type == BFD_RELOC_32_PCREL)
reloc->addend = fixP->fx_offset;
else if ((!pic_code
&& code != BFD_RELOC_M32R_26_PLTREL)
2005-07-20 Kazuhiro Inaoka <inaoka.kazuhiro@renesas.com>
* gas/m32r/rel32.exp: New file.
* gas/m32r/rel32.s: New file.
* gas/m32r/rel32.d: New file.
* gas/m32r/rel32-pic.s: New file.
* gas/m32r/rel32-pic.d: New file.
* gas/m32r/rel32-err.s: New file.
* gas/m32r/error.exp: Added rel32-err.
Index: error.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/m32r/error.exp,v
retrieving revision 1.2
diff -u -r1.2 error.exp
--- error.exp 17 Dec 2003 09:41:06 -0000 1.2
+++ error.exp 20 Jul 2005 02:06:10 -0000
@@ -10,6 +10,7 @@
dg-runtest "$srcdir/$subdir/interfere.s" "" ""
dg-runtest "$srcdir/$subdir/outofrange.s" "" ""
dg-runtest "$srcdir/$subdir/parallel.s" "" ""
+ dg-runtest "$srcdir/$subdir/rel32-err.s" "" ""
dg-finish
--- /tmp/rel32.exp 1970-01-01 09:00:00.000000000 +0900
+++ rel32.exp 2005-07-20 10:34:45.000000000 +0900
@@ -0,0 +1,6 @@
+# M32R R_M32R_REL32 testcases
+
+if [istarget m32r*-*-*] {
+ run_dump_test "rel32"
+ run_dump_test "rel32-pic"
+}
--- /tmp/rel32.s 1970-01-01 09:00:00.000000000 +0900
+++ rel32.s 2005-07-20 10:41:48.000000000 +0900
@@ -0,0 +1,12 @@
+ .text
+ nop
+ nop
+bar:
+ .section .text2
+ .4byte bar - .
+label:
+ nop
+ nop
+ .4byte bar - label
+ .4byte bar - label2
+label2:
--- /tmp/rel32.d 1970-01-01 09:00:00.000000000 +0900
+++ rel32.d 2005-07-20 10:46:01.000000000 +0900
@@ -0,0 +1,13 @@
+#as:
+#objdump: -r
+#name: rel32
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR \[.text2\]:
+OFFSET TYPE VALUE
+00000000 R_M32R_REL32 .text\+0x00000004
+00000008 R_M32R_REL32 .text\+0x00000008
+0000000c R_M32R_REL32 .text
+
+
--- /tmp/rel32-pic.s 1970-01-01 09:00:00.000000000 +0900
+++ rel32-pic.s 2005-07-20 10:41:58.000000000 +0900
@@ -0,0 +1,12 @@
+ .text
+ nop
+ nop
+bar:
+ .section .text2
+ .4byte bar - .
+label:
+ nop
+ nop
+ .4byte bar - label
+ .4byte bar - label2
+label2:
--- /tmp/rel32-pic.d 1970-01-01 09:00:00.000000000 +0900
+++ rel32-pic.d 2005-07-20 10:45:52.000000000 +0900
@@ -0,0 +1,13 @@
+#as: -KPIC
+#objdump: -r
+#name: rel32-pic
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR \[.text2\]:
+OFFSET TYPE VALUE
+00000000 R_M32R_REL32 .text\+0x00000004
+00000008 R_M32R_REL32 .text\+0x00000008
+0000000c R_M32R_REL32 .text
+
+
--- /tmp/rel32-err.s 1970-01-01 09:00:00.000000000 +0900
+++ rel32-err.s 2005-07-20 10:57:09.000000000 +0900
@@ -0,0 +1,10 @@
+
+; { dg-do assemble { target m32r-*-* } }
+
+ .text
+ nop
+ nop
+bar:
+ .section .text2
+ .2byte bar - . ; { dg-error "can't export reloc type 11" }
+ .byte bar - . ; { dg-error "can\'t export reloc type 7" }