This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH, gas] PC-relative fx_offset calculation
- From: Alan Modra <amodra at gmail dot com>
- To: Chung-Lin Tang <cltang at codesourcery dot com>
- Cc: Binutils <binutils at sourceware dot org>, nickc at redhat dot com
- Date: Mon, 4 Mar 2013 10:34:33 +1030
- Subject: Re: [PATCH, gas] PC-relative fx_offset calculation
- References: <5130B50D.7090201@codesourcery.com>
On Fri, Mar 01, 2013 at 10:02:53PM +0800, Chung-Lin Tang wrote:
> So how does this (one liner) patch look, does the change look sensible?
No, it is not correct. fx_where is supposed to be location of the
field where the fixup is applied. "dot" is not necessarily the same
location. For intstance, given a 4 byte instruction that consists of
a 2 byte opcode followed by a 2 byte offset field, "dot" will point to
the start of the insn but fx_where ought to point at the field.
ie. fx_where = dot + 2. However if you simply had a .short directive
with the same fixup, then both "dot" and fx_where will point to the
same location.
>
> 2013-03-01 Chung-Lin Tang <cltang@codesourcery.com>
>
> gas/
> * write.c (fixup_segment): Use fx_where instead of fx_dot_value
> in computing fx_offset for the pc-relative case.
>
> Index: gas/write.c
> ===================================================================
> RCS file: /cvs/src/src/gas/write.c,v
> retrieving revision 1.154
> diff -u -r1.154 write.c
> --- gas/write.c 4 Feb 2013 12:34:17 -0000 1.154
> +++ gas/write.c 1 Mar 2013 13:56:40 -0000
> @@ -976,7 +976,7 @@
> && !TC_FORCE_RELOCATION_SUB_LOCAL (fixP, add_symbol_segment))
> {
> add_number -= S_GET_VALUE (fixP->fx_subsy);
> - fixP->fx_offset = (add_number + fixP->fx_dot_value
> + fixP->fx_offset = (add_number + fixP->fx_where
> + fixP->fx_frag->fr_address);
>
> /* Make it pc-relative. If the back-end code has not
--
Alan Modra
Australia Development Lab, IBM