This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 1/4] MIPS/GAS: Fix equated symbols in relaxation
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: binutils at sourceware dot org
- Cc: Richard Sandiford <rdsandiford at googlemail dot com>, Catherine Moore <clm at codesourcery dot com>, gnu-mips-sgxx at codesourcery dot com
- Date: Mon, 26 Jul 2010 11:46:54 +0100 (BST)
- Subject: [PATCH 1/4] MIPS/GAS: Fix equated symbols in relaxation
Hi,
Equated symbols (defined with .eqv) are not yet fully resolved by the
time relaxation is made. As a result, if used in a relaxed expression,
they cause a failure as follows:
branch-self.s:30: Error: attempt to get value of unresolved symbol `fnord'
The fix is to manually walk the chain of symbols; we handle additive
expressions involving constant (positive or negative) addends here only
like elsewhere.
2010-07-26 Maciej W. Rozycki <macro@codesourcery.com>
gas/
* config/tc-mips.c: Include "struc-symbol.h".
(md_convert_frag): Resolve equated symbols manually.
OK to apply?
Maciej
binutils-gas-mips-eqv-relax.diff
Index: binutils-fsf-trunk-quilt/gas/config/tc-mips.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/gas/config/tc-mips.c 2010-07-24 02:25:11.000000000 +0100
+++ binutils-fsf-trunk-quilt/gas/config/tc-mips.c 2010-07-24 02:25:11.000000000 +0100
@@ -28,6 +28,7 @@
#include "config.h"
#include "subsegs.h"
#include "safe-ctype.h"
+#include "struc-symbol.h"
#include "opcode/mips.h"
#include "itbl-ops.h"
@@ -14558,6 +14559,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
unsigned long insn;
bfd_boolean use_extend;
unsigned short extend;
+ symbolS* sym;
type = RELAX_MIPS16_TYPE (fragp->fr_subtype);
op = mips16_immed_operands;
@@ -14575,8 +14577,15 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
ext = FALSE;
}
- resolve_symbol_value (fragp->fr_symbol);
- val = S_GET_VALUE (fragp->fr_symbol);
+ val = 0;
+ sym = fragp->fr_symbol;
+ resolve_symbol_value (sym);
+ while (symbol_equated_p (sym))
+ {
+ val += sym->sy_value.X_add_number;
+ sym = sym->sy_value.X_add_symbol;
+ }
+ val += S_GET_VALUE (sym);
if (op->pcrel)
{
addressT addr;