Override the previous definition from IR object
[external/binutils.git] / ld / testsuite / ld-plugin / lto.exp
index 7c50b0f..b56bd63 100644 (file)
@@ -219,6 +219,18 @@ set lto_link_tests [list \
   [list "Build pr22751.a" \
    "$plug_opt" "-flto $lto_no_fat $INT128_CFLAGS" \
    {pr22751.c} {} "pr22751.a"] \
+  [list "Build libpr23818.so" \
+   "-shared -flto -g -Wl,-version-script,pr23818.t" \
+   "-g -flto $lto_fat" \
+   {pr23818a.c pr23818b.c} \
+   {{"readelf" {-s --wide} "pr23818.d"}} \
+   "libpr23818.so"] \
+  [list "Build libpr23958.so" \
+   "-shared -flto -Wl,-version-script,pr23958.t" \
+   "-g -flto $lto_fat" \
+   {pr23958.c} \
+   "" \
+   "libpr23958.so"] \
 ]
 
 if { [at_least_gcc_version 4 7] } {
@@ -262,9 +274,6 @@ set lto_link_elf_tests [list \
   [list "Build liblto-17b.so 2" \
    "-shared -O2 -fpic -flto -fuse-linker-plugin tmpdir/lto-17a.o" "-O2 -fpic -flto" \
    {lto-17b.c} {{"nm" {} "lto-17b-2.d"}} "liblto-17b.so"] \
-  [list "PR ld/12982" \
-   "-O2 -flto -fuse-linker-plugin" "-O2 -flto" \
-   {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"] \
   [list "PR ld/12975" \
    "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib -Wl,-version-script,pr12975.t" "-O2 -flto" \
    {pr12975.c} {{"readelf" {-s --wide} "pr12975.d"}} "pr12975.so" "c"] \
@@ -328,6 +337,18 @@ if { ! [istarget "arm*-*-*"] } {
   ]]
 }
 
+# PR 12982 checks that an executable stack is not created by default
+# when using the LTO plugin.  The HPPA target however requires an
+# executable stack for syscall restarts and signal returns, so we
+# skip this test for that target.
+if { ! [istarget "hppa*-*-*"] } {
+    set lto_link_elf_tests [concat $lto_link_elf_tests [list \
+  [list "PR ld/12982" \
+   "-O2 -flto -fuse-linker-plugin" "-O2 -flto" \
+   {pr12982.c} {{"readelf" {-l --wide} "pr12982.d"}} "pr12982.exe"] \
+  ]]
+}
+
 # Check final symbols in executables.
 set lto_link_symbol_tests [list \
   [list "LTO 3 symbol" \
@@ -506,6 +527,7 @@ if { [at_least_gcc_version 4 7] } {
           || [istarget "amd64-*-linux*"]) } {
        set testname "PR ld/12365"
        set exec_output [run_host_cmd "$CC" "-O2 -flto -flto-partition=none -fuse-linker-plugin -o tmpdir/pr12365 tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
+       set exec_output [prune_warnings $exec_output]
        if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
            # Linker should catch the reference to undefined `my_bcopy'
            # error caused by a GCC bug.
@@ -556,6 +578,32 @@ if { [at_least_gcc_version 4 7] } {
     } {
         fail $testname
     }
+
+    run_cc_link_tests [list \
+       [list \
+           "Build pr23460*.o" \
+           "$plug_opt" \
+           "-O2 -fPIC -flto $lto_no_fat" \
+           {pr23460a.c pr23460b.c pr23460c.c \
+            pr23460d.c pr23460e.c pr23460f.c} \
+       ] \
+    ]
+    set exec_output [run_host_cmd "sh" \
+                                 "-c \"ulimit -n 16; \
+                                  $ar -rc $plug_opt \
+                                  tmpdir/libpr23460.a \
+                                  tmpdir/pr23460a.o \
+                                  tmpdir/pr23460b.o \
+                                  tmpdir/pr23460c.o \
+                                  tmpdir/pr23460d.o \
+                                  tmpdir/pr23460e.o \
+                                  tmpdir/pr23460f.o\""]
+    set exec_output [prune_warnings $exec_output]
+    if [string match "" $exec_output] then {
+       pass "PR binutils/23460"
+    } else {
+       fail "PR binutils/23460"
+    }
 }
 
 # Run "ld -r" to generate inputs for complex LTO tests.