Remove perror from ld_assemble, ld_compile and ld_nm
[deliverable/binutils-gdb.git] / ld / testsuite / ld-x86-64 / x86-64.exp
index 408e52a9f26171a6630f7be1b45e29a8acb63e80..6bd1f123317ee1299e848e306988ba65b8368df8 100644 (file)
@@ -1,5 +1,5 @@
 # Expect script for ld-x86_64 tests
-#   Copyright (C) 2002-2019 Free Software Foundation, Inc.
+#   Copyright (C) 2002-2020 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -34,7 +34,6 @@ if [istarget "*-*-nacl*"] {
     set emul "elf_x86_64"
 }
 
-global ASFLAGS
 set saved_ASFLAGS "$ASFLAGS"
 set ASFLAGS "$ASFLAGS -mx86-used-note=no"
 
@@ -212,9 +211,12 @@ set x86_64tests {
      "--64" { pr19827a.S }}
     {"Build pr19827b.so" "-melf_x86_64 -shared" ""
      "--64" { pr19827b.S } {} "pr19827b.so"}
-    {"Build pr19827" "-melf_x86_64 -pie tmpdir/pr19827a.o tmpdir/pr19827b.so" ""
+    {"Build pr19827"
+     "-melf_x86_64 -pie -z notext tmpdir/pr19827a.o tmpdir/pr19827b.so"
+     ""
      "--64" { dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"}
-    {"Build pr19827.so" "-melf_x86_64 -shared -Bsymbolic" ""
+    {"Build pr19827.so"
+     "-melf_x86_64 -shared -Bsymbolic -z notext" ""
      "--64" { pr19827a.S }  {{readelf {-rW} pr19827.rd}} "pr19827.so"}
     {"Build pr19969.so" "-melf_x86_64 -shared" ""
      "--64" { pr19969a.S } {} "pr19969.so"}
@@ -222,7 +224,9 @@ set x86_64tests {
      "--64" { pr20550a.s }}
     {"Build pr20550b.so" "-melf_x86_64 -shared" ""
      "--64" { pr20550b.s } {} "pr20550b.so"}
-    {"Build pr20550" "-melf_x86_64 -pie tmpdir/pr20550a.o tmpdir/pr20550b.so" ""
+    {"Build pr20550"
+     "-melf_x86_64 -pie -z notext tmpdir/pr20550a.o tmpdir/pr20550b.so"
+     ""
      "--64" { dummy.s } {} "pr20550"}
 }
 
@@ -260,9 +264,6 @@ if [istarget "*-*-nacl*"] {
 
 run_ld_link_tests $x86_64tests
 
-global link_output
-global ld
-
 set test_name "Mixed x86_64 and i386 input test 1"
 set test mixed1
 if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
@@ -450,38 +451,56 @@ run_dump_test "pr24322a"
 run_dump_test "pr24322a-x32"
 run_dump_test "pr24322b"
 run_dump_test "pr24322b-x32"
+run_dump_test "pr24458a"
+run_dump_test "pr24458a-x32"
+run_dump_test "pr24458b"
+run_dump_test "pr24458b-x32"
+run_dump_test "pr24458c"
+run_dump_test "pr24458c-x32"
+run_dump_test "pr24721"
+run_dump_test "pr24721-x32"
+run_dump_test "pr24905"
+run_dump_test "pr24905-x32"
+run_dump_test "align-branch-1"
+run_dump_test "pr25416-1a"
+run_dump_test "pr25416-2b"
+run_dump_test "pr25416-2a"
+run_dump_test "pr25416-2b"
+run_dump_test "pr25416-3"
+run_dump_test "pr25416-4"
+run_dump_test "pr26018"
 
 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
     return
 }
 
 if ![ld_assemble $as "--x32 $srcdir/$subdir/start.s" tmpdir/startx32.o] {
-    unresolved "Build ILP32 start.o"
+    fail "Build ILP32 start.o"
     return
 }
 
 if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
-    unresolved "Build ia32 start.o"
+    fail "Build ia32 start.o"
     return
 }
 
 if ![ld_assemble $as "--64 $srcdir/$subdir/start.s" tmpdir/start64.o] {
-    unresolved "Build LP64 start.o"
+    fail "Build LP64 start.o"
     return
 }
 
 if ![ld_assemble $as "--x32 $srcdir/$subdir/foo.s" tmpdir/foox32.o] {
-    unresolved "Build ILP32 foo.o"
+    fail "Build ILP32 foo.o"
     return
 }
 
 if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
-    unresolved "Build ia32 foo.o"
+    fail "Build ia32 foo.o"
     return
 }
 
 if ![ld_assemble $as "--64 $srcdir/$subdir/foo.s" tmpdir/foo64.o] {
-    unresolved "Build LP64 foo.o"
+    fail "Build LP64 foo.o"
     return
 }
 
@@ -560,7 +579,12 @@ run_dump_test "pr17935-1"
 run_dump_test "pr17935-2"
 run_dump_test "pr18160"
 run_dump_test "pr18176"
-run_dump_test "pr18801"
+run_dump_test "pr18801a"
+run_dump_test "pr18801b"
+run_dump_test "ifunc-textrel-1a"
+run_dump_test "ifunc-textrel-1b"
+run_dump_test "ifunc-textrel-2a"
+run_dump_test "ifunc-textrel-2b"
 run_dump_test "pr18815"
 run_dump_test "pr19013"
 run_dump_test "pr19013-x32"
@@ -718,17 +742,15 @@ proc undefined_weak {cflags ldflags} {
     }
 }
 
-# Add $PLT_CFLAGS if PLT is expected.
-global PLT_CFLAGS
-# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-
 # Must be native with the C compiler
-if { [isnative] && [which $CC] != 0 } {
-    run_cc_link_tests {
-       {"Helper X32 DSO from x86-64 object" "" "-m64 -fPIC -g"
-        {simple.c} {} "libsimple.a"}
-    }
+if { [isnative] && [check_compiler_available] } {
+    run_cc_link_tests [list \
+       [list \
+           "Helper X32 DSO from x86-64 object" "" \
+           "-m64 $NOSANTIZE_CFLAGS -fPIC -g" \
+           {simple.c} {} "libsimple.a" \
+       ] \
+    ]
 
     set convertx32 "$objcopy -O elf32-x86-64 tmpdir/simple.o tmpdir/simple-x32.o"
     send_log "$convertx32\n"
@@ -739,12 +761,16 @@ if { [isnative] && [which $CC] != 0 } {
        return
     }
 
-    run_ld_link_tests {
-       {"X32 DSO from x86-64 object"
-        "-shared -melf32_x86_64 tmpdir/simple-x32.o" ""
-        "--x32 -mx86-used-note=yes"
-       {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} "x86-64-x32"}
-    }
+    run_ld_link_tests [list \
+       [list \
+           "X32 DSO from x86-64 object" \
+           "-shared -melf32_x86_64 tmpdir/simple-x32.o" \
+           "$NOSANTIZE_CFLAGS" \
+           "--x32 -mx86-used-note=yes" \
+           {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} \
+           "x86-64-x32" \
+       ] \
+    ]
 
     run_cc_link_tests [list \
        [list \
@@ -1151,7 +1177,7 @@ if { [isnative] && [which $CC] != 0 } {
        ] \
        [list \
            "Build pr22001-1a" \
-           "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+           "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
            "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
            { pr22001-1b.c } \
            {{error_output "pr22001-1a.err"}} \
@@ -1167,7 +1193,7 @@ if { [isnative] && [which $CC] != 0 } {
        ] \
        [list \
            "Build pr21997-1a" \
-           "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+           "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
            "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
            { pr21997-1b.c } \
            {{error_output "pr21997-1a.err"}} \
@@ -1242,7 +1268,7 @@ if { [isnative] && [which $CC] != 0 } {
        ] \
        [list \
            "Build pr22791-1" \
-           "-pie -Wl,--no-as-needed tmpdir/pr22791-1.so" \
+           "-pie -Wl,--no-as-needed,-z,notext tmpdir/pr22791-1.so" \
            "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
            { pr22791-1b.s } \
            {{error_output "pr22791-1.err"}} \
@@ -1290,10 +1316,55 @@ if { [isnative] && [which $CC] != 0 } {
     ]
 
     if  {[istarget "x86_64-*-linux*-gnux32"]} {
+       run_cc_link_tests [list \
+           [list \
+               "Build pr25416-5b.o (GDesc -maddress-mode=short)" \
+               "" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5b.s } \
+           ] \
+           [list \
+               "Build pr25416-5b.so (GDesc -> IE -maddress-mode=short)" \
+               "-shared" \
+               "-fPIC -Wa,-mx86-used-note=yes" \
+               { pr25416-5b.s pr25416-5d.s } \
+               {} \
+               "pr25416-5b.so" \
+           ] \
+           [list \
+               "Build pr25416-5c.o (GDesc -maddress-mode=long)" \
+               "" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5c.s } \
+           ] \
+           [list \
+               "Build pr25416-5c.so (GDesc -> IE -maddress-mode=long)" \
+               "-shared" \
+               "-fPIC -Wa,-mx86-used-note=yes" \
+               { pr25416-5c.s pr25416-5d.s } \
+               {} \
+               "pr25416-5c.so" \
+           ] \
+           [list \
+               "Build pr25416-5d.so (GDesc -maddress-mode=short)" \
+               "-shared" \
+               "-fPIC -Wa,-mx86-used-note=yes" \
+               { pr25416-5b.s pr25416-5e.s } \
+               {} \
+               "pr25416-5d.so" \
+           ] \
+           [list \
+               "Build pr25416-5d.o (IE -maddress-mode=short)" \
+               "" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5d.s } \
+           ] \
+       ]
+
        run_ld_link_exec_tests [list \
            [list \
                "Run pr22001-1b" \
-               "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+               "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
                "-Wa,-mx86-used-note=yes" \
                { pr22001-1c.c } \
                "pr22001-1b" \
@@ -1302,19 +1373,80 @@ if { [isnative] && [which $CC] != 0 } {
            ] \
            [list \
                "Run pr21997-1b" \
-               "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+               "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
                "-Wa,-mx86-used-note=yes" \
                { pr21997-1c.c } \
                "pr21997-1b" \
                "pass.out" \
                "$NOPIE_CFLAGS" \
            ] \
+           [list \
+               "Run pr25416-5a (GDesc -> IE -maddress-mode=short)" \
+               "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr25416-5b.so" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5a.c } \
+               "pr25416-5a" \
+               "pass.out" \
+               "$NOPIE_CFLAGS" \
+           ] \
+           [list \
+               "Run pr25416-5b (GDesc -> LE -maddress-mode=short" \
+               "$NOPIE_LDFLAGS tmpdir/pr25416-5b.o tmpdir/pr25416-5d.o" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5a.c } \
+               "pr25416-5b" \
+               "pass.out" \
+               "$NOPIE_CFLAGS" \
+           ] \
+           [list \
+               "Run pr25416-5c (GDesc -> IE -maddress-mode=long)" \
+               "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr25416-5c.so" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5a.c } \
+               "pr25416-5c" \
+               "pass.out" \
+               "$NOPIE_CFLAGS" \
+           ] \
+           [list \
+               "Run pr25416-5d (GDesc -> LE -maddress-mode=long)" \
+               "$NOPIE_LDFLAGS tmpdir/pr25416-5c.o tmpdir/pr25416-5d.o" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5a.c } \
+               "pr25416-5d" \
+               "pass.out" \
+               "$NOPIE_CFLAGS" \
+           ] \
+           [list \
+               "Run pr25416-5e (GDesc -maddress-mode=short)" \
+               "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr25416-5d.so" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5a.c } \
+               "pr25416-5e" \
+               "pass.out" \
+               "$NOPIE_CFLAGS" \
+           ] \
+           [list \
+               "Run pr25416-5f (PIE GDesc -> LE -maddress-mode=short)" \
+               "-pie -Wl,-z,notext tmpdir/pr25416-5b.o tmpdir/pr25416-5d.o" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5a.c } \
+               "pr25416-5f" \
+               "pass.out" \
+           ] \
+           [list \
+               "Run pr25416-5g (PIE GDesc -> LE -maddress-mode=long)" \
+               "-pie -Wl,-z,notext tmpdir/pr25416-5c.o tmpdir/pr25416-5d.o" \
+               "-Wa,-mx86-used-note=yes" \
+               { pr25416-5a.c } \
+               "pr25416-5g" \
+               "pass.out" \
+           ] \
        ]
     } else {
        run_cc_link_tests [list \
            [list \
                "Build pr22001-1b" \
-               "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+               "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
                "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
                { pr22001-1c.c } \
                {{error_output "pr22001-1b.err"}} \
@@ -1322,7 +1454,7 @@ if { [isnative] && [which $CC] != 0 } {
            ] \
            [list \
                "Build pr21997-1b" \
-               "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+               "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
                "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
                { pr21997-1c.c } \
                {{error_output "pr21997-1b.err"}} \
@@ -1695,7 +1827,7 @@ if { [isnative] && [which $CC] != 0 } {
                "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
                 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt \
                 -z noseparate-code -z max-page-size=0x200000" \
-               "-Wa,-mx86-used-note=yes" \
+               "-Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
                { plt-main5.c } \
                {{objdump {-drw} plt-main-bnd.dd}} \
                "plt-main-bnd" \
@@ -1705,7 +1837,7 @@ if { [isnative] && [which $CC] != 0 } {
                "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
                 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -pie \
                 -z noseparate-code -z max-page-size=0x200000" \
-               "-fPIC -Wa,-mx86-used-note=yes" \
+               "-fPIC -Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
                { plt-main5.c } \
                {{objdump {-drw} plt-main-bnd.dd}} \
                "plt-main-pie-bnd" \
@@ -1715,7 +1847,7 @@ if { [isnative] && [which $CC] != 0 } {
                "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
                 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -z now \
                 -z noseparate-code -z max-page-size=0x200000" \
-               "-Wa,-mx86-used-note=yes" \
+               "-Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
                { plt-main5.c } \
                {{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
                "plt-main-bnd-now" \
@@ -1725,7 +1857,7 @@ if { [isnative] && [which $CC] != 0 } {
                "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
                 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -z now -pie \
                 -z noseparate-code -z max-page-size=0x200000" \
-               "-fPIC -Wa,-mx86-used-note=yes" \
+               "-fPIC -Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
                { plt-main5.c } \
                {{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
                "plt-main-pie-bnd-now" \
@@ -2008,7 +2140,6 @@ run_ld_link_tests [list \
 ]
 
 # Linux only tests
-global LD_CLASS
 if { "$LD_CLASS" == "64bit" } then {
     # This test needs 64-bit linker.
     run_dump_test "pr17618"
This page took 0.035605 seconds and 4 git commands to generate.