[v3,3/3] gas: Add macro tests for PR gas/32073

Message ID 20240812151251.2315001-4-hjl.tools@gmail.com
State Superseded
Headers
Series Restore the original macro behaviors |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

H.J. Lu Aug. 12, 2024, 3:12 p.m. UTC
  1. Add a macro test with expression argument and a white space before
argument added by C preprocessor.
2. Add a x86-64 specific macro test.

	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 | 11 +++++++++++
 gas/testsuite/gas/i386/x86-64-macro-1.s |  9 +++++++++
 gas/testsuite/gas/i386/x86-64.exp       |  2 ++
 gas/testsuite/gas/macros/arg1.d         |  7 +++++++
 gas/testsuite/gas/macros/arg1.s         | 12 ++++++++++++
 gas/testsuite/gas/macros/macros.exp     |  2 ++
 6 files changed, 43 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

Jan Beulich Aug. 12, 2024, 3:29 p.m. UTC | #1
On 12.08.2024 17:12, H.J. Lu wrote:
> --- /dev/null
> +++ b/gas/testsuite/gas/macros/arg1.d
> @@ -0,0 +1,7 @@
> +#objdump: -s -j .data
> +
> +.*: .*
> +
> +Contents of section .data:
> + 0000 10111213 1415                        ......          
> +#pass

Despite the #pass, isn't this going to fail for targets which pad sections
to certain alignment? Or was that an issue only with text sections?

> --- /dev/null
> +++ b/gas/testsuite/gas/macros/arg1.s
> @@ -0,0 +1,12 @@
> +# Test expression argument and a white space before argument added by
> +# C preprocessor.

Nit: It's not really "expression" that matters here, but expressions with
inner whitespace.

Jan
  
H.J. Lu Aug. 12, 2024, 3:35 p.m. UTC | #2
On Mon, Aug 12, 2024 at 8:29 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 12.08.2024 17:12, H.J. Lu wrote:
> > --- /dev/null
> > +++ b/gas/testsuite/gas/macros/arg1.d
> > @@ -0,0 +1,7 @@
> > +#objdump: -s -j .data
> > +
> > +.*: .*
> > +
> > +Contents of section .data:
> > + 0000 10111213 1415                        ......
> > +#pass
>
> Despite the #pass, isn't this going to fail for targets which pad sections
> to certain alignment? Or was that an issue only with text sections?

I don't think we pad data section.

> > --- /dev/null
> > +++ b/gas/testsuite/gas/macros/arg1.s
> > @@ -0,0 +1,12 @@
> > +# Test expression argument and a white space before argument added by
> > +# C preprocessor.
>
> Nit: It's not really "expression" that matters here, but expressions with
> inner whitespace.
>
> Jan

Will fix.
  
Alan Modra Aug. 13, 2024, 3:12 a.m. UTC | #3
On Mon, Aug 12, 2024 at 08:35:56AM -0700, H.J. Lu wrote:
> On Mon, Aug 12, 2024 at 8:29 AM Jan Beulich <jbeulich@suse.com> wrote:
> >
> > On 12.08.2024 17:12, H.J. Lu wrote:
> > > --- /dev/null
> > > +++ b/gas/testsuite/gas/macros/arg1.d
> > > @@ -0,0 +1,7 @@
> > > +#objdump: -s -j .data
> > > +
> > > +.*: .*
> > > +
> > > +Contents of section .data:
> > > + 0000 10111213 1415                        ......
> > > +#pass
> >
> > Despite the #pass, isn't this going to fail for targets which pad sections
> > to certain alignment? Or was that an issue only with text sections?
> 
> I don't think we pad data section.

We do, and there are targets that have 2 or 4 octets per byte.  And some
that don't have '#' as a line comment char.  Huh, and tic6x-elf fails
the test with "Error: too many positional arguments".  So not all
targets strip out whitespace.

aarch64-pe  +FAIL: gas/macros/arg1
alpha-linux-gnuecoff  +FAIL: gas/macros/arg1
arm-pe  +FAIL: gas/macros/arg1
arm-wince-pe  +FAIL: gas/macros/arg1
bfin-elf  +FAIL: gas/macros/arg1
bfin-linux-uclibc  +FAIL: gas/macros/arg1
bfin-uclinux  +FAIL: gas/macros/arg1
hppa-hp-hpux10  +FAIL: gas/macros/arg1
i386-bsd  +FAIL: gas/macros/arg1
i386-go32  +FAIL: gas/macros/arg1
i386-msdos  +FAIL: gas/macros/arg1
i686-pe  +FAIL: gas/macros/arg1
mcore-pe  +FAIL: gas/macros/arg1
mips64el-openbsd  +FAIL: gas/macros/arg1
mips64-linux-gnuabi64  +FAIL: gas/macros/arg1
mips64-openbsd  +FAIL: gas/macros/arg1
mipsel-linux-gnu  +FAIL: gas/macros/arg1
mipsisa32el-linux-gnu  +FAIL: gas/macros/arg1
mips-linux-gnu  +FAIL: gas/macros/arg1
mips-sgi-irix6  +FAIL: gas/macros/arg1
powerpc-aix5.1  +FAIL: gas/macros/arg1
powerpc-aix7.2  +FAIL: gas/macros/arg1
rs6000-aix4.3.3  +FAIL: gas/macros/arg1
rs6000-aix5.1  +FAIL: gas/macros/arg1
rs6000-aix7.2  +FAIL: gas/macros/arg1
s390-linux-gnu  +FAIL: gas/macros/arg1
s390x-linux-gnu  +FAIL: gas/macros/arg1
sh-coff  +FAIL: gas/macros/arg1
sh-pe  +FAIL: gas/macros/arg1
tic30-unknown-coff  +FAIL: gas/macros/arg1
tic4x-coff  +FAIL: gas/macros/arg1
tic54x-coff  +FAIL: gas/macros/arg1
tic6x-elf  +FAIL: gas/macros/arg1
x86_64-w64-mingw32  +FAIL: gas/macros/arg1

	* testsuite/gas/macros/arg1.s: Pad out data section.  Use C style
	comments.
	* testsuite/gas/macros/arg1.d: Adjust to suit.  Don't run on
	multi-octet per byte targes.  xfail tic6x.

diff --git a/gas/testsuite/gas/macros/arg1.d b/gas/testsuite/gas/macros/arg1.d
index 0a9d8b10fdb..adb24c9ac65 100644
--- a/gas/testsuite/gas/macros/arg1.d
+++ b/gas/testsuite/gas/macros/arg1.d
@@ -1,7 +1,9 @@
 #objdump: -s -j .data
+# tic30 and tic4x have 4 octets per byte, tic54x has 2 octets per byte
+#notarget: tic30-*-* tic4x-*-* tic54x-*-*
+#xfail: tic6x-*-*
 
 .*: .*
 
 Contents of section .data:
- 0000 10111213 1415                        ......          
-#pass
+ 0000 10111213 14150000 00000000 00000000 .*
diff --git a/gas/testsuite/gas/macros/arg1.s b/gas/testsuite/gas/macros/arg1.s
index e0cb0bddc32..7eecc97f17c 100644
--- a/gas/testsuite/gas/macros/arg1.s
+++ b/gas/testsuite/gas/macros/arg1.s
@@ -1,5 +1,5 @@
-# Test expression argument with inner white spaces and a white space
-# before argument added by C preprocessor.
+/* Test expression argument with inner white spaces and a white space
+   before argument added by C preprocessor.  */
 
 	.macro test arg1, arg2, arg3
 	.byte \arg1
@@ -10,3 +10,4 @@
 	.data
  	test  0x10 + 0, 0x10 + 1, 0x10 + 2
  	test  0x10 + 3, 0x10 + 4, 0x15
+	.byte 0,0,0,0,0,0,0,0,0,0
  

Patch

diff --git a/gas/testsuite/gas/i386/x86-64-macro-1.d b/gas/testsuite/gas/i386/x86-64-macro-1.d
new file mode 100644
index 00000000000..586dbded1a4
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-macro-1.d
@@ -0,0 +1,11 @@ 
+#as: -mrelax-relocations=yes
+#objdump: -dwr
+
+.*: +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
diff --git a/gas/testsuite/gas/i386/x86-64-macro-1.s b/gas/testsuite/gas/i386/x86-64-macro-1.s
new file mode 100644
index 00000000000..20b4416195a
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-macro-1.s
@@ -0,0 +1,9 @@ 
+# Test a white space before argument added by C preprocessor.
+
+	.macro WRAPPER_IMPL_SSE2 callee
+	call *\ callee@GOTPCREL(%rip)
+	.endm
+
+	.text
+_start:
+	WRAPPER_IMPL_SSE2 acos
diff --git a/gas/testsuite/gas/i386/x86-64.exp b/gas/testsuite/gas/i386/x86-64.exp
index a14ed32727f..57cb4aa165a 100644
--- a/gas/testsuite/gas/i386/x86-64.exp
+++ b/gas/testsuite/gas/i386/x86-64.exp
@@ -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"
diff --git a/gas/testsuite/gas/macros/arg1.d b/gas/testsuite/gas/macros/arg1.d
new file mode 100644
index 00000000000..0a9d8b10fdb
--- /dev/null
+++ b/gas/testsuite/gas/macros/arg1.d
@@ -0,0 +1,7 @@ 
+#objdump: -s -j .data
+
+.*: .*
+
+Contents of section .data:
+ 0000 10111213 1415                        ......          
+#pass
diff --git a/gas/testsuite/gas/macros/arg1.s b/gas/testsuite/gas/macros/arg1.s
new file mode 100644
index 00000000000..1833ef24cbb
--- /dev/null
+++ b/gas/testsuite/gas/macros/arg1.s
@@ -0,0 +1,12 @@ 
+# Test expression argument and a white space before argument added by
+# C preprocessor.
+
+	.macro test arg1, arg2, arg3
+	.byte \arg1
+	.byte \arg2
+	.byte \ arg3
+	.endm
+
+	.data
+ 	test  0x10 + 0, 0x10 + 1, 0x10 + 2
+ 	test  0x10 + 3, 0x10 + 4, 0x15
diff --git a/gas/testsuite/gas/macros/macros.exp b/gas/testsuite/gas/macros/macros.exp
index bb5d4abf25b..3e84902c65f 100644
--- a/gas/testsuite/gas/macros/macros.exp
+++ b/gas/testsuite/gas/macros/macros.exp
@@ -75,6 +75,8 @@  if { ![istarget tic30-*-*] } {
     run_list_test app6 ""
 }
 
+run_dump_test arg1
+
 run_list_test badarg ""
 
 switch -glob $target_triplet {