This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: pc-relative relocs on alpha
On Thu, Sep 19, 2002 at 11:16:46PM +0930, Alan Modra wrote:
> The only half reasonable solution I can see is to arrange for
> expression() to save away the current value of dot, which fix_new
> can then save. I'm trying that now, and will run tests overnight.
I suppose someone might like to play with this. Fixes the alpha
problem, but I'm not waiting up to see what else it breaks..
* write.h (struct fix): Add fx_dot_value.
(dot_value): Declare.
* write.c (dot_value): New var.
(fix_new_internal): Save dot_value as fx_dot_value.
* expr.c (expr): Update dot_value.
I'll apply this in the morning if everything pans out OK.
Index: gas/expr.c
===================================================================
RCS file: /cvs/src/src/gas/expr.c,v
retrieving revision 1.43
diff -u -p -r1.43 expr.c
--- gas/expr.c 27 Aug 2002 11:09:42 -0000 1.43
+++ gas/expr.c 19 Sep 2002 14:08:49 -0000
@@ -1656,6 +1656,10 @@ expr (rankarg, resultP)
int op_chars;
know (rank >= 0);
+
+ /* Save the value of dot for the fixup code. */
+ if (rank == 0)
+ dot_value = frag_now_fix ();
retval = operand (resultP);
Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.60
diff -u -p -r1.60 write.c
--- gas/write.c 5 Sep 2002 00:01:15 -0000 1.60
+++ gas/write.c 19 Sep 2002 14:08:52 -0000
@@ -111,6 +111,9 @@ int symbol_table_frozen;
symbolS *abs_section_sym;
+/* Remember the value of dot when parsing expressions. */
+addressT dot_value;
+
void print_fixup PARAMS ((fixS *));
#ifdef BFD_ASSEMBLER
@@ -220,6 +223,7 @@ fix_new_internal (frag, where, size, add
fixP->fx_addsy = add_symbol;
fixP->fx_subsy = sub_symbol;
fixP->fx_offset = offset;
+ fixP->fx_dot_value = dot_value;
fixP->fx_pcrel = pcrel;
fixP->fx_plt = 0;
#if defined(NEED_FX_R_TYPE) || defined (BFD_ASSEMBLER)
@@ -2656,7 +2660,7 @@ fixup_segment (fixP, this_segment)
&& !TC_FORCE_RELOCATION_SUB_LOCAL (fixP))
{
add_number -= S_GET_VALUE (fixP->fx_subsy);
- fixP->fx_offset = add_number;
+ fixP->fx_offset = add_number + fixP->fx_dot_value;
/* Make it pc-relative. If the back-end code has not
selected a pc-relative reloc, cancel the adjustment
Index: gas/write.h
===================================================================
RCS file: /cvs/src/src/gas/write.h,v
retrieving revision 1.7
diff -u -p -r1.7 write.h
--- gas/write.h 5 Sep 2002 00:01:15 -0000 1.7
+++ gas/write.h 19 Sep 2002 14:08:52 -0000
@@ -105,6 +105,9 @@ struct fix
/* Absolute number we add in. */
valueT fx_offset;
+ /* The value of dot when the fixup expression was parsed. */
+ addressT fx_dot_value;
+
/* Next fixS in linked list, or NULL. */
struct fix *fx_next;
@@ -159,6 +162,7 @@ typedef struct fix fixS;
extern int finalize_syms;
extern symbolS *abs_section_sym;
+extern addressT dot_value;
#ifndef BFD_ASSEMBLER
extern char *next_object_file_charP;
--
Alan Modra
IBM OzLabs - Linux Technology Centre