gas .macro quirks, and an ARM bug
Ulf Carlsson
ulfc@calypso.engr.sgi.com
Thu Jun 8 12:12:00 GMT 2000
On Thu, 8 Jun 2000, Nick Clifton wrote:
> : > 2) Cannot pass a string argument with escaped characters to macros.
> :
> : I agree that this is weird. The macros don't support expansion of escaped
> : characters in arguments to macros. Escaped characters are just passed on,
> : with one exception for the quote character itself. I think the correct
> : behaviour would be to pass '\"' and '\'' on as an escaped character and not
> : treat them as argument delimiters.
> :
> : 2000-06-07 Ulf Carlsson <ulfc@engr.sgi.com>
> :
> : * macro.c (getstring): Make it possible to escape the quote character.
> :
> : Index: macro.c
> : ===================================================================
> : RCS file: /cvs/src/src/gas/macro.c,v
> : retrieving revision 1.7
> : diff -u -p -r1.7 macro.c
> : --- macro.c 2000/05/01 14:01:06 1.7
> : +++ macro.c 2000/06/07 21:49:26
> : @@ -312,6 +312,12 @@ getstring (idx, in, acc)
> : idx++ ;
> : sb_add_char (acc, in->ptr[idx++]);
> : }
> : + else if (in->ptr[idx] == '\\' && in->ptr[idx+1] == tchar)
> : + {
> : + sb_add_char (acc, '\\');
> : + sb_add_char (acc, tchar);
> : + idx += 2;
> : + }
> : else
> : {
> : if (in->ptr[idx] == tchar)
>
> Actually this does not work since it leaves the \ character in the
> input stream rather than stripping it out. This causes the error
> message:
>
> Error: Rest of line ignored. First ignored character is `\'.
No, this was intentional. The only problem I see with the current
implementation is that you actually can't pass a `\"' through it if you really
want a quote character in your string.
.macro hello narg1
.asciiz "\narg1"
.endm
hello "a quote char: \""
This assembles into
Contents of section .text:
0000 61207175 6f746520 63686172 3a202200 a quote char: ".
Contents of section .data:
You can probably get the same effect by passing `\\"' with your patch, but I
think that's even more obscure since expansion of escape sequences usually
isn't done in arguments to macros. The logical syntax would have been `\\\"'.
Ulf
More information about the Binutils
mailing list