[PATCH] gas: correct .irpc handling with empty string
Bernhard Übelacker
bernhardu@mailbox.org
Wed Aug 14 13:30:59 GMT 2024
Am 12.08.24 um 16:50 schrieb Jan Beulich:
> Following 69cab370cf66 ("gas: adjust handling of quotes for .irpc") the
> closing quote was mistakenly treated as the first quoted character.
> ---
> I recall wondering about the lack of "continue" there. Yet I wrongly
> concluded that since there was none, there also shouldn't be any.
>
> --- a/gas/macro.c
> +++ b/gas/macro.c
> @@ -1389,6 +1389,7 @@ expand_irp (int irpc, size_t idx, sb *in
> if (idx >= in->len)
> break;
> }
> + continue;
> }
> sb_reset (&f.actual);
> sb_add_char (&f.actual, in->ptr[idx]);
> --- a/gas/testsuite/gas/macros/irpc-quote.s
> +++ b/gas/testsuite/gas/macros/irpc-quote.s
> @@ -1,6 +1,6 @@
> - .irpc c, " ab" cd " ef"
> + .irpc c, " ab" cd " ef" ""
> .print ">\c<"
> .endr
> - .irpc c, "12 " 34 "56 "
> + .irpc c, "" "12 " 34 "56 "
> .print ">\c<"
> .endr
Hello Jan,
I am not sure if this patch should handle the issue in the Debian bug completely.
At least I tested current git with your patch applied, but the issue seems still visible.
For convenience I tried to put a minimal reproducer together [1].
In [2] is the example output of an working version 2.42.
In [3] the output of current git with your patch.
It still shows the warning messages.
And it seems the parameter string_a is seen like it contains 0x0a.
Kind regards,
Bernhard
[1]
$ git diff --cached
diff --git a/gas/testsuite/gas/macros/irpc-nested-macro.d b/gas/testsuite/gas/macros/irpc-nested-macro.d
new file mode 100644
index 00000000000..38214ac730b
--- /dev/null
+++ b/gas/testsuite/gas/macros/irpc-nested-macro.d
@@ -0,0 +1,6 @@
+#objdump: -s -j .data
+
+.*: .*
+
+Contents of section .data:
+ 0000 61002000 62000000 a. .b...
diff --git a/gas/testsuite/gas/macros/irpc-nested-macro.s b/gas/testsuite/gas/macros/irpc-nested-macro.s
new file mode 100644
index 00000000000..c31e027e487
--- /dev/null
+++ b/gas/testsuite/gas/macros/irpc-nested-macro.s
@@ -0,0 +1,19 @@
+/*
+rm -f irpc-nested-macro.o
+i686-w64-mingw32-as -o irpc-nested-macro.o irpc-nested-macro.s
+i686-w64-mingw32-objdump -s -j .data irpc-nested-macro.o | tee dump.out
+*/
+
+.macro macro2 string_c
+.irpc char_c,"\string_c"
+.asciz "\char_c"
+.endr
+.endm
+
+.macro macro1 string_a="", string_b=""
+macro2 "\string_a"
+macro2 "\string_b"
+.endm
+
+.data
+macro1 string_b="a b"
$
[2]
$ rm -f irpc-nested-macro.o
$ i686-w64-mingw32-as -o irpc-nested-macro.o irpc-nested-macro.s
$ i686-w64-mingw32-objdump -s -j .data irpc-nested-macro.o | tee dump_2.42-4+11.5.out
irpc-nested-macro.o: file format pe-i386
Contents of section .data:
0000 61002000 62000000 a. .b...
$ i686-w64-mingw32-as --version
GNU assembler (GNU Binutils) 2.42
...
$
[3]
$ rm -f irpc-nested-macro.o
$ ../../../as-new -o irpc-nested-macro.o irpc-nested-macro.s
irpc-nested-macro.s: Assembler messages:
irpc-nested-macro.s:19: Warning: end of file in string; '"' inserted
irpc-nested-macro.s:14: Info: macro invoked from here
irpc-nested-macro.s:19: Info: macro invoked from here
irpc-nested-macro.s:9: Warning: unterminated string; newline inserted
irpc-nested-macro.s:14: Info: macro invoked from here
irpc-nested-macro.s:19: Info: macro invoked from here
$ i686-w64-mingw32-objdump -s -j .data irpc-nested-macro.o | tee dump_git+patch.out
irpc-nested-macro.o: file format pe-i386
Contents of section .data:
0000 0a006100 20006200 ..a. .b.
$ ../../../as-new --version
GNU assembler (GNU Binutils) 2.43.50.20240814
...
$
More information about the Binutils
mailing list