public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
To: Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>
Cc: binutils@sources.redhat.com
Subject: Re: [PATCH] Fix handling of R_MIPS_PC16 relocations
Date: Wed, 12 Sep 2001 08:40:00 -0000	[thread overview]
Message-ID: <Pine.GSO.3.96.1010912171746.3453A-100000@delta.ds2.pg.gda.pl> (raw)
In-Reply-To: <20010907005955.K2210@rembrandt.csv.ica.uni-stuttgart.de>

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        +

  parent reply	other threads:[~2001-09-12  8:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-26 14:30 Thiemo Seufer
2001-09-06 16:00 ` Thiemo Seufer
2001-09-06 21:45   ` Eric Christopher
2001-09-12  8:40   ` Maciej W. Rozycki [this message]
2001-09-12 11:31     ` Thiemo Seufer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.3.96.1010912171746.3453A-100000@delta.ds2.pg.gda.pl \
    --to=macro@ds2.pg.gda.pl \
    --cc=binutils@sources.redhat.com \
    --cc=ica2_ts@csv.ica.uni-stuttgart.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).