This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Fix handling of R_MIPS_PC16 relocations

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));
+	    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 W. Rozycki, Technical University of Gdansk, Poland   +
+        e-mail:, PGP key available        +

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]