ld/elf: Ignore section symbols when matching linkonce with comdat
[binutils-gdb.git] / ld / testsuite / ld-i386 / i386.exp
index 21f55932497f2af56742ef6caaeaa1bfc3953044..0be6b861daba79092e12e4f60af643f01ff5c1c3 100644 (file)
@@ -1,5 +1,5 @@
 # Expect script for ld-i386 tests
-#   Copyright (C) 2002-2018 Free Software Foundation, Inc.
+#   Copyright (C) 2002-2021 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -19,7 +19,6 @@
 # MA 02110-1301, USA.
 #
 
-global ASFLAGS
 set saved_ASFLAGS "$ASFLAGS"
 if { [is_elf_format] \
      && ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
@@ -40,7 +39,7 @@ if {[istarget "i?86-*-vxworks"]} {
        {"VxWorks executable test 1 (dynamic)" \
         "tmpdir/libvxworks1.so -Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
         "" {vxworks1.s}
-        {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
+        {{readelf {--relocs --wide} vxworks1.rd} {objdump -dr vxworks1.dd}}
         "vxworks1"}
        {"VxWorks executable test 2 (dynamic)" \
         "-Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
@@ -108,9 +107,7 @@ if [istarget "*-*-go32*"] {
 if { !([istarget "i?86-*-elf*"]
        || [istarget "i?86-*-linux*"]
        || [istarget "i?86-*-gnu*"]
-       || [istarget "i?86-*-nacl*"]
        || [istarget "x86_64-*-elf*"]
-       || [istarget "x86_64-*-nacl*"]
        || [istarget "x86_64-*-linux*"]
        || [istarget "amd64-*-linux*"]) } {
     return
@@ -181,7 +178,7 @@ set i386tests {
       {objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
       "tlsbindesc"}
     {"TLS -fno-pic -shared"
-     "-shared -melf_i386 --no-ld-generated-unwind-info \
+     "-shared -melf_i386 --no-ld-generated-unwind-info -z notext \
       -z noseparate-code --hash-style=sysv" ""
      "--32" {tlsnopic1.s tlsnopic2.s}
      {{readelf -Ssrl tlsnopic.rd} {objdump -drj.text tlsnopic.dd}
@@ -197,7 +194,8 @@ set i386tests {
      {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
     {"TLS @indntpoff with %eax" "-melf_i386" "" "--32" {tlsindntpoff.s}
      {{objdump -drj.text tlsindntpoff.dd}} "tlsindntpoff"}
-    {"Reloc section order" "-shared -melf_i386 -z nocombreloc" "" "--32"
+    {"Reloc section order"
+     "-shared -melf_i386 -z nocombreloc -z notext" "" "--32"
      {reloc.s} {{objdump -hw reloc.d}} "reloc.so"}
     {"Basic --emit-relocs support" "-shared -melf_i386 --emit-relocs" "" "--32"
      {emit-relocs.s} {{readelf --relocs emit-relocs.rd}} "emit-relocs.so"}
@@ -238,58 +236,44 @@ set i386tests {
     {"Build pr19827b.so" "-melf_i386 -shared" ""
      "--32 -mx86-used-note=yes"
      { pr19827b.S } {} "pr19827b.so"}
-    {"Build pr19827" "-melf_i386 -pie tmpdir/pr19827a.o tmpdir/pr19827b.so" ""
+    {"Build pr19827"
+     "-melf_i386 -pie -z notext tmpdir/pr19827a.o tmpdir/pr19827b.so"
+     ""
      "--32 -mx86-used-note=yes"
      { dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"}
-    {"Build pr19827.so" "-melf_i386 -shared -Bsymbolic" ""
+    {"Build pr19827.so"
+     "-melf_i386 -shared -Bsymbolic -z notext" ""
      "--32 -mx86-used-note=yes"
      { pr19827a.S }  {{readelf {-rW} pr19827.rd}} "pr19827.so"}
-}
-
-# So as to avoid rewriting every last test case here in a nacl variant,
-# we use black magic to massage the generic cases into nacl-variant cases.
-if [istarget "*-*-nacl*"] {
-    # Change all the -melf_i386 to -melf_i386_nacl so linking can succeed.
-    regsub -all elf_i386 $i386tests elf_i386_nacl i386tests
-
-    # Same, applied to all the run_dump_test cases.
-    set options_regsub(ld) {elf_i386 elf_i386_nacl}
-
-    # The section/segment layout differs too much for the vanilla
-    # readelf output files to match.  So massage the cases so that
-    # they refer to a foo-nacl.rd file instead of a foo.rd file.
-    regsub -all {([a-z0-9]+)\.rd} $i386tests {\1-nacl.rd} i386tests
-
-    # Likewise for PLTs.
-    regsub -all -- {([a-z0-9]+)\.pd} $i386tests {\1-nacl.pd} i386tests
+    {"Build pr27193.so"
+     "-melf_i386 -shared" ""
+     "--32"
+     { pr27193a.o.bz2 pr27193b.s }
+     {{objdump {-dw} pr27193.dd}} "pr27193.so"}
 }
 
 proc iamcu_tests {} {
-    if {[istarget "*-*-nacl*"]} then {
-       return
-    }
-
     global as
     global srcdir
     global subdir
 
     if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/start.s" tmpdir/startiamcu.o] {
-       unresolved "Build Intel MCU start.o"
+       fail "Build Intel MCU 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 "--32 -march=iamcu $srcdir/$subdir/foo.s" tmpdir/fooiamcu.o] {
-       unresolved "Build Intel MCU foo.o"
+       fail "Build Intel MCU 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
     }
 
@@ -363,8 +347,9 @@ run_dump_test "call3g"
 run_dump_test "call3h"
 run_dump_test "jmp1"
 run_dump_test "jmp2"
+run_dump_test "ljmp1"
+run_dump_test "ljmp2"
 run_dump_test "load1"
-run_dump_test "load1-nacl"
 run_dump_test "load2"
 run_dump_test "load3"
 run_dump_test "load4a"
@@ -379,7 +364,6 @@ run_dump_test "pr19636-1a"
 run_dump_test "pr19636-1b"
 run_dump_test "pr19636-1c"
 run_dump_test "pr19636-1d"
-run_dump_test "pr19636-1d-nacl"
 run_dump_test "pr19636-1e"
 run_dump_test "pr19636-1f"
 run_dump_test "pr19636-1g"
@@ -391,11 +375,8 @@ run_dump_test "pr19636-1l"
 run_dump_test "pr19636-2a"
 run_dump_test "pr19636-2b"
 run_dump_test "pr19636-2c"
-run_dump_test "pr19636-2c-nacl"
 run_dump_test "pr19636-2d"
-run_dump_test "pr19636-2d-nacl"
 run_dump_test "pr19636-2e"
-run_dump_test "pr19636-2e-nacl"
 run_dump_test "pr19636-3a"
 run_dump_test "pr19636-3b"
 run_dump_test "pr19636-3c"
@@ -446,6 +427,7 @@ run_dump_test "property-x86-3"
 run_dump_test "property-x86-4a"
 run_dump_test "property-x86-4b"
 run_dump_test "property-x86-5"
+run_dump_test "property-x86-6"
 run_dump_test "property-x86-ibt1a"
 run_dump_test "property-x86-ibt1b"
 run_dump_test "property-x86-ibt2"
@@ -460,10 +442,18 @@ run_dump_test "property-x86-shstk3a"
 run_dump_test "property-x86-shstk3b"
 run_dump_test "property-x86-shstk4"
 run_dump_test "property-x86-shstk5"
+run_dump_test "property-x86-cet1"
+run_dump_test "property-x86-cet2a"
+run_dump_test "property-x86-cet2b"
+run_dump_test "property-x86-cet3a"
+run_dump_test "property-x86-cet3b"
+run_dump_test "property-x86-cet4a"
+run_dump_test "property-x86-cet4b"
+run_dump_test "property-x86-cet5a"
+run_dump_test "property-x86-cet5b"
+run_dump_test "property-x86-cet6"
 run_dump_test "pie1"
-run_dump_test "pie1-nacl"
 run_dump_test "pr21884"
-run_dump_test "pr21884-nacl"
 run_dump_test "pr22115-1a"
 run_dump_test "pr22115-1b"
 run_dump_test "pr22115-1c"
@@ -481,11 +471,24 @@ run_dump_test "pr23486a"
 run_dump_test "pr23486b"
 run_dump_test "pr23486c"
 run_dump_test "pr23486d"
+run_dump_test "pr23854"
+run_dump_test "pr23930"
+run_dump_test "pr24322a"
+run_dump_test "pr24322b"
+run_dump_test "align-branch-1"
+run_dump_test "pr26018"
+run_dump_test "pr26263"
+run_dump_test "pr26711-1"
+run_dump_test "pr26711-2"
+run_dump_test "pr26711-3"
+run_dump_test "property-x86-isa1"
+run_dump_test "property-x86-isa2"
+run_dump_test "property-x86-isa3"
+run_dump_test "property-x86-isa4"
+run_dump_test "pr26869"
 
 if { !([istarget "i?86-*-linux*"]
        || [istarget "i?86-*-gnu*"]
-       || [istarget "i?86-*-nacl*"]
-       || [istarget "x86_64-*-nacl*"]
        || [istarget "x86_64-*-linux*"]) } {
     set ASFLAGS "$saved_ASFLAGS"
     return
@@ -498,11 +501,17 @@ run_dump_test "pr14215"
 run_dump_test "pr17057"
 run_dump_test "pr17935-1"
 run_dump_test "pr17935-2"
-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 "pr19939a"
 run_dump_test "pr19939b"
 run_dump_test "tlsdesc2"
+run_dump_test "report-reloc-1"
 
 proc undefined_weak {cflags ldflags} {
     set testname "Undefined weak symbol"
@@ -560,13 +569,10 @@ proc undefined_weak {cflags ldflags} {
     }
 }
 
-# Add $PLT_CFLAGS if PLT is expected.
-global PLT_CFLAGS
-
 # Must be Linux native with the C compiler
 if { [isnative]
      && [istarget "i?86-*-linux*"]
-     && [which $CC] != 0 } {
+     && [check_compiler_available] } {
     run_cc_link_tests [list \
        [list \
            "Build plt-lib.so" \
@@ -802,6 +808,15 @@ if { [isnative]
            {{objdump {-dw} pr19319.dd}} \
            "pr19319" \
        ] \
+       [list \
+           "Build pr24276.so" \
+           "-shared -nostdlib -nostartfiles \
+            -Ltmpdir $srcdir/$subdir/pr24276.dso" \
+           "-Wa,-mx86-used-note=yes" \
+           { pr19319b.S } \
+           {{warning_output pr24276.warn}} \
+           "pr24276.so" \
+       ] \
        [list \
            "Build property 1" \
            "" \
@@ -1163,13 +1178,11 @@ if { [isnative]
     undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
 }
 
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-
 # Must be native with the C compiler and working IFUNC support,
 if { [isnative]
      && [check_ifunc_available]
      && [istarget "i?86-*-*"]
-     && [which $CC] != 0 } {
+     && [check_compiler_available] } {
     run_cc_link_tests [list \
        [list \
            "Build ifunc-1a.o ifunc-1b.o ifunc-1c.o ifunc-1d.o" \
@@ -1286,11 +1299,11 @@ if { [isnative]
 # Must be native with the C compiler.
 if { [isnative]
      && [istarget "i?86-*-*"]
-     && [which $CC] != 0 } {
+     && [check_compiler_available] } {
     run_cc_link_tests [list \
        [list \
            "Build pr22001-1.so" \
-           "-shared" \
+           "-shared -Wl,-z,notext" \
            "-Wa,-mx86-used-note=yes" \
            { pr22001-1a.c } \
            {} \
@@ -1326,7 +1339,7 @@ if { [isnative]
        ] \
        [list \
            "Run pr22001-1" \
-           "$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-1b.c } \
            "pr22001-1" \
@@ -1369,7 +1382,7 @@ if { [isnative]
        ] \
        [list \
            "Run pr21997-1" \
-           "$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-1b.c } \
            "pr21997-1" \
@@ -1418,6 +1431,15 @@ if { [isnative]
            "pr22842" \
            "pass.out" \
        ] \
+       [list \
+           "Run pr23997" \
+           "" \
+           "" \
+           { ../ld-x86-64/pr23997a.s ../ld-x86-64/pr23997b.c \
+             ../ld-x86-64/pr23997c.c } \
+           "pr23997" \
+           "pass.out" \
+       ] \
     ]
 
     if { [at_least_gcc_version 5 0] } {