ld/x86: reduce testsuite dependency on system object files
authorJan Beulich <jbeulich@suse.com>
Tue, 7 Nov 2023 12:58:32 +0000 (13:58 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 7 Nov 2023 12:58:32 +0000 (13:58 +0100)
PR ld/30722
Tests looking for certain .note-section recorded properties may not
involve object files from the underlying platform (e.g. via using the C
compiler for linking): Such object files may themselves have similar
note sections, and hence they may influence the overall outcome.

For now convert just the tests known to be affected by crt*.o coming
with "ISA v3 needed" notes. Eventually other tests ought to be
converted, too.

ld/testsuite/ld-x86-64/property-stk.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/property-x86-1.S [deleted file]
ld/testsuite/ld-x86-64/property-x86-1.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/property-x86-2.S [deleted file]
ld/testsuite/ld-x86-64/property-x86-2.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

diff --git a/ld/testsuite/ld-x86-64/property-stk.s b/ld/testsuite/ld-x86-64/property-stk.s
new file mode 100644 (file)
index 0000000..b3c7c4e
--- /dev/null
@@ -0,0 +1,25 @@
+       .ifdef __64_bit__
+       .equ ALIGN, 3
+       .else
+       .equ ALIGN, 2
+       .endif
+
+       .section ".note.gnu.property", "a"
+       .p2align ALIGN
+       .long 1f - 0f           /* name length.  */
+       .long 3f - 1f           /* data length.  */
+       /* NT_GNU_PROPERTY_TYPE_0 */
+       .long 5                 /* note type.  */
+0:
+       .asciz "GNU"            /* vendor name.  */
+1:
+       .p2align ALIGN
+       /* GNU_PROPERTY_STACK_SIZE */
+       .long 1                 /* pr_type.  */
+       .long 5f - 4f           /* pr_datasz.  */
+4:
+       .dc.a 0x800000          /* Stack size.  */
+5:
+       .p2align ALIGN
+3:
+       .section        .note.GNU-stack
diff --git a/ld/testsuite/ld-x86-64/property-x86-1.S b/ld/testsuite/ld-x86-64/property-x86-1.S
deleted file mode 100644 (file)
index 6d1d8fb..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifdef __LP64__
-# define ALIGN 3
-#else
-# define ALIGN 2
-#endif
-       .section ".note.gnu.property", "a"
-       .p2align ALIGN
-       .long 1f - 0f           /* name length.  */
-       .long 3f - 1f           /* data length.  */
-       /* NT_GNU_PROPERTY_TYPE_0 */
-       .long 5                 /* note type.  */
-0:
-       .asciz "GNU"            /* vendor name.  */
-1:
-       .p2align ALIGN
-       /* GNU_PROPERTY_STACK_SIZE */
-       .long 1                 /* pr_type.  */
-       .long 5f - 4f           /* pr_datasz.  */
-4:
-       .dc.a 0x600000          /* Stack size.  */
-5:
-       .p2align ALIGN
-       /* GNU_PROPERTY_X86_ISA_1_USED */
-       .long 0xc0010002        /* pr_type.  */
-       .long 5f - 4f           /* pr_datasz.  */
-4:
-       .long 0xa
-5:
-       .p2align ALIGN
-       /* GNU_PROPERTY_X86_ISA_1_NEEDED */
-       .long 0xc0008002        /* pr_type.  */
-       .long 5f - 4f           /* pr_datasz.  */
-4:
-       .long 0x3
-5:
-       .p2align ALIGN
-3:
-       .section        .note.GNU-stack
diff --git a/ld/testsuite/ld-x86-64/property-x86-1.s b/ld/testsuite/ld-x86-64/property-x86-1.s
new file mode 100644 (file)
index 0000000..3e3f707
--- /dev/null
@@ -0,0 +1,39 @@
+       .ifdef __64_bit__
+       .equ ALIGN, 3
+       .else
+       .equ ALIGN, 2
+       .endif
+
+       .section ".note.gnu.property", "a"
+       .p2align ALIGN
+       .long 1f - 0f           /* name length.  */
+       .long 3f - 1f           /* data length.  */
+       /* NT_GNU_PROPERTY_TYPE_0 */
+       .long 5                 /* note type.  */
+0:
+       .asciz "GNU"            /* vendor name.  */
+1:
+       .p2align ALIGN
+       /* GNU_PROPERTY_STACK_SIZE */
+       .long 1                 /* pr_type.  */
+       .long 5f - 4f           /* pr_datasz.  */
+4:
+       .dc.a 0x600000          /* Stack size.  */
+5:
+       .p2align ALIGN
+       /* GNU_PROPERTY_X86_ISA_1_USED */
+       .long 0xc0010002        /* pr_type.  */
+       .long 5f - 4f           /* pr_datasz.  */
+4:
+       .long 0xa /* GNU_PROPERTY_X86_ISA_1_V2 | GNU_PROPERTY_X86_ISA_1_V4 */
+5:
+       .p2align ALIGN
+       /* GNU_PROPERTY_X86_ISA_1_NEEDED */
+       .long 0xc0008002        /* pr_type.  */
+       .long 5f - 4f           /* pr_datasz.  */
+4:
+       .long 0x3 /* GNU_PROPERTY_X86_ISA_1_BASELINE | GNU_PROPERTY_X86_ISA_1_V2 */
+5:
+       .p2align ALIGN
+3:
+       .section        .note.GNU-stack
diff --git a/ld/testsuite/ld-x86-64/property-x86-2.S b/ld/testsuite/ld-x86-64/property-x86-2.S
deleted file mode 100644 (file)
index 613d5b2..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifdef __LP64__
-# define ALIGN 3
-#else
-# define ALIGN 2
-#endif
-       .section ".note.gnu.property", "a"
-       .p2align ALIGN
-       .long 1f - 0f           /* name length.  */
-       .long 3f - 1f           /* data length.  */
-       /* NT_GNU_PROPERTY_TYPE_0 */
-       .long 5                 /* note type.  */
-0:
-       .asciz "GNU"            /* vendor name.  */
-1:
-       .p2align ALIGN
-       /* GNU_PROPERTY_X86_ISA_1_USED */
-       .long 0xc0010002        /* pr_type.  */
-       .long 5f - 4f           /* pr_datasz.  */
-4:
-       .long 0x3
-5:
-       .p2align ALIGN
-       /* GNU_PROPERTY_X86_ISA_1_NEEDED */
-       .long 0xc0008002        /* pr_type.  */
-       .long 5f - 4f           /* pr_datasz.  */
-4:
-       .long 0xa
-5:
-       .p2align ALIGN
-3:
-       .section        .note.GNU-stack
diff --git a/ld/testsuite/ld-x86-64/property-x86-2.s b/ld/testsuite/ld-x86-64/property-x86-2.s
new file mode 100644 (file)
index 0000000..2c3b303
--- /dev/null
@@ -0,0 +1,32 @@
+       .ifdef __64_bit__
+       .equ ALIGN, 3
+       .else
+       .equ ALIGN, 2
+       .endif
+
+       .section ".note.gnu.property", "a"
+       .p2align ALIGN
+       .long 1f - 0f           /* name length.  */
+       .long 3f - 1f           /* data length.  */
+       /* NT_GNU_PROPERTY_TYPE_0 */
+       .long 5                 /* note type.  */
+0:
+       .asciz "GNU"            /* vendor name.  */
+1:
+       .p2align ALIGN
+       /* GNU_PROPERTY_X86_ISA_1_USED */
+       .long 0xc0010002        /* pr_type.  */
+       .long 5f - 4f           /* pr_datasz.  */
+4:
+       .long 0x3 /* GNU_PROPERTY_X86_ISA_1_BASELINE | GNU_PROPERTY_X86_ISA_1_V2 */
+5:
+       .p2align ALIGN
+       /* GNU_PROPERTY_X86_ISA_1_NEEDED */
+       .long 0xc0008002        /* pr_type.  */
+       .long 5f - 4f           /* pr_datasz.  */
+4:
+       .long 0xa /* GNU_PROPERTY_X86_ISA_1_V2 | GNU_PROPERTY_X86_ISA_1_V4 */
+5:
+       .p2align ALIGN
+3:
+       .section        .note.GNU-stack
index 3dc8cb47192b8b02a48d158b96576d15dcd8f62b..71ecc92f081deb4720a5f4ce3bfc3ffc1faad0b2 100644 (file)
@@ -1092,86 +1092,6 @@ if { [isnative] && [check_compiler_available] } {
            {{readelf {-n} property-2.r}} \
            "property-2.so" \
        ] \
-       [list \
-           "Build property 3" \
-           "" \
-           "-Wa,-mx86-used-note=yes" \
-           {pass.c property-stack.S property-x86-1.S} \
-           {{readelf {-n} property-3.r}} \
-           "property-3" \
-       ] \
-       [list \
-           "Build property 3 (.o)" \
-           "-r -nostdlib" \
-           "-Wa,-mx86-used-note=yes" \
-           {pass.c property-x86-1.S property-stack.S} \
-           {{readelf {-n} property-3a.r}} \
-           "property-3.o" \
-       ] \
-       [list \
-           "Build property 3 (.so)" \
-           "-shared" \
-           "-fPIC -Wa,-mx86-used-note=yes" \
-           {property-x86-1.S pass.c property-stack.S} \
-           {{readelf {-n} property-3.r}} \
-           "property-3.so" \
-       ] \
-       [list \
-           "Build property 4" \
-           "" \
-           "-Wa,-mx86-used-note=yes" \
-           {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
-           {{readelf {-n} property-4.r}} \
-           "property-4" \
-       ] \
-       [list \
-           "Build property 4 (.o)" \
-           "-r -nostdlib" \
-           "-Wa,-mx86-used-note=yes" \
-           {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
-           {{readelf {-n} property-4a.r}} \
-           "property-4.o" \
-       ] \
-       [list \
-           "Build property 4 (.so)" \
-           "-shared" \
-           "-fPIC -Wa,-mx86-used-note=yes" \
-           {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
-           {{readelf {-n} property-4.r}} \
-           "property-4.so" \
-       ] \
-       [list \
-           "Build property 4 (-Wl,-z,stack-size=0)" \
-           "-Wl,-z,stack-size=0" \
-           "-Wa,-mx86-used-note=yes" \
-           {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
-           {{readelf {-n} property-4.r}} \
-           "property-4" \
-       ] \
-       [list \
-           "Build property 5" \
-           "-Wl,-z,stack-size=0x900000" \
-           "-Wa,-mx86-used-note=yes" \
-           {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
-           {{readelf {-n} property-5.r}} \
-           "property-5" \
-       ] \
-       [list \
-           "Build property 5 (.o)" \
-           "-r -nostdlib -Wl,-z,stack-size=0x900000" \
-           "-Wa,-mx86-used-note=yes" \
-           {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
-           {{readelf {-n} property-5a.r}} \
-           "property-5.o" \
-       ] \
-       [list \
-           "Build property 5 (.so)" \
-           "-shared -Wl,-z,stack-size=0x900000" \
-           "-fPIC -Wa,-mx86-used-note=yes" \
-           {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
-           {{readelf {-n} property-5.r}} \
-           "property-5.so" \
-       ] \
        [list \
            "Build property-6.so" \
            "-shared" \
@@ -2179,6 +2099,96 @@ run_ld_link_tests [list \
        {{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
        "plt2" \
     ] \
+    [list \
+       "Build property 3" \
+       "" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-stk.s property-x86-1.s} \
+       {{readelf -n property-3.r}} \
+       "property-3" \
+    ] \
+    [list \
+       "Build property 3 (.o)" \
+       "-r -nostdlib" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-x86-1.s property-stk.s} \
+       {{readelf -n property-3a.r}} \
+       "property-3.o" \
+    ] \
+    [list \
+       "Build property 3 (.so)" \
+       "-shared" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-x86-1.s property-stk.s} \
+       {{readelf -n property-3.r}} \
+       "property-3.so" \
+    ] \
+    [list \
+       "Build property 4" \
+       "" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-stk.s property-x86-1.s property-x86-2.s} \
+       {{readelf -n property-4.r}} \
+       "property-4" \
+    ] \
+    [list \
+       "Build property 4 (.o)" \
+       "-r -nostdlib" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-x86-2.s property-x86-1.s property-stk.s} \
+       {{readelf {-n} property-4a.r}} \
+       "property-4.o" \
+    ] \
+    [list \
+       "Build property 4 (.so)" \
+       "-shared" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-x86-2.s property-x86-1.s property-stk.s} \
+       {{readelf -n property-4.r}} \
+       "property-4.so" \
+    ] \
+    [list \
+       "Build property 4 (-z stack-size=0)" \
+       "-z stack-size=0" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-stk.s property-x86-1.s property-x86-2.s} \
+       {{readelf -n property-4.r}} \
+       "property-4" \
+    ] \
+    [list \
+       "Build property 5" \
+       "-z stack-size=0x900000" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-stk.s property-x86-1.s property-x86-2.s} \
+       {{readelf -n property-5.r}} \
+       "property-5" \
+    ] \
+    [list \
+       "Build property 5 (.o)" \
+       "-r -nostdlib -z stack-size=0x900000" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-x86-2.s property-x86-1.s property-stk.s} \
+       {{readelf {-n} property-5a.r}} \
+       "property-5.o" \
+    ] \
+    [list \
+       "Build property 5 (.so)" \
+       "-shared -z stack-size=0x900000" \
+       "" \
+       "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+       {property-x86-2.s property-x86-1.s property-stk.s} \
+       {{readelf -n property-5.r}} \
+       "property-5.so" \
+    ] \
     [list \
        "Build pr21626.so" \
        "-shared -melf_x86_64" \