This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: xstormy2 pcrel reloc fix
- From: DJ Delorie <dj at redhat dot com>
- To: nickc at redhat dot com
- Cc: geoffk at geoffk dot org, binutils at sources dot redhat dot com
- Date: Tue, 7 Jan 2003 16:28:22 -0500
- Subject: Re: xstormy2 pcrel reloc fix
- References:
> In which case, please consider your patch approved.
Thanks!
Here is the final patch as applied. I had forgotten about the
partial_inplace change, but it's obviously needed (the LSB isn't
stored in the opcode, and gas/tc-xstormy16.c mentions that this isn't
a RELA port (and thus not partial_inplace) but random bits end up in
the opcode anyway with partial_inplace).
Index: bfd/ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.1876
diff -c -3 -r1.1876 bfd/ChangeLog
*** bfd/ChangeLog 7 Jan 2003 13:12:34 -0000 1.1876
--- bfd/ChangeLog 7 Jan 2003 21:21:32 -0000
***************
*** 1,3 ****
--- 1,8 ----
+ 2003-01-07 DJ Delorie <dj@redhat.com>
+
+ * elf32-xstormy16.c (xstormy16_elf_howto_table): Make REL_12 not
+ partial_inplace.
+
2003-01-07 Andreas Schwab <schwab@suse.de>
* elf32-m68k.c (elf_m68k_check_relocs): Don't set DF_TEXTREL for
Index: bfd/elf32-xstormy16.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xstormy16.c,v
retrieving revision 1.15
diff -c -3 -r1.15 bfd/elf32-xstormy16.c
*** bfd/elf32-xstormy16.c 20 Dec 2002 21:13:19 -0000 1.15
--- bfd/elf32-xstormy16.c 7 Jan 2003 21:21:32 -0000
***************
*** 174,180 ****
complain_overflow_signed, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_XSTORMY16_REL_12", /* name */
! TRUE, /* partial_inplace */
0, /* src_mask */
0x0fff, /* dst_mask */
TRUE), /* pcrel_offset */
--- 174,180 ----
complain_overflow_signed, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_XSTORMY16_REL_12", /* name */
! FALSE, /* partial_inplace */
0, /* src_mask */
0x0fff, /* dst_mask */
TRUE), /* pcrel_offset */
Index: gas/ChangeLog
===================================================================
RCS file: /cvs/src/src/gas/ChangeLog,v
retrieving revision 1.1639
diff -c -3 -r1.1639 gas/ChangeLog
*** gas/ChangeLog 3 Jan 2003 21:47:19 -0000 1.1639
--- gas/ChangeLog 7 Jan 2003 21:26:56 -0000
***************
*** 1,3 ****
--- 1,9 ----
+ 2003-01-07 DJ Delorie <dj@redhat.com>
+
+ * config/tc-xstormy16.c (md_cgen_lookup_reloc): Adjust value based
+ on operand type.
+ (xstormy16_md_apply_fix3): Use adjustment.
+
2003-01-02 Ben Elliston <bje@redhat.com>
* configure.in: Add iq2000-elf target.
Index: gas/config/tc-xstormy16.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xstormy16.c,v
retrieving revision 1.7
diff -c -3 -r1.7 gas/config/tc-xstormy16.c
*** gas/config/tc-xstormy16.c 20 Dec 2002 21:14:20 -0000 1.7
--- gas/config/tc-xstormy16.c 7 Jan 2003 21:21:32 -0000
***************
*** 352,359 ****
case XSTORMY16_OPERAND_ABS24:
return BFD_RELOC_XSTORMY16_24;
- case XSTORMY16_OPERAND_REL8_2:
case XSTORMY16_OPERAND_REL8_4:
fixP->fx_pcrel = 1;
return BFD_RELOC_8_PCREL;
--- 352,361 ----
case XSTORMY16_OPERAND_ABS24:
return BFD_RELOC_XSTORMY16_24;
case XSTORMY16_OPERAND_REL8_4:
+ fixP->fx_addnumber -= 2;
+ case XSTORMY16_OPERAND_REL8_2:
+ fixP->fx_addnumber -= 2;
fixP->fx_pcrel = 1;
return BFD_RELOC_8_PCREL;
***************
*** 361,366 ****
--- 363,369 ----
fixP->fx_where += 2;
/* Fall through... */
case XSTORMY16_OPERAND_REL12A:
+ fixP->fx_addnumber -= 2;
fixP->fx_pcrel = 1;
return BFD_RELOC_XSTORMY16_REL_12;
***************
*** 423,428 ****
--- 426,437 ----
/* Canonical name, since used a lot. */
CGEN_CPU_DESC cd = gas_cgen_cpu_desc;
+ /* md_cgen_lookup_reloc() will adjust this to compensate for where
+ in the opcode the relocation happens, for pcrel relocations. We
+ have no other way of keeping track of what this offset needs to
+ be. */
+ fixP->fx_addnumber = 0;
+
/* This port has pc-relative relocs and DIFF_EXPR_OK defined, so
it must deal with turning a BFD_RELOC_{8,16,32,64} into a
BFD_RELOC_*_PCREL for the case of
***************
*** 556,562 ****
/* Tuck `value' away for use by tc_gen_reloc.
See the comment describing fx_addnumber in write.h.
This field is misnamed (or misused :-). */
! fixP->fx_addnumber = value;
}
--- 565,571 ----
/* Tuck `value' away for use by tc_gen_reloc.
See the comment describing fx_addnumber in write.h.
This field is misnamed (or misused :-). */
! fixP->fx_addnumber += value;
}
Index: gas/testsuite/ChangeLog
===================================================================
RCS file: /cvs/src/src/gas/testsuite/ChangeLog,v
retrieving revision 1.428
diff -c -3 -r1.428 gas/testsuite/ChangeLog
*** gas/testsuite/ChangeLog 3 Jan 2003 21:38:49 -0000 1.428
--- gas/testsuite/ChangeLog 7 Jan 2003 21:21:33 -0000
***************
*** 1,3 ****
--- 1,7 ----
+ 2003-01-07 DJ Delorie <dj@redhat.com>
+
+ * gas/xstormy16/reloc-2.d: Adjust for fixed REL12 relocs.
+
2003-01-02 Jeff Johnston <jjohnstn@redhat.com>
* gas/iq2000: New testsuite.
Index: gas/testsuite/gas/xstormy16/reloc-2.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/xstormy16/reloc-2.d,v
retrieving revision 1.1
diff -c -3 -r1.1 gas/testsuite/gas/xstormy16/reloc-2.d
*** gas/testsuite/gas/xstormy16/reloc-2.d 8 Dec 2001 03:45:58 -0000 1.1
--- gas/testsuite/gas/xstormy16/reloc-2.d 7 Jan 2003 21:21:33 -0000
***************
*** 27,39 ****
30: 00 79 00 00 mov\.w 0x0,#0x0
32: R_XSTORMY16_16 global
34: fe d0 bge 0x34
! 34: R_XSTORMY16_PC8 global
36: fc c0 00 00 bge Rx,#0x0,0x36
! 36: R_XSTORMY16_PC8 global
3a: 00 0d fc 0f bge r0,r0,0x3a
! 3c: R_XSTORMY16_REL_12 global
3e: fe 1f br 0x3e
! 3e: R_XSTORMY16_REL_12 global
40: 0a d0 bge 0x4c
42: 06 c0 00 00 bge Rx,#0x0,0x4c
46: 00 0d 02 00 bge r0,r0,0x4c
--- 27,39 ----
30: 00 79 00 00 mov\.w 0x0,#0x0
32: R_XSTORMY16_16 global
34: fe d0 bge 0x34
! 34: R_XSTORMY16_PC8 global\+0xfffffffe
36: fc c0 00 00 bge Rx,#0x0,0x36
! 36: R_XSTORMY16_PC8 global\+0xfffffffc
3a: 00 0d fc 0f bge r0,r0,0x3a
! 3c: R_XSTORMY16_REL_12 global\+0xfffffffe
3e: fe 1f br 0x3e
! 3e: R_XSTORMY16_REL_12 global\+0xfffffffe
40: 0a d0 bge 0x4c
42: 06 c0 00 00 bge Rx,#0x0,0x4c
46: 00 0d 02 00 bge r0,r0,0x4c