Patch to fix FRV branch relocs
Richard Sandiford
rsandifo@redhat.com
Fri Aug 29 16:47:00 GMT 2003
frv gas generates the following relocs for the attached test case:
R_FRV_LABEL24 f1+0xffffffec
R_FRV_LABEL16 f1+0xffffffe8
i.e.: the addend is the difference between the pc and the target.
Patch tested on frv-elf. OK to install?
gas/
* config/tc-frv.c (md_pcrel_from_section): Heed TC_FORCE_RELOCATION.
gas/testsuite/
* gas/frv/reloc1.[sd]: New test.
* gas/frv/allinsn.exp: Run it.
Index: gas/config/tc-frv.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-frv.c,v
retrieving revision 1.7
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.7 tc-frv.c
*** gas/config/tc-frv.c 21 May 2003 12:07:55 -0000 1.7
--- gas/config/tc-frv.c 29 Aug 2003 16:34:33 -0000
*************** md_convert_frag (abfd, sec, fragP)
*** 1164,1179 ****
long
md_pcrel_from_section (fixP, sec)
fixS * fixP;
! segT sec;
{
! if (fixP->fx_addsy != (symbolS *) NULL
! && (! S_IS_DEFINED (fixP->fx_addsy)
! || S_GET_SEGMENT (fixP->fx_addsy) != sec))
! {
! /* The symbol is undefined (or is defined but not in this section).
! Let the linker figure it out. */
! return 0;
! }
return (fixP->fx_frag->fr_address + fixP->fx_where) & ~1;
}
--- 1164,1174 ----
long
md_pcrel_from_section (fixP, sec)
fixS * fixP;
! segT sec ATTRIBUTE_UNUSED;
{
! /* Make no adjustment for relocations that will be written out. */
! if (TC_FORCE_RELOCATION (fixP))
! return 0;
return (fixP->fx_frag->fr_address + fixP->fx_where) & ~1;
}
Index: gas/testsuite/gas/frv/allinsn.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/frv/allinsn.exp,v
retrieving revision 1.1
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.1 allinsn.exp
*** gas/testsuite/gas/frv/allinsn.exp 18 Jun 2002 21:14:45 -0000 1.1
--- gas/testsuite/gas/frv/allinsn.exp 29 Aug 2003 16:34:33 -0000
***************
*** 2,5 ****
--- 2,6 ----
if [istarget frv*-*-*] {
run_dump_test "allinsn"
+ run_dump_test "reloc1"
}
*** /dev/null Tue Jun 17 23:06:41 2003
--- gas/testsuite/gas/frv/reloc1.d Fri Aug 29 17:45:32 2003
***************
*** 0 ****
--- 1,21 ----
+ #objdump: -dr
+
+ .* elf32-frv
+
+ Disassembly.*:
+
+ .* <begin>:
+ .*: 80 88 00 00 * nop
+ .*: 80 88 00 00 * nop
+ .* <f1>:
+ .*: 80 88 00 00 * nop
+ .*: 80 88 00 00 * nop
+ .*: 80 88 00 00 * nop
+ .* <f2>:
+ .*: 80 3c 00 00 * call.*
+ .*: R_FRV_LABEL24 f1
+ .*: c0 1a 00 00 * bra.*
+ .*: R_FRV_LABEL16 f1
+ .*: fe 3f ff fe * call .* <f2>
+ .*: c0 1a ff fd * bra .* <f2>
+ \.\.\.
*** /dev/null Tue Jun 17 23:06:41 2003
--- gas/testsuite/gas/frv/reloc1.s Fri Aug 29 17:39:00 2003
***************
*** 0 ****
--- 1,14 ----
+ .globl f1
+ begin:
+ nop
+ nop
+ f1:
+ nop
+ nop
+ nop
+ f2:
+ call f1
+ bra f1
+ call f2
+ bra f2
+ .space 16
More information about the Binutils
mailing list