Patch: Allow xstormy16-elf-gas to handle "@fptr() - @fptr()"
Nick Clifton
nickc@redhat.com
Mon May 12 09:08:00 GMT 2003
Hi Guys,
xstormy-elf-gcc can generate an assembler expression that is the
difference of two function pointers that looks like this:
.howrd @fptr(foo) - @fptr(bar).
xstormy-elf-gas however cannot handle this expression and produces a
very strange error message (about an unrecognised case value in a
symbol).
The patch below adds the ability to handle this kind of expression
to xstormy-elf-gas.
Cheers
Nick
2003-05-12 Nick Clifton <nickc@redhat.com>
* config/tc-xstormy16.c (skipping_fptr): New local variable.
(md_assemble): Reset skipping_fptr.
(md_operand): If @fptr() is followed by a minus sign, set
skipping_fptr and ignore the fptr. If skipping_fptr is set and an
@fptr is detected, ignore it and reset skipping_fptr.
Index: gas/config/tc-xstormy16.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xstormy16.c,v
retrieving revision 1.10
diff -c -3 -p -w -r1.10 tc-xstormy16.c
*** gas/config/tc-xstormy16.c 2 May 2003 12:42:13 -0000 1.10
--- gas/config/tc-xstormy16.c 12 May 2003 09:05:33 -0000
*************** md_begin ()
*** 104,109 ****
--- 104,111 ----
cgen_set_parse_operand_fn (gas_cgen_cpu_desc, gas_cgen_parse_operand);
}
+ static bfd_boolean skipping_fptr = FALSE;
+
void
md_assemble (str)
char * str;
*************** md_assemble (str)
*** 111,116 ****
--- 113,122 ----
xstormy16_insn insn;
char * errmsg;
+ /* Make sure that if we had an erroneous input line which triggered
+ the skipping_fptr boolean that it does not affect following lines. */
+ skipping_fptr = FALSE;
+
/* Initialize GAS's cgen interface for a new instruction. */
gas_cgen_init_parse ();
*************** md_operand (e)
*** 154,162 ****
--- 160,187 ----
goto err;
}
input_line_pointer++;
+ SKIP_WHITESPACE ();
if (e->X_op != O_symbol)
as_bad ("Not a symbolic expression");
+ else if (* input_line_pointer == '-')
+ /* We are computing the difference of two function pointers
+ like this:
+
+ .hword @fptr (foo) - @fptr (bar)
+
+ In this situation we do not want to generate O_fptr_symbol
+ operands because the result is an absolute value, not a
+ function pointer.
+
+ We need to make the check here, rather than when the fixup
+ is generated as the function names (foo & bar in the above
+ example) might be local symbols and we want the expression
+ to be evaluated now. This kind of thing can happen when
+ gcc is generating computed gotos. */
+ skipping_fptr = TRUE;
+ else if (skipping_fptr)
+ skipping_fptr = FALSE;
else
e->X_op = O_fptr_symbol;
}
More information about the Binutils
mailing list