From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Maciej W. Rozycki" To: Thiemo Seufer Cc: binutils@sources.redhat.com Subject: Re: [PATCH] Fix handling of R_MIPS_PC16 relocations Date: Wed, 12 Sep 2001 08:40:00 -0000 Message-id: References: <20010907005955.K2210@rembrandt.csv.ica.uni-stuttgart.de> X-SW-Source: 2001-09/msg00212.html 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 +