This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
xstormy2 pcrel reloc fix
- From: DJ Delorie <dj at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Mon, 23 Dec 2002 17:40:40 -0500
- Subject: xstormy2 pcrel reloc fix
xstormy16 was calculating pc-relative relocs wrong. It turns out that
there is one reloc (REL12) that's used for two different *sized*
opcodes, so knowing the reloc alone is insufficient to make the
adjustment. So, I note the adjustment earlier and apply it when
appropriate. I'm running full tests now (and will have to patch the
allinsn testcase of course), but does anyone see a cleaner way to do
this?
Index: tc-xstormy16.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/config/tc-xstormy16.c,v
retrieving revision 1.1.6.2
diff -p -3 -r1.1.6.2 tc-xstormy16.c
*** tc-xstormy16.c 2002/12/20 21:29:33 1.1.6.2
--- tc-xstormy16.c 2002/12/23 22:37:42
*************** md_cgen_lookup_reloc (insn, operand, fix
*** 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;
*************** md_cgen_lookup_reloc (insn, operand, fix
*** 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;
*************** xstormy16_md_apply_fix3 (fixP, valueP, s
*** 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
*************** xstormy16_md_apply_fix3 (fixP, valueP, s
*** 583,589 ****
/* 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;
return 1;
}
--- 592,598 ----
/* 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;
return 1;
}