This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH-SH]:Generating proper relocations to link withRenesasSHC linker
- From: "Asgari J. Jinia" <AsgariJ at KPITCummins dot com>
- To: <binutils at sources dot redhat dot com>
- Date: Tue, 30 Mar 2004 19:11:05 +0530
- Subject: Re: [PATCH-SH]:Generating proper relocations to link withRenesasSHC linker
Hi,
Please find below complete patch which adds -renesas-relocs switch
to gas to generate relocations of local symbols against symbol values.
This enables object files generated by GNU assembler with -renesas-relocs
option to be correctly linked with Renesas linker.
Regards,
Asgari Jinia
Patch:
gas/ChangeLog:
2004-03-30 Asgari Jinia <asgarij@kpitcummins.com>
* config/tc-sh.c : Modified md_longopts to add new gas option as -renesas-relocs
Added new variable sh_renesas_relocs.
* config/tc-sh.c (md_parse_option) : Added support for new gas option -renesas-relocs
* config/tc-sh.c (md_show_usage) : Added help string for new gas option -renesas-relocs
* doc/c-sh.text : Added documentation for -renesas-relocs option
2004-03-30 Dhananjay Deshpande <dhananjayd@kpitcummins.com>
* config/tc-sh.c (sh_fix_adjustable) : added test to avoid adjusting relocation of
type BFD_RELOC_32 with -renesas-relocs option.
--- Start of gas patch -------------------
--- gas/config/tc-sh.c.old Mon Mar 29 22:02:28 2004
+++ gas/config/tc-sh.c Tue Mar 30 00:00:16 2004
@@ -163,6 +163,11 @@ int sh_relax; /* set if -relax seen */
int sh_small;
+/* Flag to generate relocations against symbol values
+ for local symbols */
+
+int sh_renesas_relocs;
+
/* preset architecture set, if given; zero otherwise. */
static int preset_target_arch;
@@ -2596,7 +2601,31 @@ s_uses (ignore)
demand_empty_rest_of_line ();
}
+/*
+SH specific options
+-------------------
+* -relax
+ Alter jump instructions for long displacements.
+
+* -big
+ Generate big endian code.
+
+* -little
+ Generate little endian code.
+
+* -small
+ Align sections to 4 byte boundaries, not 16.
+
+* -dsp
+ Enable sh-dsp insns, and disable sh3e / sh4 insns.
+
+* -renesas-relocs
+ Enable gas to generate relocations of local symbols
+ against symbol values.
+*/
+
const char *md_shortopts = "";
+
struct option md_longopts[] =
{
#define OPTION_RELAX (OPTION_MD_BASE)
@@ -2605,6 +2634,7 @@ struct option md_longopts[] =
#define OPTION_SMALL (OPTION_LITTLE + 1)
#define OPTION_DSP (OPTION_SMALL + 1)
#define OPTION_ISA (OPTION_DSP + 1)
+#define OPTION_RENESAS_RELOCS (OPTION_ISA + 1)
{"relax", no_argument, NULL, OPTION_RELAX},
{"big", no_argument, NULL, OPTION_BIG},
@@ -2612,8 +2642,10 @@ struct option md_longopts[] =
{"small", no_argument, NULL, OPTION_SMALL},
{"dsp", no_argument, NULL, OPTION_DSP},
{"isa", required_argument, NULL, OPTION_ISA},
+ {"renesas-relocs",no_argument, NULL, OPTION_RENESAS_RELOCS},
+
#ifdef HAVE_SH64
-#define OPTION_ABI (OPTION_ISA + 1)
+#define OPTION_ABI (OPTION_RENESAS_RELOCS + 1)
#define OPTION_NO_MIX (OPTION_ABI + 1)
#define OPTION_SHCOMPACT_CONST_CRANGE (OPTION_NO_MIX + 1)
#define OPTION_NO_EXPAND (OPTION_SHCOMPACT_CONST_CRANGE + 1)
@@ -2656,6 +2688,10 @@ md_parse_option (c, arg)
preset_target_arch = arch_sh1_up & ~arch_sh3e_up;
break;
+ case OPTION_RENESAS_RELOCS:
+ sh_renesas_relocs = 1;
+ break;
+
case OPTION_ISA:
if (strcasecmp (arg, "sh4") == 0)
preset_target_arch = arch_sh4;
@@ -2734,6 +2770,7 @@ SH options:\n\
-little generate little endian code\n\
-big generate big endian code\n\
-relax alter jump instructions for long displacements\n\
+-renesas-relocs enable relocations of local symbols against symbol \n values. \n\
-small align sections to 4 byte boundaries, not 16\n\
-dsp enable sh-dsp insns, and disable sh2e/sh3e/sh4 insns.\n"));
#ifdef HAVE_SH64
@@ -3286,6 +3323,7 @@ sh_fix_adjustable (fixP)
if (fixP->fx_r_type == BFD_RELOC_32_PLT_PCREL
|| fixP->fx_r_type == BFD_RELOC_32_GOT_PCREL
|| fixP->fx_r_type == BFD_RELOC_SH_GOTPC
+ || ((fixP->fx_r_type == BFD_RELOC_32) && sh_renesas_relocs )
|| fixP->fx_r_type == BFD_RELOC_RVA)
return 0;
--- gas/doc/c-sh.texi.old Wed Jan 7 18:13:01 2004
+++ gas/doc/c-sh.texi Tue Mar 30 00:34:44 2004
@@ -29,6 +29,7 @@
@kindex -relax
@kindex -small
@kindex -dsp
+@kindex -renesas-relocs
@item -little
Generate little endian code.
@@ -44,6 +45,11 @@ Align sections to 4 byte boundaries, not
@item -dsp
Enable sh-dsp insns, and disable sh3e / sh4 insns.
+
+@item -renesas-relocs
+Enable relocations of local symbols against symbol values. This option is
+useful when GNU assembler generated object file is required to be linked
+with Renesas linker.
@end table
--- End of gas patch -------------------
***********************************************************
Testsuite Patch:
gas/testsuite/ChangeLog:
2004-03-30 Asgari Jinia <asgarij@kpitcummins.com>
* gas/sh/basic.exp : Added new test for -renesas-relocs option
--- Start of test suite patch -------------------
--- gas/testsuite/gas/sh/basic.exp.old Wed Mar 31 00:35:46 2004
+++ gas/testsuite/gas/sh/basic.exp Wed Mar 31 00:35:46 2004
@@ -157,6 +157,14 @@ if [istarget sh*-*-*] then {
run_dump_test "tlspic"
run_dump_test "tlsnopic"
+
+ if {[istarget sh*-*elf]} then {
+
+ run_dump_test "renesas_relocs"
+
+ }
+
+
}
}
--- End of test suite patch ----------------------
-------------renesas_relocs.d file ----------------
--- /dev/null Wed May 6 02:02:27 1998
+++ gas/testsuite/gas/sh/renesas_relocs.d Tue Mar 30 23:46:29 2004
@@ -0,0 +1,34 @@
+#objdump: -dr
+#as: -renesas-relocs
+#name: sh renesas relocs tls
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+00000000 <_foo>:
+ 0: 2f e6 [ ]*mov\.l r14,@-r15
+ 2: 6e f3 [ ]*mov r15,r14
+ 4: 6f e3 [ ]*mov r14,r15
+ 6: 6e f6 [ ]*mov\.l @r15\+,r14
+ 8: 00 0b [ ]*rts
+ a: 00 09 [ ]*nop
+
+0000000c <_dummymain>:
+ c: 2f e6 [ ]*mov\.l r14,@-r15
+ e: 4f 22 [ ]*sts\.l pr,@-r15
+ 10: 6e f3 [ ]*mov r15,r14
+ 12: d1 04 [ ]*mov\.l 24 <_dummymain\+0x18>,r1[ ]+! 0x0
+ 14: 41 0b [ ]*jsr @r1
+ 16: 00 09 [ ]*nop
+ 18: 6f e3 [ ]*mov r14,r15
+ 1a: 4f 26 [ ]*lds\.l @r15\+,pr
+ 1c: 6e f6 [ ]*mov\.l @r15\+,r14
+ 1e: 00 0b [ ]*rts
+ 20: 00 09 [ ]*nop
+ 22: 00 09 [ ]*nop
+ 24: 00 00 [ ]*\.word 0x0000
+[ ]+24: R_SH_DIR32 _foo
+ \.\.\.
+
+
-------------------renesas_relocs.s file --------------------------
--- /dev/null Wed May 6 02:02:27 1998
+++ gas/testsuite/gas/sh/renesas_relocs.s Tue Mar 30 23:45:22 2004
@@ -0,0 +1,36 @@
+ .file "foo.c"
+ .text
+ .text
+ .align 1
+ .type _foo, @function
+_foo:
+ mov.l r14,@-r15
+ mov r15,r14
+ mov r14,r15
+ mov.l @r15+,r14
+ rts
+ nop
+ .size _foo, .-_foo
+ .align 1
+ .global _dummymain
+ .type _dummymain, @function
+_dummymain:
+ mov.l r14,@-r15
+ sts.l pr,@-r15
+ mov r15,r14
+ mov.l .L3,r1
+ jsr @r1
+ nop
+ mov r14,r15
+ lds.l @r15+,pr
+ mov.l @r15+,r14
+ rts
+ nop
+.L4:
+ .align 2
+.L3:
+ .long _foo
+ .size _dummymain, .-_dummymain
+ .ident "GCC: (GNU) 3.3-GNUSH_v0401"
+
+