[v2,3/3] gas: Add macro tests for PR gas/32073
Checks
Commit Message
1. Add a macro test with expression argument:
.macro test arg1
.byte \arg1
.endm
.data
test 0x10 + 0
test 0x10 + 1
2. Add a macro test for C preprocessor:
.macro WRAPPER_IMPL_SSE2 callee
call *\ callee@GOTPCREL(%rip)
.endm
.text
_start:
WRAPPER_IMPL_SSE2 acos
PR gas/32073
* testsuite/gas/i386/x86-64-macro-1.d: New file.
* testsuite/gas/i386/x86-64-macro-1.s: Likewise.
* testsuite/gas/i386/x86-64.exp: Run x86-64-macro-1.
* testsuite/gas/macros/arg1.d: New file.
* testsuite/gas/macros/arg1.s: Likewise.
* testsuite/gas/macros/macros.exp: Run arg1.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
gas/testsuite/gas/i386/x86-64-macro-1.d | 12 ++++++++++++
gas/testsuite/gas/i386/x86-64-macro-1.s | 7 +++++++
gas/testsuite/gas/i386/x86-64.exp | 2 ++
gas/testsuite/gas/macros/arg1.d | 8 ++++++++
gas/testsuite/gas/macros/arg1.s | 7 +++++++
gas/testsuite/gas/macros/macros.exp | 2 ++
6 files changed, 38 insertions(+)
create mode 100644 gas/testsuite/gas/i386/x86-64-macro-1.d
create mode 100644 gas/testsuite/gas/i386/x86-64-macro-1.s
create mode 100644 gas/testsuite/gas/macros/arg1.d
create mode 100644 gas/testsuite/gas/macros/arg1.s
Comments
On 12.08.2024 15:26, H.J. Lu wrote:
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/x86-64-macro-1.s
> @@ -0,0 +1,7 @@
> + .macro WRAPPER_IMPL_SSE2 callee
> + call *\ callee@GOTPCREL(%rip)
> + .endm
> +
> + .text
> +_start:
> + WRAPPER_IMPL_SSE2 acos
/If/ we really want such a test (applies similarly to the other one),
then clearly some comment is needed. One shouldn't need to go back to
the commit to find what's going on. (Right here I'm afraid I wouldn't
be able to deduce what these seemingly broken tests are about even
after having read the description).
Plus surely this test doesn't need to be x86-specific. In fact you
could simply fold it into ...
> --- /dev/null
> +++ b/gas/testsuite/gas/macros/arg1.s
> @@ -0,0 +1,7 @@
> + .macro test arg1
> + .byte \arg1
... here, adding a blank after the backslash (plus a comment clarifying
what this is about).
Jan
On Mon, Aug 12, 2024 at 6:51 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 12.08.2024 15:26, H.J. Lu wrote:
> > --- /dev/null
> > +++ b/gas/testsuite/gas/i386/x86-64-macro-1.s
> > @@ -0,0 +1,7 @@
> > + .macro WRAPPER_IMPL_SSE2 callee
> > + call *\ callee@GOTPCREL(%rip)
> > + .endm
> > +
> > + .text
> > +_start:
> > + WRAPPER_IMPL_SSE2 acos
>
> /If/ we really want such a test (applies similarly to the other one),
> then clearly some comment is needed. One shouldn't need to go back to
> the commit to find what's going on. (Right here I'm afraid I wouldn't
> be able to deduce what these seemingly broken tests are about even
> after having read the description).
>
> Plus surely this test doesn't need to be x86-specific. In fact you
> could simply fold it into ...
Since the assembler errors are different:
Error: too many positional arguments
vs
Error: invalid character '\' in operand 1
I will keep the x86-64 test.
>
> > --- /dev/null
> > +++ b/gas/testsuite/gas/macros/arg1.s
> > @@ -0,0 +1,7 @@
> > + .macro test arg1
> > + .byte \arg1
>
> ... here, adding a blank after the backslash (plus a comment clarifying
> what this is about).
I will add it.
> Jan
new file mode 100644
@@ -0,0 +1,12 @@
+#as: -mrelax-relocations=yes
+#objdump: -dwr
+#name: x86-64 macro from C preprocessor
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <_start>:
+ +[a-f0-9]+: ff 15 00 00 00 00 call \*0x0\(%rip\) # 6 <_start\+0x6> 2: R_X86_64_GOTPCRELX acos-0x4
+#pass
new file mode 100644
@@ -0,0 +1,7 @@
+ .macro WRAPPER_IMPL_SSE2 callee
+ call *\ callee@GOTPCREL(%rip)
+ .endm
+
+ .text
+_start:
+ WRAPPER_IMPL_SSE2 acos
@@ -698,6 +698,8 @@ if [is_elf_format] then {
run_dump_test "x86-64-no-got"
+ run_dump_test "x86-64-macro-1"
+
run_dump_test "x86-64-addend"
run_dump_test "x86-64-nop-3"
run_dump_test "x86-64-nop-4"
new file mode 100644
@@ -0,0 +1,8 @@
+#objdump: -s -j .data
+#name expression argument
+
+.*: .*
+
+Contents of section .data:
+ 0000 1011 ..
+#pass
new file mode 100644
@@ -0,0 +1,7 @@
+ .macro test arg1
+ .byte \arg1
+ .endm
+
+ .data
+ test 0x10 + 0
+ test 0x10 + 1
@@ -75,6 +75,8 @@ if { ![istarget tic30-*-*] } {
run_list_test app6 ""
}
+run_dump_test arg1
+
run_list_test badarg ""
switch -glob $target_triplet {