This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] Fix handling of R_MIPS_PC16 relocations
- To: Thiemo Seufer <ica2_ts at csv dot ica dot uni-stuttgart dot de>
- Subject: Re: [PATCH] Fix handling of R_MIPS_PC16 relocations
- From: "Maciej W. Rozycki" <macro at ds2 dot pg dot gda dot pl>
- Date: Wed, 12 Sep 2001 17:43:04 +0200 (MET DST)
- cc: binutils at sources dot redhat dot com
- Organization: Technical University of Gdansk
- Reply-To: "Maciej W. Rozycki" <macro at ds2 dot pg dot gda dot pl>
On Fri, 7 Sep 2001, Thiemo Seufer wrote:
> This patch was wrong. The R_MIPS_PC16 relocation actually spans an
> offset of only 16 bit while the hardware (and internal branches
> without a reloc) can do 18 bit. I have no explanation why this was
> defined this way. The appended patch adds handling for R_MIPS_PC16
> to gas and bfd. Tested for mips64-linux and mips-elf.
It's simply the R_MIPS_PC16 relocation does not shift the address and as
such it is basically useless. The ABI is broken but I think we should
either stick to it as is or fix it first.
I don't think the following bit is OK -- you've just defined
BFD_RELOC_16_PCREL to behave just like BFD_RELOC_16_PCREL_S2 would:
diff -BurpNX /bigdisk/src/binutils-exclude src-orig/gas/config/tc-mips.c src/gas/config/tc-mips.c
--- src-orig/gas/config/tc-mips.c Fri Aug 31 22:00:08 2001
+++ src/gas/config/tc-mips.c Thu Sep 6 21:58:05 2001
@@ -1898,6 +1978,10 @@ append_insn (place, ip, address_expr, re
| ((address_expr->X_add_number & 0x3fffc) >> 2));
break;
+ case BFD_RELOC_16_PCREL:
+ ip->insn_opcode |= (address_expr->X_add_number >> 2) & 0xffff;
+ break;
+
case BFD_RELOC_16_PCREL_S2:
goto need_reloc;
You'd do something like "ip->insn_opcode |= address_expr->X_add_number &
0xffff" for a BFD_RELOC_16_PCREL reloc.
Maciej
--
+ Maciej W. Rozycki, Technical University of Gdansk, Poland +
+--------------------------------------------------------------+
+ e-mail: macro@ds2.pg.gda.pl, PGP key available +