This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: gas .macro quirks, and an ARM bug
- To: Nick Clifton <nickc at cygnus dot com>
- Subject: Re: gas .macro quirks, and an ARM bug
- From: Ulf Carlsson <ulfc at calypso dot engr dot sgi dot com>
- Date: Thu, 8 Jun 2000 14:20:03 -0700 (PDT)
- Cc: andrewm at netwinder dot org, binutils at sourceware dot cygnus dot com
Hi Nick,
> : 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 `\\\"'.
>
> Good point. OK I agree that your patch is the correct solution,
> although we still need to add one small extra test, to make sure that
> the character following the backslash is actually present:
Forget my last mail. I wasn't thinking and things were a bit more complicated
than I first thought. This patch can assemble
.macro hello narg1
.asciiz "\narg1"
.endm
hello " \\\"foo\\\""
into this
ontents of section .text:
0000 205c2266 6f6f5c22 00000000 00000000 \"foo\"........
Contents of section .data:
Ulf
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/08 21:14:23
@@ -304,13 +304,24 @@ getstring (idx, in, acc)
else if (in->ptr[idx] == '"' || in->ptr[idx] == '\'')
{
char tchar = in->ptr[idx];
+ int escaped = 0;
idx++;
while (idx < in->len)
{
+ if (in->ptr[idx-1] == '\\')
+ escaped ^= 1;
+ else
+ escaped = 0;
+
if (macro_alternate && in->ptr[idx] == '!')
{
idx++ ;
sb_add_char (acc, in->ptr[idx++]);
+ }
+ else if (escaped && in->ptr[idx] == tchar)
+ {
+ sb_add_char (acc, tchar);
+ idx++;
}
else
{