[PATCH, gas] PC-relative fx_offset calculation
Fri Mar 1 14:02:00 GMT 2013
Hi, this patch corrects the PC-relative case in write.c:fixup_segment()
where the location of the fix seems to incorrectly use fx_dot_value +
fx_frag->fr_address, rather than fx_where + fx_frag->fr_address.
fx_dot_value actually seems to work most of the time, however in cases
I'm encountering under the nios2 port, the calling of frag_more() before
creating a new fix during assembly sometimes creates a new frag, thus
causing mismatch of fx_dot_value vs. the intra-frag position.
The behavior seems to depend on the point of frag obstack exhaustion, so
I'm afraid I don't have a way to reproduce the error consistently. My
current failing case is pthread_create.c from NPTL, which triggers in
our internal binutils branch, but doesn't happen on a clean binutils
So how does this (one liner) patch look, does the change look sensible?
2013-03-01 Chung-Lin Tang <firstname.lastname@example.org>
* write.c (fixup_segment): Use fx_where instead of fx_dot_value
in computing fx_offset for the pc-relative case.
-------------- next part --------------
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
/* Make it pc-relative. If the back-end code has not
More information about the Binutils