Blob Blame History Raw
diff -rupN --no-dereference binutils-2.38/binutils/testsuite/binutils-all/compress.exp binutils-2.38-new/binutils/testsuite/binutils-all/compress.exp
--- binutils-2.38/binutils/testsuite/binutils-all/compress.exp	2022-01-22 13:14:07.000000000 +0100
+++ binutils-2.38-new/binutils/testsuite/binutils-all/compress.exp	2022-04-26 13:54:59.385542280 +0200
@@ -766,12 +766,6 @@ proc test_gnu_debuglink {} {
     } else {
 	pass "$test (objdump with missing link)"
     }
-    set got [remote_exec host [concat sh -c [list "$READELF -S tmpdir/testprog > /dev/null"]]]
-    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
-	fail "$test (readelf with missing link)"
-    } else {
-	pass "$test (readelf with missing link)"
-    }
 }
 
 if {[is_elf_format]} then {
diff -rupN --no-dereference binutils-2.38/gold/main.cc binutils-2.38-new/gold/main.cc
--- binutils-2.38/gold/main.cc	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/gold/main.cc	2022-04-26 13:54:59.378542270 +0200
@@ -290,16 +290,6 @@ main(int argc, char** argv)
               elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
               elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
 
-#if defined(HAVE_MALLINFO2)
-      struct mallinfo2 m = mallinfo2();
-      fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
-	      program_name, static_cast<long long>(m.arena));
-#elif defined(HAVE_MALLINFO)
-      struct mallinfo m = mallinfo();
-      fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"),
-	      program_name, static_cast<long long>(m.arena));
-#endif
-
       File_read::print_stats();
       Archive::print_stats();
       Lib_group::print_stats();
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-aarch64/tls-relax-gdesc-le-now.d binutils-2.38-new/ld/testsuite/ld-aarch64/tls-relax-gdesc-le-now.d
--- binutils-2.38/ld/testsuite/ld-aarch64/tls-relax-gdesc-le-now.d	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-aarch64/tls-relax-gdesc-le-now.d	2022-04-26 13:54:59.378542270 +0200
@@ -11,7 +11,7 @@
  0x.+ \(PLTRELSZ\) \s+.+ \(bytes\)
  0x.+ \(PLTREL\)   \s+RELA
  0x.+ \(JMPREL\)   \s+0x.+
- 0x.+ \(BIND_NOW\) \s+
+ 0x.+ \(FLAGS\) \s+BIND_NOW
  0x.+ \(FLAGS_1\)  \s+   Flags: NOW
  0x.+ \(NULL\)     \s+   0x0
 
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-aarch64/variant_pcs-now.d binutils-2.38-new/ld/testsuite/ld-aarch64/variant_pcs-now.d
--- binutils-2.38/ld/testsuite/ld-aarch64/variant_pcs-now.d	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-aarch64/variant_pcs-now.d	2022-04-26 13:54:59.377542268 +0200
@@ -23,10 +23,10 @@ Symbol table '\.dynsym' contains 7 entri
    Num:    Value          Size Type    Bind   Vis      Ndx Name
      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND f_base_global_default_undef
-     2: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]   UND f_spec_global_default_undef
-     3: 0000000000008000     0 IFUNC   GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_ifunc
+     2: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT[ 	]+UND f_spec_global_default_undef[ 	]+\[VARIANT_PCS\]
+     3: 0000000000008000     0 IFUNC   GLOBAL DEFAULT[ 	]+1 f_spec_global_default_ifunc[ 	]+\[VARIANT_PCS\]
      4: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT    1 f_base_global_default_def
-     5: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_def
+     5: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT[ 	]+1 f_spec_global_default_def[ 	]+\[VARIANT_PCS\]
      6: 0000000000008000     0 IFUNC   GLOBAL DEFAULT    1 f_base_global_default_ifunc
 
 Symbol table '\.symtab' contains 35 entries:
@@ -41,28 +41,28 @@ Symbol table '\.symtab' contains 35 entr
      7: 00000000000111c8     0 SECTION LOCAL  DEFAULT    7.*
      8: 0000000000011270     0 SECTION LOCAL  DEFAULT    8.*
      9: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS .*variant_pcs-1\.o
-    10: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local
-    11: 0000000000008000     0 IFUNC   LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local_ifunc
+    10: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT .*
+    11: 0000000000008000     0 IFUNC   LOCAL  DEFAULT .*
     12: 0000000000008000     0 IFUNC   LOCAL  DEFAULT    1 f_base_local_ifunc
     13: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT    1 f_base_local
     14: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT    1 \$x
     15: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS .*variant_pcs-2\.o
-    16: 0000000000008038     0 NOTYPE  LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local2
-    17: 0000000000008038     0 IFUNC   LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local2_ifunc
+    16: 0000000000008038     0 NOTYPE  LOCAL  DEFAULT .*
+    17: 0000000000008038     0 IFUNC   LOCAL  DEFAULT .*
     18: 0000000000008038     0 IFUNC   LOCAL  DEFAULT    1 f_base_local2_ifunc
     19: 0000000000008038     0 NOTYPE  LOCAL  DEFAULT    1 f_base_local2
     20: 0000000000008038     0 NOTYPE  LOCAL  DEFAULT    1 \$x
     21: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS 
     22: 0000000000009080     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
-    23: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_global_hidden_def
+    23: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT .*
     24: 0000000000008000     0 IFUNC   LOCAL  DEFAULT    1 f_base_global_hidden_ifunc
     25: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT    1 f_base_global_hidden_def
     26: 0000000000009000     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
-    27: 0000000000008000     0 IFUNC   LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_global_hidden_ifunc
+    27: 0000000000008000     0 IFUNC   LOCAL  DEFAULT .*
     28: 0000000000008070     0 NOTYPE  LOCAL  DEFAULT    2 \$x
     29: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND f_base_global_default_undef
-    30: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]   UND f_spec_global_default_undef
-    31: 0000000000008000     0 IFUNC   GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_ifunc
+    30: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT .*
+    31: 0000000000008000     0 IFUNC   GLOBAL DEFAULT .*
     32: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT    1 f_base_global_default_def
-    33: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_def
+    33: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT .*
     34: 0000000000008000     0 IFUNC   GLOBAL DEFAULT    1 f_base_global_default_ifunc
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-aarch64/variant_pcs-r.d binutils-2.38-new/ld/testsuite/ld-aarch64/variant_pcs-r.d
--- binutils-2.38/ld/testsuite/ld-aarch64/variant_pcs-r.d	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-aarch64/variant_pcs-r.d	2022-04-26 13:54:59.378542270 +0200
@@ -37,24 +37,24 @@ Symbol table '\.symtab' contains 26 entr
      2: 0000000000000000     0 SECTION LOCAL  DEFAULT    3.*
      3: 0000000000000000     0 SECTION LOCAL  DEFAULT    4.*
      4: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS .*variant_pcs-1\.o
-     5: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local
-     6: 0000000000000000     0 IFUNC   LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local_ifunc
+     5: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT .*
+     6: 0000000000000000     0 IFUNC   LOCAL  DEFAULT .*
      7: 0000000000000000     0 IFUNC   LOCAL  DEFAULT    1 f_base_local_ifunc
      8: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT    1 f_base_local
      9: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT    1 \$x
     10: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS .*variant_pcs-2\.o
-    11: 0000000000000038     0 NOTYPE  LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local2
-    12: 0000000000000038     0 IFUNC   LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local2_ifunc
+    11: 0000000000000038     0 NOTYPE  LOCAL  DEFAULT .*
+    12: 0000000000000038     0 IFUNC   LOCAL  DEFAULT .*
     13: 0000000000000038     0 IFUNC   LOCAL  DEFAULT    1 f_base_local2_ifunc
     14: 0000000000000038     0 NOTYPE  LOCAL  DEFAULT    1 f_base_local2
     15: 0000000000000038     0 NOTYPE  LOCAL  DEFAULT    1 \$x
     16: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND f_base_global_default_undef
-    17: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]   UND f_spec_global_default_undef
-    18: 0000000000000000     0 NOTYPE  GLOBAL HIDDEN  \[VARIANT_PCS\]     1 f_spec_global_hidden_def
+    17: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT .*
+    18: 0000000000000000     0 NOTYPE  GLOBAL HIDDEN  .*
     19: 0000000000000000     0 IFUNC   GLOBAL HIDDEN     1 f_base_global_hidden_ifunc
-    20: 0000000000000000     0 IFUNC   GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_ifunc
+    20: 0000000000000000     0 IFUNC   GLOBAL DEFAULT .*
     21: 0000000000000000     0 NOTYPE  GLOBAL HIDDEN     1 f_base_global_hidden_def
-    22: 0000000000000000     0 IFUNC   GLOBAL HIDDEN  \[VARIANT_PCS\]     1 f_spec_global_hidden_ifunc
+    22: 0000000000000000     0 IFUNC   GLOBAL HIDDEN  .*
     23: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 f_base_global_default_def
-    24: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_def
+    24: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT .*
     25: 0000000000000000     0 IFUNC   GLOBAL DEFAULT    1 f_base_global_default_ifunc
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-aarch64/variant_pcs-shared.d binutils-2.38-new/ld/testsuite/ld-aarch64/variant_pcs-shared.d
--- binutils-2.38/ld/testsuite/ld-aarch64/variant_pcs-shared.d	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-aarch64/variant_pcs-shared.d	2022-04-26 13:54:59.378542270 +0200
@@ -23,10 +23,10 @@ Symbol table '\.dynsym' contains 7 entri
    Num:    Value          Size Type    Bind   Vis      Ndx Name
      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
      1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND f_base_global_default_undef
-     2: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]   UND f_spec_global_default_undef
-     3: 0000000000008000     0 IFUNC   GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_ifunc
+     2: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT[ 	]+UND f_spec_global_default_undef[ 	]+\[VARIANT_PCS\]
+     3: 0000000000008000     0 IFUNC   GLOBAL DEFAULT[ 	]+1 f_spec_global_default_ifunc[ 	]+\[VARIANT_PCS\]
      4: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT    1 f_base_global_default_def
-     5: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_def
+     5: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT[ 	]+1 f_spec_global_default_def[ 	]+\[VARIANT_PCS\]
      6: 0000000000008000     0 IFUNC   GLOBAL DEFAULT    1 f_base_global_default_ifunc
 
 Symbol table '\.symtab' contains 35 entries:
@@ -41,28 +41,28 @@ Symbol table '\.symtab' contains 35 entr
      7: 00000000000111c8     0 SECTION LOCAL  DEFAULT    7.*
      8: 0000000000011270     0 SECTION LOCAL  DEFAULT    8.*
      9: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS .*variant_pcs-1\.o
-    10: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local
-    11: 0000000000008000     0 IFUNC   LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local_ifunc
+    10: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT .*
+    11: 0000000000008000     0 IFUNC   LOCAL  DEFAULT .*
     12: 0000000000008000     0 IFUNC   LOCAL  DEFAULT    1 f_base_local_ifunc
     13: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT    1 f_base_local
     14: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT    1 \$x
     15: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS .*variant_pcs-2\.o
-    16: 0000000000008038     0 NOTYPE  LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local2
-    17: 0000000000008038     0 IFUNC   LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_local2_ifunc
+    16: 0000000000008038     0 NOTYPE  LOCAL  DEFAULT .*
+    17: 0000000000008038     0 IFUNC   LOCAL  DEFAULT .*
     18: 0000000000008038     0 IFUNC   LOCAL  DEFAULT    1 f_base_local2_ifunc
     19: 0000000000008038     0 NOTYPE  LOCAL  DEFAULT    1 f_base_local2
     20: 0000000000008038     0 NOTYPE  LOCAL  DEFAULT    1 \$x
     21: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS 
     22: 0000000000009080     0 OBJECT  LOCAL  DEFAULT  ABS _DYNAMIC
-    23: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_global_hidden_def
+    23: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT .*
     24: 0000000000008000     0 IFUNC   LOCAL  DEFAULT    1 f_base_global_hidden_ifunc
     25: 0000000000008000     0 NOTYPE  LOCAL  DEFAULT    1 f_base_global_hidden_def
     26: 0000000000009000     0 OBJECT  LOCAL  DEFAULT  ABS _GLOBAL_OFFSET_TABLE_
-    27: 0000000000008000     0 IFUNC   LOCAL  DEFAULT \[VARIANT_PCS\]     1 f_spec_global_hidden_ifunc
+    27: 0000000000008000     0 IFUNC   LOCAL  DEFAULT .*
     28: 0000000000008070     0 NOTYPE  LOCAL  DEFAULT    2 \$x
     29: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND f_base_global_default_undef
-    30: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]   UND f_spec_global_default_undef
-    31: 0000000000008000     0 IFUNC   GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_ifunc
+    30: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT .*
+    31: 0000000000008000     0 IFUNC   GLOBAL DEFAULT .*
     32: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT    1 f_base_global_default_def
-    33: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT \[VARIANT_PCS\]     1 f_spec_global_default_def
+    33: 0000000000008000     0 NOTYPE  GLOBAL DEFAULT .*
     34: 0000000000008000     0 IFUNC   GLOBAL DEFAULT    1 f_base_global_default_ifunc
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-elf/compress.exp binutils-2.38-new/ld/testsuite/ld-elf/compress.exp
--- binutils-2.38/ld/testsuite/ld-elf/compress.exp	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-elf/compress.exp	2022-04-26 13:54:59.379542271 +0200
@@ -167,8 +167,8 @@ if { [regexp_diff tmpdir/$test.out $srcd
 
 set test_name "Link with zlib compressed debug output 1"
 set test normal
-send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
-set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"]
+send_log "$READELF -wi tmpdir/$test > tmpdir/$test.out\n"
+set got [remote_exec host [concat sh -c [list "$READELF -wi tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
     send_log "$got\n"
     fail "$test_name"
@@ -176,8 +176,8 @@ if { [lindex $got 0] != 0 || ![string ma
 
 set test_name "Link with zlib compressed debug output 2"
 set test zlibnormal
-send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
-set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"]
+send_log "$READELF -wi tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
+set got [remote_exec host [concat sh -c [list "$READELF -wi tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
     send_log "$got\n"
     fail "$test_name"
@@ -203,8 +203,8 @@ if { [regexp_diff tmpdir/$test.out $srcd
 
 set test_name "Link with zlib-gnu compressed debug output 1"
 set test gnunormal
-send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
-set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"]
+send_log "$READELF -wi tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
+set got [remote_exec host [concat sh -c [list "$READELF -wi tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
     send_log "$got\n"
     fail "$test_name"
@@ -230,8 +230,8 @@ if { [regexp_diff tmpdir/$test.out $srcd
 
 set test gabinormal
 set test_name "Link with zlib-gabi compressed debug output 1"
-send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
-set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"]
+send_log "$READELF -wi tmpdir/$test > tmpdir/$test.out\n"
+set got [remote_exec host [concat sh -c [list "$READELF -wi tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
     send_log "$got\n"
     fail "$test_name"
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-elf/pr26580-3.out binutils-2.38-new/ld/testsuite/ld-elf/pr26580-3.out
--- binutils-2.38/ld/testsuite/ld-elf/pr26580-3.out	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-elf/pr26580-3.out	2022-04-26 13:54:59.385542280 +0200
@@ -1,2 +1,2 @@
 library not loaded
-alignment 1
+alignment .
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-elf/shared.exp binutils-2.38-new/ld/testsuite/ld-elf/shared.exp
--- binutils-2.38/ld/testsuite/ld-elf/shared.exp	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-elf/shared.exp	2022-04-26 13:54:59.385542280 +0200
@@ -1576,18 +1576,6 @@ if { [istarget *-*-linux*]
 	    "pr22393-2-static" \
 	    "pass.out" \
 	] \
-	[list \
-	    "Run pr21964-4" \
-	    "" \
-	    "" \
-	    {pr21964-4.c} \
-	    "pr21964-4" \
-	    "pass.out" \
-	    "" \
-	    "" \
-	    "" \
-	    "-ldl" \
-	] \
     ]
 }
 
@@ -1669,6 +1657,7 @@ if [istarget "sparc*-*-*"] {
 if { ([istarget "*-*-linux*"]
       || [istarget "*-*-nacl*"]
       || [istarget "*-*-gnu*"])
+     && ![istarget "aarch64*-*-*"] && ![istarget "arm*-*-*"]
      && ![istarget "mips*-*-*"] } {
     run_ld_link_tests [list \
 	[list \
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-elf/shared.exp.orig binutils-2.38-new/ld/testsuite/ld-elf/shared.exp.orig
--- binutils-2.38/ld/testsuite/ld-elf/shared.exp.orig	1970-01-01 01:00:00.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-elf/shared.exp.orig	2022-01-22 13:14:09.000000000 +0100
@@ -0,0 +1,1796 @@
+# Expect script for various ELF tests.
+#   Copyright (C) 2006-2022 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+# Exclude non-ELF targets.
+
+if ![is_elf_format] {
+    return
+}
+
+# Skip targets where -shared is not supported
+
+if ![check_shared_lib_support] {
+    return
+}
+
+set old_ASFLAGS $ASFLAGS
+
+# This target requires extra GAS options when building code for shared
+# libraries.
+set AFLAGS_PIC ""
+if [istarget "nds32*-*"] {
+    append AFLAGS_PIC " -mpic"
+}
+if [istarget "tic6x-*-*"] {
+    append AFLAGS_PIC " -mpic -mpid=near"
+}
+if [istarget "sparc*-*-*"] {
+    append AFLAGS_PIC " -K PIC -Av9"
+}
+
+# GAS options to disable program property note.
+set AFLAGS_NOTE ""
+if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
+    append AFLAGS_NOTE "-mx86-used-note=no"
+}
+
+# This target requires a non-default emulation for successful shared
+# library/executable builds.
+set LFLAGS ""
+if [istarget "tic6x-*-*"] {
+    append LFLAGS " -melf32_tic6x_le"
+}
+# HPUX targets use a different .comm syntax.
+set hpux ""
+if [istarget "*-*-hpux*"] {
+    set hpux "--defsym HPUX=1"
+}
+# These targets do not default to linking with shared libraries.
+if { [istarget "mips*vr4100*-*-elf*"] \
+     || [istarget "mips*vr4300*-*-elf*"] \
+     || [istarget "mips*vr5000*-*-elf*"] } {
+    append LFLAGS " -call_shared"
+}
+
+if [is_underscore_target] {
+    append ASFLAGS " --defsym UNDERSCORE=1"
+}
+
+run_ld_link_tests [list \
+    [list \
+	"Build pr22471a.so" \
+	"$LFLAGS -shared" \
+	"" \
+	"$AFLAGS_PIC" \
+	{pr22471a.s} \
+	{} \
+	"pr22471a.so" \
+    ] \
+    [list \
+	"Build pr22471b.so" \
+	"$LFLAGS -shared --version-script pr22471.t" \
+	"tmpdir/pr22471a.so" \
+	"$AFLAGS_PIC" \
+	{pr22471a.s} \
+	{} \
+	"pr22471b.so" \
+    ] \
+    [list \
+	"Build pr22649-1.so" \
+	"$LFLAGS -shared" \
+	"" \
+	"$AFLAGS_PIC" \
+	{pr22649-1.s} \
+	{} \
+	"pr22649-1.so" \
+    ] \
+]
+
+run_ld_link_tests [list \
+    [list \
+	"Build pr22471" \
+	"$LFLAGS -rpath-link . -rpath-link tmpdir" \
+	"tmpdir/pr22471b.so" \
+	"" \
+	{pr22471b.s} \
+	{} \
+	"pr22471" \
+    ] \
+] bfin-*-* frv-*-* lm32-*-*
+
+if { [check_gc_sections_available] } {
+    if [istarget mips*-*-*] {
+	set actions {{ld pr22649-2ab-mips.msg}}
+    } else {
+	set actions {{ld pr22649.msg}}
+    }
+    run_ld_link_tests [list \
+	[list \
+	    "Build pr22649-2a.so" \
+	    "$LFLAGS -shared -gc-sections -print-gc-sections" \
+	    "" \
+	    "$AFLAGS_PIC" \
+	    {pr22649-2a.s} \
+	    $actions \
+	    "pr22649-2a.so" \
+	] \
+	[list \
+	    "Build pr22649-2b.so" \
+	    "$LFLAGS -shared -gc-sections -print-gc-sections" \
+	    "tmpdir/pr22649-1.so" \
+	    "$AFLAGS_PIC" \
+	    {pr22649-2a.s} \
+	    $actions \
+	    "pr22649-2b.so" \
+	] \
+    ]
+    if { [istarget mips*-*-*] && ![istarget *-*-elf*] } {
+	set actions {{ld pr22649-2cd-mips.msg}}
+    } else {
+	set actions {}
+    }
+    run_ld_link_tests [list \
+	[list \
+	    "Build pr22649-2c.so" \
+	    "$LFLAGS -shared -gc-sections -print-gc-sections" \
+	    "" \
+	    "$AFLAGS_PIC" \
+	    {pr22649-2b.s} \
+	    $actions \
+	    "pr22649-2b.so" \
+	] \
+	[list \
+	    "Build pr22649-2d.so" \
+	    "$LFLAGS -shared -gc-sections -print-gc-sections" \
+	    "tmpdir/pr22649-1.so" \
+	    "$AFLAGS_PIC" \
+	    {pr22649-2b.s} \
+	    $actions \
+	    "pr22649-2b.so" \
+	] \
+    ]
+}
+
+run_ld_link_tests [list \
+    [list \
+	"DT_TEXTREL in shared lib" \
+	"$LFLAGS -shared --warn-shared-textrel" \
+	"" \
+	"$AFLAGS_PIC" \
+	{textrel.s} \
+	 {{ld textrel.warn} \
+	  {readelf {-d --wide} textrel.rd}} \
+	"textrel.so" \
+    ] \
+] bfin-*-* frv-*-* lm32-*-* xtensa-*-*
+
+# The MIPS backend sets SHF_WRITE, in `mips_elf_create_dynamic_relocation',
+# for any section that has a dynamic relocation attached and consequently
+# this test is irrelevant for MIPS targets.  We don't have a clean way to
+# request UNSUPPORTED result, which would be the most appropriate here,
+# so we just XFAIL the test instead.
+run_ld_link_tests [list \
+    [list \
+	"DT_TEXTREL map file warning" \
+	"$LFLAGS -shared -M" \
+	"" \
+	"$AFLAGS_PIC" \
+	{textrel.s} \
+	 {{ld textrel.map}} \
+	"textrel.so" \
+    ] \
+] bfin-*-* cris*-*-* frv-*-* lm32-*-* mips*-*-*
+
+# PR ld/20828 check for correct dynamic symbol table entries where:
+# - symbols have been defined with a linker script,
+# - the same symbols have been seen in shared library used in the link,
+# - the shared library symbols have been swept in section garbage collection.
+# Verify that the symbols are global rather than local and that a version
+# script adjusts them accordingly.
+# Also verify that a version definition supplied by an object rather than
+# a version script and forcibly exported is unaffected by section GC.
+if { [check_gc_sections_available] } {
+    run_ld_link_tests [list \
+	[list \
+	    "PR ld/20828 dynamic symbols with section GC\
+	     (auxiliary shared library)" \
+	    "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \
+	    {pr20828.s} \
+	    {{readelf --dyn-syms pr20828-a.sd} \
+	     {readelf --dyn-syms pr20828-b.sd}} \
+	    "libpr20828.so"] \
+	[list \
+	    "PR ld/20828 dynamic symbols with section GC (plain)" \
+	    "$LFLAGS -shared --gc-sections -T pr20828.ld" \
+	    "tmpdir/libpr20828.so" "$AFLAGS_PIC" \
+	    {pr20828.s} \
+	    {{readelf --dyn-syms pr20828-a.sd} \
+	     {readelf --dyn-syms pr20828-b.sd}} \
+	    "pr20828-1.so"] \
+	[list \
+	    "PR ld/20828 dynamic symbols with section GC (version script)" \
+	    "$LFLAGS -shared --gc-sections -T pr20828.ld\
+	     --version-script=pr20828.ver" \
+	    "tmpdir/libpr20828.so" \
+	    "$AFLAGS_PIC" \
+	    {pr20828.s} \
+	    {{readelf --dyn-syms pr20828-b.sd} \
+	     {readelf --dyn-syms pr20828-c.sd}} \
+	    "pr20828-2.so"] \
+	[list \
+	    "PR ld/20828 dynamic symbols with section GC\
+	     (versioned shared library)" \
+	    "$LFLAGS -shared --gc-sections -T pr20828.ld\
+	     --version-script=pr20828-v.ver" \
+	    "" "$AFLAGS_PIC" \
+	    {pr20828.s} \
+	    {{readelf --dyn-syms pr20828-c.sd} \
+	     {readelf --dyn-syms pr20828-d.sd} \
+	     {readelf --dyn-syms pr20828-e.sd}} \
+	    "libpr20828-v.so"] \
+	[list \
+	    "PR ld/20828 dynamic symbols with section GC (versioned)" \
+	    "$LFLAGS -shared --gc-sections -T pr20828.ld\
+	     --version-script=pr20828-v.ver" \
+	    "tmpdir/libpr20828-v.so" \
+	    "$AFLAGS_PIC" \
+	    {pr20828.s} \
+	    {{readelf --dyn-syms pr20828-c.sd} \
+	     {readelf --dyn-syms pr20828-d.sd} \
+	     {readelf --dyn-syms pr20828-e.sd}} \
+	    "pr20828-v.so"] \
+	[list \
+	    "PR ld/20828 forcibly exported symbol version without section GC" \
+	    "$LFLAGS --no-dynamic-linker -e foo -E -T pr20828-v.ld" "" "" \
+	    {pr20828-v.s} \
+	    {{objdump -p pr20828-v.od}} \
+	    "pr20828-v-1"] \
+	[list \
+	    "PR ld/20828 forcibly exported symbol version with section GC" \
+	    "$LFLAGS --no-dynamic-linker -e foo --gc-sections -E -T pr20828-v.ld" "" "" \
+	    {pr20828-v.s} \
+	    {{objdump -p pr20828-v.od}} \
+	    "pr20828-v-2"]]
+}
+# PR ld/21233 check for correct dynamic symbol table entries where:
+# - a symbol has been defined in a shared library used in the link,
+# - the symbol has been referenced from a section swept in garbage collection,
+# - the symbol has also been forced to be entered in the output file as an
+#   undefined symbol, either with a command-line option or a linker script
+#   command.
+# Verify that the undefined symbol is global rather than local.
+if { [check_gc_sections_available] } {
+    run_ld_link_tests [list \
+	[list \
+	    "PR ld/21233 dynamic symbols with section GC\
+	     (auxiliary shared library)" \
+	    "$LFLAGS -shared -T pr21233.ld" "" "$AFLAGS_PIC" \
+	    {pr21233-l.s} \
+	    {{readelf --dyn-syms pr21233-l.sd}} \
+	    "libpr21233.so"]]
+
+    run_ld_link_tests [list \
+	[list \
+	    "PR ld/21233 dynamic symbols with section GC (--undefined)" \
+	    "$LFLAGS --gc-sections -e foo --undefined=bar -T pr21233.ld" \
+	    "tmpdir/libpr21233.so" "" \
+	    {pr21233.s} \
+	    {{readelf --dyn-syms pr21233.sd}} \
+	    "pr21233-1"]]
+
+    run_ld_link_tests [list \
+	[list \
+	    "PR ld/21233 dynamic symbols with section GC (--require-defined)" \
+	    "$LFLAGS --gc-sections -e foo --require-defined=bar\
+	     -T pr21233.ld" \
+	    "tmpdir/libpr21233.so" "" \
+	    {pr21233.s} \
+	    {{readelf --dyn-syms pr21233.sd}} \
+	    "pr21233-2"]]
+
+    run_ld_link_tests [list \
+	[list \
+	    "PR ld/21233 dynamic symbols with section GC (EXTERN)" \
+	    "$LFLAGS --gc-sections -e foo -T pr21233-e.ld" \
+	    "tmpdir/libpr21233.so" "" \
+	    {pr21233.s} \
+	    {{readelf --dyn-syms pr21233.sd}} \
+	    "pr21233-3"]]
+}
+
+if { [check_gc_sections_available] } {
+    run_ld_link_tests [list \
+	[list \
+	    "Build pr22150.so" \
+	    "$LFLAGS -shared --version-script pr22150.ver" \
+	    "" \
+	    "$AFLAGS_PIC" \
+	    {pr22150a.s} \
+	    {} \
+	    "pr22150.so" \
+	] \
+	[list \
+	    "Build pr22150" \
+	    "$LFLAGS -e _start --gc-sections" \
+	    "tmpdir/pr22150.so" \
+	    "" \
+	    {pr22150b.s} \
+	    {{readelf -V pr22150.vd}} \
+	    "pr22150" \
+	] \
+    ]
+
+    switch -glob $target_triplet {
+	# exclude targets that don't support copy relocs
+	bfin-*-* { }
+	frv-*-* { }
+	lm32-*-* { }
+	mips*-*-* { }
+	tic6x-*-* { }
+	xtensa-*-* { }
+	default {
+	    run_ld_link_tests [list \
+		[list \
+		     "Build pr25458.so" \
+		     "$LFLAGS -shared --version-script=pr25458.map" \
+		     "" \
+		     "$AFLAGS_PIC" \
+		     {pr25458b.s} \
+		     {} \
+		     "pr25458.so" \
+		] \
+		[list \
+		     "Build pr25458" \
+		     "$LFLAGS -e _start --gc-sections" \
+		     "tmpdir/pr25458.so" \
+		     "$AFLAGS_PIC" \
+		     {pr25458a.s} \
+		     {{readelf {--dyn-sym --wide} pr25458.rd}} \
+		     "pr25458" \
+		] \
+	    ]
+	}
+    }
+}
+
+set ASFLAGS $old_ASFLAGS
+
+run_ld_link_tests {
+    {"Build pr14170a.o" "" "" "" {pr14170a.s} {} "pr14170.a" }
+}
+run_ld_link_tests [list \
+    [list "Build shared library for pr14170" \
+	"-shared" "" "$AFLAGS_PIC" "pr14170b.s" {} "pr14170.so" ] \
+]
+
+# bfin does not currently support copy relocs.
+setup_xfail bfin-*-*
+clear_xfail bfin-*-linux*
+run_ld_link_tests [list \
+    [list "PR ld/14170" \
+	"$LFLAGS --no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" \
+	$hpux \
+	 {pr14170c.s} { } "pr14170" ] \
+]
+
+# Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests
+# Nor will hppa64 with dot-symbols.
+run_ld_link_tests [list \
+    [list "PR ld/21703 shared" \
+	"$LFLAGS -shared --allow-multiple-definition --version-script pr21703.ver\
+	 tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "$AFLAGS_PIC" \
+	{pr21703-3.s pr21703-4.s} {{readelf {--dyn-syms} pr21703-shared.sd}} \
+	"pr21703.so" ] \
+] \[is_generic\] hppa64-*-*
+
+# This target requires extra GAS options when building non-PIC code
+# for linking with shared libraries.
+set AFLAGS_NONPIC ""
+if [istarget "mips*-*-*"] {
+    append AFLAGS_NONPIC " -call_nonpic"
+}
+
+# Run a test to check linking a shared library with a broken linker
+# script that accidentally marks dynamic sections as notes.  The
+# resulting executable is not expected to work, but the linker
+# should not seg-fault whilst creating the binary.
+run_ld_link_tests [list \
+    [list "Build shared library for broken linker script test" \
+	"-shared --hash-style=sysv" "" "$AFLAGS_PIC" "note-3.s" \
+	{} \
+	"note-3.so" ] \
+    [list "Link using broken linker script" \
+	"$LFLAGS --script note-3.t tmpdir/note-3.so" "" "" "" \
+	{ { ld "note-3.l" } } \
+	"a.out" ] \
+]
+
+run_ld_link_tests [list \
+    [list "Build pr17068.so" \
+	"-shared" "" "$AFLAGS_PIC" \
+	{pr17068d.s} {} "pr17068.so"] \
+    [list "Build pr17068a.a" \
+	"" "" "" \
+	{pr17068a.s pr17068c.s pr17068ez.s} {} "pr17068a.a"] \
+    [list "Build pr17068b.a" \
+	"" "" "" \
+	{pr17068b.s pr17068e.s} {} "pr17068b.a"] \
+]
+
+# bfin does not currently support copy relocs.
+setup_xfail bfin-*-*
+clear_xfail bfin-*-linux*
+run_ld_link_tests {
+    {"pr17068 link --as-needed lib in group"
+	"$LFLAGS --as-needed --no-dynamic-linker"
+	"--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a\
+	 --end-group" ""
+	{start.s pr17068.s} {} "pr17068"}
+}
+
+# Fails on MIPS because ABI trickery means that a NULL reloc is emitted.
+# Fails on bfin because relocations are not created.
+setup_xfail mips*-*-* bfin-*-*
+clear_xfail bfin-*-linux*
+run_ld_link_tests [list \
+    [list "-Bsymbolic-functions" \
+	"-shared -Bsymbolic-functions $NO_DT_RELR_LDFLAGS" \
+	"" "$AFLAGS_PIC" \
+	{symbolic-func.s} {{readelf {-r --wide} symbolic-func.r}} \
+	"symbolic-func.so"] \
+]
+
+run_ld_link_tests [list \
+    [list "Build pr20995.so" \
+	"-shared" "" "$AFLAGS_PIC" \
+	{pr20995b.s} {} "pr20995.so"] \
+]
+
+# These targets don't copy dynamic variables into .bss.
+setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
+# or don't have .data.rel.ro
+setup_xfail "hppa*64*-*-hpux*" "tic6x-*-*"
+# or complain about relocs in read-only sections
+setup_xfail frv-*-* lm32-*-*
+run_ld_link_tests [list \
+    [list \
+	"pr20995" \
+	"$LFLAGS" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \
+	{pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]]
+
+# xfail on targets that don't support GNU_RELRO.
+#   For more details, please see discussions at:
+#   https://sourceware.org/ml/binutils/2017-01/msg00441.html
+run_ld_link_tests [list \
+    [list "Build pr20995-2.so" \
+	"-shared -z relro" "" "$AFLAGS_PIC" \
+	{pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"] \
+] {![check_relro_support]}
+
+setup_xfail alpha-*-* xtensa-*-*
+run_ld_link_tests [list \
+    [list \
+	"pr20995-2" \
+	"$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \
+	{pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"]
+] {![check_relro_support]}
+
+run_ld_link_tests [list \
+    [list "Build pr22374 shared library" \
+	"-shared" "" "$AFLAGS_PIC" "pr22374b.s" {} "pr22374.so" ] \
+]
+
+# The next test checks that copy relocs are not used unnecessarily,
+# but that is just an optimization so don't complain loudly.
+setup_xfail *-*-*
+clear_xfail alpha-*-* bfin-*-linux* csky-*-* frv-*-* hppa*-*-* i?86-*-*
+clear_xfail ia64-*-* microblaze-*-* powerpc*-*-* x86_64-*-* xtensa-*-*
+run_ld_link_tests {
+    {"pr22374 function pointer initialization"
+	"" "tmpdir/pr22374.so" "" "pr22374a.s"
+	{ {readelf {--wide -r --dyn-syms} "pr22374-1.r"}
+	  {readelf {--wide -r} "pr22374-2.r"} }
+	"pr22374" }
+}
+
+if { [istarget *-*-linux*]
+     || [istarget *-*-nacl*]
+     || [istarget *-*-gnu*] } {
+    run_ld_link_tests {
+	{"Weak symbols in dynamic objects 1 (support)"
+	    "-shared" "" "" {weak-dyn-1a.s}
+	    {}
+	    "libweakdyn1a.so"}
+	{"Weak symbols in dynamic objects 1 (main test)"
+	    "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s}
+	    {{readelf {--relocs --wide} weak-dyn-1.rd}}
+	    "libweakdyn1b.so"}
+    }
+}
+
+# Check to see if the C compiler works
+if { ![check_compiler_available] } {
+    return
+}
+
+# Add -ldl to extralibs if needed
+set extralibs ""
+if { ![istarget *-*-freebsd*]} {
+    set extralibs "-ldl"
+}
+
+set build_tests {
+  {"Build libfoo.so"
+   "-shared" "-fPIC"
+   {foo.c} {} "libfoo.so"}
+  {"Build versioned libfoo.so"
+   "-shared -Wl,--version-script=foo.map" "-fPIC"
+   {foo.c} {} "libfoov.so"}
+  {"Build libbar.so"
+   "-shared" "-fPIC"
+   {begin.c end.c} {} "libbar.so"}
+  {"Build warn libbar.so"
+   "-shared" "-fPIC"
+  {beginwarn.c end.c}
+  {{readelf {-S --wide} libbarw.rd}
+   {warning "^.*beginwarn.c:7: warning: function foo is deprecated\n?$"}}
+  "libbarw.so" "c"}
+  {"Build hidden libbar.so"
+   "-shared" "-fPIC"
+   {begin.c endhidden.c} {} "libbarh.so"}
+  {"Build protected libbar.so"
+   "-shared" "-fPIC"
+   {begin.c endprotected.c} {} "libbarp.so"}
+  {"Build libbar.so with libfoo.so"
+   "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
+   {end.c} {} "libbarfoo.so"}
+  {"Build libar.so with versioned libfoo.so"
+   "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
+   {end.c} {} "libbarfoov.so"}
+  {"Build hidden libbar.so with libfoo.so"
+   "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
+   {endhidden.c} {} "libbarhfoo.so"}
+  {"Build hidden libar.so with versioned libfoo.so"
+   "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
+   {endhidden.c} {} "libbarhfoov.so"}
+  {"Build protected libbar.so with libfoo.so"
+   "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
+   {endprotected.c} {} "libbarpfoo.so"}
+  {"Build protected libbar.so with versioned libfoo.so"
+   "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
+   {endprotected.c} {} "libbarpfoov.so"}
+  {"Build libdl1.so"
+   "-shared" "-fPIC"
+   {dl1.c} {} "libdl1.so"}
+  {"Build libdl2a.so with --dynamic-list=dl2.list"
+   "-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2a.so"}
+  {"Build libdl2a.so with --dynamic-list=dl2a.list"
+   "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2a.so"}
+  {"Build libdl2a.so with --dynamic-list-data"
+   "-shared -Wl,--dynamic-list-data" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2a.so"}
+  {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
+   "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2b.so"}
+  {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list"
+   "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2c.so"}
+  {"Build libdl2d.so with --dynamic-list-data -Bsymbolic"
+   "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2d.so"}
+  {"Build libdl2e.so with --export-dynamic-symbol=foo"
+   "-shared -Wl,--export-dynamic-symbol=foo" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2e.so"}
+  {"Build libdl2f.so with --dynamic-list=dlempty.list and --export-dynamic-symbol=foo"
+   "-shared -Wl,--dynamic-list=dlempty.list,--export-dynamic-symbol=foo" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2f.so"}
+  {"Build libdl2g.so with --export-dynamic-symbol-list=dl2.list"
+   "-shared -Wl,--export-dynamic-symbol-list=dl2.list" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2g.so"}
+  {"Build libdl2h.so with --dynamic-list=dlempty.list and --export-dynamic-symbol-list=dl2.list"
+   "-shared -Wl,--dynamic-list=dlempty.list,--export-dynamic-symbol-list=dl2.list" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2h.so"}
+  {"Build libdl2i.so with -Bsymbolic and --export-dynamic-symbol=foo"
+   "-shared -Wl,-Bsymbolic,--export-dynamic-symbol=foo" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2i.so"}
+  {"Build libdl2j.so with -Bsymbolic and --export-dynamic-symbol-list=dl2.list"
+   "-shared -Wl,-Bsymbolic,--export-dynamic-symbol-list=dl2.list" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2j.so"}
+  {"Build libdl2k.so with --export-dynamic-symbol-list=dl2.list and -Bsymbolic"
+   "-shared -Wl,--export-dynamic-symbol-list=dl2.list,-Bsymbolic" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2k.so"}
+  # Check that -Bno-symbolic cancels -Bsymbolic.
+  {"Build libdl2l.so with -Bsymbolic -Bno-symbolic and --export-dynamic-symbol=foo"
+   "-shared -Wl,-Bsymbolic,-Bno-symbolic,--export-dynamic-symbol=foo" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2l.so"}
+  {"Build libdl4a.so with --dynamic-list=dl4.list"
+   "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
+   {dl4.c dl4xxx.c} {} "libdl4a.so"}
+  {"Build libdl4b.so with --dynamic-list-data"
+   "-shared -Wl,--dynamic-list-data" "-fPIC"
+   {dl4.c dl4xxx.c} {} "libdl4b.so"}
+  {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list"
+   "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
+   {dl4.c dl4xxx.c} {} "libdl4c.so"}
+  {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list"
+   "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC"
+   {dl4.c dl4xxx.c} {} "libdl4d.so"}
+  {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new"
+   "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
+   {dl4.c dl4xxx.c} {} "libdl4e.so"}
+  {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions"
+   "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC"
+   {dl4.c dl4xxx.c} {} "libdl4f.so"}
+  {"Build libdl6a.so"
+   "-shared" "-fPIC"
+   {dl6.c} {} "libdl6a.so"}
+  {"Build libdl6b.so with -Bsymbolic --dynamic-list-data"
+   "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC"
+   {dl6.c} {} "libdl6b.so"}
+  {"Build libdl6c.so with -Bsymbolic"
+   "-shared -Wl,-Bsymbolic" "-fPIC"
+   {dl6.c} {} "libdl6c.so"}
+  {"Build libdl6d.so with --dynamic-list-data -Bsymbolic"
+   "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC"
+   {dl6.c} {} "libdl6d.so"}
+  {"Build libdata1.so"
+   "-shared" "-fPIC"
+   {data1.c} {} "libdata1.so"}
+  {"Build libdata2.so"
+   "-shared" "-fPIC"
+   {data2.c} {} "libdata2.so"}
+  {"Build libcomm1.o"
+   "-r -nostdlib" "-fcommon"
+   {comm1.c} {} "libcomm1.o"}
+  {"Build libfunc1.so"
+   "-shared" "-fPIC"
+   {func1.c} {} "libfunc1.so"}
+  {"Build libpr9676-1.a"
+   "" "-fPIC"
+   {pr9676-1.c} {} "libpr9676-1.a"}
+  {"Build libpr9676-2.a"
+   "" "-fPIC"
+   {pr9676-2.c} {} "libpr9676-2.a"}
+  {"Build libpr9676-3.so"
+   "-shared" "-fPIC"
+   {pr9676-3.c} {} "libpr9676-3.so"}
+  {"Build libpr9676-4.so"
+   "-shared" "-fPIC"
+   {pr9676-4.c} {} "libpr9676-4.so"}
+  {"Build libpr9676-4a.so"
+   "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group"
+   "-fPIC"
+   {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"}
+  {"Build libpr9679.so"
+   "-shared" "-fPIC -O0"
+   {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"}
+  {"Build libpr11138-1.so"
+   "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
+   {pr11138-1.c} {} "libpr11138-1.so"}
+  {"Build libpr11138-2.o"
+   "-r -nostdlib" ""
+   {pr11138-2.c} {} "libpr11138-2.o"}
+  {"Build pr13250-1.so"
+   "-shared" "-fPIC -fcommon"
+   {pr13250-1.c} {} "libpr13250-1.so"}
+  {"Build pr13250-2.so with libpr13250-1.so"
+   "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC -fcommon"
+   {pr13250-2.c} {} "libpr13250-2.so"}
+  {"Build libpr13250-3.o"
+   "-r -nostdlib" "-fcommon"
+   {pr13250-3.c} {} "libpr13250-3.o"}
+  {"Build libpr14323-2.so"
+   "-shared" "-fPIC -fcommon"
+   {pr14323-2.c} {} "libpr14323-2.so"}
+  {"Build pr14862-1.o"
+   "-r -nostdlib" ""
+   {pr14862-1.c} {} "libpr14862-1.o"}
+  {"Build libpr14862.so"
+   "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
+   {pr14862-2.c} {} "libpr14862.so"}
+  {"Build libneeded1b.so"
+   "-shared" "-fPIC"
+   {needed1b.c} {} "libneeded1b.so"}
+  {"Build libneeded1a.so"
+   "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC"
+   {needed1a.c} {} "libneeded1a.so"}
+  {"Build libneeded1c.o"
+   "-r -nostdlib" ""
+   {needed1c.c} {} "libneeded1c.o"}
+  {"Build libneeded1pic.o"
+   "-r -nostdlib" "-fPIC"
+   {needed1c.c} {} "libneeded1pic.o"}
+  {"Build needed1a.so with --add-needed"
+   "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
+   {dummy.c} {} "needed1a.so"}
+  {"Build needed1b.so with --copy-dt-needed-entries"
+   "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
+   {dummy.c} {} "needed1b.so"}
+  {"Build needed1a.so with --no-add-needed"
+   "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-add-needed -Ltmpdir -lneeded1a" ""
+   {dummy.c} {} "needed1c.so"}
+  {"Build needed1b.so with --no-copy-dt-needed-entries"
+   "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" ""
+   {dummy.c} {} "needed1d.so"}
+  {"Build librel.so"
+   "-shared" "-fPIC"
+   {rel.c} {} "librel.so"}
+  {"Build libneeded2a.so"
+   "-shared" "-fPIC"
+   {needed2a.c} {} "libneeded2a.so"}
+  {"Build libneeded2b.so"
+   "-shared -Wl,--version-script,needed2.ver" "-fPIC"
+   {needed2b.c} {} "libneeded2b.so"}
+  {"Build libneeded2c.o"
+   "-r -nostdlib" ""
+   {needed2c.c} {} "libneeded2c.o"}
+  {"Build needed2"
+   "tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" ""
+   {dummy.c} {} "needed2"}
+  {"Build libneeded3a.so"
+   "-shared -Wl,--no-add-needed" "-fPIC"
+   {needed1a.c} {} "libneeded3a.so"}
+  {"Build libneeded3b.so"
+   "-shared -Wl,--no-as-needed,--add-needed -Ltmpdir -lneeded1b" "-fPIC"
+   {dummy.c} {} "libneeded3b.so"}
+  {"Build needed3.o"
+   "-r -nostdlib" ""
+   {needed3.c} {} "libneeded3.so"}
+  {"Build needed3"
+   "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" ""
+   {dummy.c} {} "needed3"}
+  {"Build rdynamic-1"
+   "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections"
+   {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
+  {"Build dynamic-1"
+   "-Wl,--no-dynamic-linker,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections"
+   {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"}
+  {"Build libpr16496a.so"
+   "-shared -Wl,--version-script=pr16496a.map" "-fPIC"
+   {pr16496a.c} {} "libpr16496a.so"}
+  {"Build libpr16496b.a"
+   "" "-fPIC"
+   {pr16496b.c} {} "libpr16496b.a"}
+  {"Build libpr16496b.so"
+   "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
+   {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"}
+  {"Build libpr16452a.so"
+   "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC"
+   {pr16452a.c} {} "libpr16452a.so"}
+  {"Build libpr16452b.so"
+   "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC"
+   {dummy.c} {} "libpr16452b.so"}
+  {"Build pr16452"
+   "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
+   {pr16452b.c} {{objdump {-p} pr16452.od}} "pr16452"}
+  {"Build pr16457"
+   "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
+   {pr16452b.c} {{objdump {-p} pr16457.od}} "pr16457"}
+  {"Build libpr18458a.so"
+   "-shared -Wl,-z,now" "-fPIC"
+   {pr18458a.c} {} "libpr18458a.so"}
+  {"Build libpr18458b.so"
+   "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC"
+   {pr18458b.c} {} "libpr18458b.so"}
+}
+
+run_cc_link_tests [list \
+    [list \
+	"Build libpr2404a.so" \
+	"-shared $NOSANITIZE_CFLAGS" \
+	"-fPIC $NOSANITIZE_CFLAGS" \
+	{pr2404a.c} \
+	{} \
+	"libpr2404a.so" \
+    ] \
+    [list \
+	"Build libpr2404n.so" \
+	"-shared -Wl,-z,now $NOSANITIZE_CFLAGS" \
+	"-fPIC $NOSANITIZE_CFLAGS" \
+	{pr2404a.c} \
+	{} \
+	"libpr2404n.so" \
+    ] \
+    [list \
+	"Build libpr2404b.a" \
+	"" \
+	"$NOSANITIZE_CFLAGS" \
+	{pr2404b.c} \
+	{} \
+	"libpr2404b.a" \
+    ] \
+    [list \
+	"Build libpr26590a.so" \
+	"-shared" \
+	"-fPIC" \
+	{pr26590a.c} \
+	{} \
+	"libpr26590a.so" \
+    ] \
+    [list \
+	"Build libpr26590b.so (1)" \
+	"-shared" \
+	"-fPIC" \
+	{pr26590b.c} \
+	{} \
+	"libpr26590b.so" \
+    ] \
+    [list \
+	"Build pr26590c.o and pr26590d.o" \
+	"" \
+	"" \
+	{pr26590c.c pr26590d.c} \
+	{} \
+    ] \
+    [list \
+	"Build pr26590 (1)" \
+	"tmpdir/pr26590c.o tmpdir/pr26590d.o \
+	 -Wl,--as-needed tmpdir/libpr26590a.so tmpdir/libpr26590b.so" \
+	"" \
+	{dummy.c} \
+	{{error_output pr26590.err}} \
+	"pr26590" \
+    ] \
+    [list \
+	"Build libpr26590b.so (2)" \
+	"-shared -Wl,--no-as-needed \
+	 tmpdir/libpr26590a.so" \
+	"-fPIC" \
+	{pr26590b.c} \
+	{} \
+	"libpr26590b.so" \
+    ] \
+    [list \
+	"Build pr26590 (2)" \
+	"tmpdir/pr26590c.o tmpdir/pr26590d.o \
+	 -Wl,--as-needed tmpdir/libpr26590a.so tmpdir/libpr26590b.so" \
+	"" \
+	{dummy.c} \
+	{} \
+	"pr26590" \
+    ] \
+    [list \
+	"Build libpr28348a.so" \
+	"-shared -Wl,--version-script=pr28348.t" \
+	"-fPIC" \
+	{pr28348a.c} \
+	{} \
+	"libpr28348a.so" \
+    ] \
+    [list \
+	"Build pr28348b.o" \
+	"" \
+	"-fPIC" \
+	{pr28348b.c} \
+    ] \
+    [list \
+	"Build pr28348c.o" \
+	"" \
+	"" \
+	{pr28348c.c} \
+    ] \
+    [list \
+	"Build libpr28348b.so" \
+	"-shared -Wl,--version-script=pr28348.t \
+	 -Wl,--no-as-needed tmpdir/pr28348b.o tmpdir/libpr28348a.so" \
+	"-fPIC" \
+	{dummy.c} \
+	{} \
+	"libpr28348b.so" \
+    ] \
+    [list \
+	"Build pr28348" \
+	"-Wl,--no-as-needed tmpdir/pr28348c.o \
+	 tmpdir/pr28348a.o tmpdir/libpr28348a.so tmpdir/libpr28348b.so \
+	 tmpdir/libpr28348a.so" \
+	"" \
+	{dummy.c} \
+	{{readelf {--dyn-syms --wide} pr28348.rd}} \
+	"pr28348" \
+    ] \
+]
+
+# pr19073.s uses .set, which has a different meaning on alpha.
+if { ![istarget alpha-*-*] } {
+    append build_tests {
+	{"Build pr19073a.o"
+	 "-r -nostdlib" ""
+	 {pr19073.s} {} "pr19073a.o"}
+	{"Build libpr19073.so"
+	 "-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC"
+	 {dummy.c} {{readelf {--dyn-syms --wide} pr19073.rd}} "libpr19073.so"}
+    }
+}
+append build_tests {
+  {"Build pr21964-1a.so"
+   "-shared" "-fPIC"
+   {pr21964-1a.c} {} "pr21964-1a.so"}
+  {"Build pr21964-1b.so"
+   "-shared" "-fPIC"
+   {pr21964-1b.c} {} "pr21964-1b.so"}
+  {"Build pr21964-2a.so"
+   "-shared" "-fPIC"
+   {pr21964-2a.c} {} "pr21964-2a.so"}
+  {"Build pr21964-2b.so"
+   "-shared" "-fPIC"
+   {pr21964-2b.c} {} "pr21964-2b.so"}
+  {"Build pr21964-3a.so"
+   "-shared" "-fPIC"
+   {pr21964-3a.c} {} "pr21964-3a.so"}
+  {"Dump pr21978.so"
+   "-shared" "-fPIC -g -O2"
+   {pr21978a.c pr21978b.c} {{objdump {-Sl} pr21978.od}} "pr21978.so"}
+  {"libpr26580-2.so"
+   "-shared" "-fPIC -fcommon"
+   {pr26580-b.c} {} "libpr26580-2.so"}
+}
+
+run_cc_link_tests $build_tests
+
+run_cc_link_tests [list \
+    [list \
+	"Build pr26094-1.so" \
+	"-shared -Wl,--version-script=pr26094-1.ver" \
+	"-fPIC" \
+	{pr26094-1a.c} \
+	{{readelf {--dyn-syms --wide} pr26094-1a.rd}} \
+	"pr26094-1.so" \
+    ] \
+    [list \
+	"Build pr26094-1" \
+	"-Wl,--no-as-needed tmpdir/pr26094-1.so" \
+	"-fcommon" \
+	{pr26094-1b.c pr26094-1c.c} \
+	{{readelf {--dyn-syms --wide} pr26094-1b.rd}} \
+	"pr26094-1" \
+    ] \
+    [list \
+	"Build pr26302a.so" \
+	"-shared -Wl,--version-script=pr26302.ver" \
+	"-fPIC" \
+	{pr26302a.c} \
+	{} \
+	"pr26302a.so"
+    ] \
+    [list \
+	"Build pr26302b.so" \
+	"-shared -Wl,--no-as-needed tmpdir/pr26302a.so" \
+	"-fPIC" \
+	{pr26302b.c} \
+	{{readelf {-sW} pr26302.rd} \
+	 {nm {-u} pr26302.nd} \
+	 {nm {-u -D} pr26302.nd} \
+	 {nm {-u -D --with-symbol-versions} pr26302.nd}} \
+	"pr26302b.so" \
+    ] \
+]
+
+run_ld_link_tests [list \
+    [list \
+	"pr22269-1 (static pie undefined weak)" \
+	"-pie -e _start --no-dynamic-linker -z text -z nocombreloc " \
+	"" \
+	"$AFLAGS_PIC" \
+	{ pr22269-1.c } \
+	{{readelf -rW pr22269-1.rd}} \
+	"pr22269-1" \
+	"-fPIE -O2 $NOSANITIZE_CFLAGS" \
+    ] \
+]
+
+set run_tests [list \
+    [list "Run normal with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \
+     {main.c} "normal" "normal.out" ] \
+    [list "Run protected with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \
+     {main.c} "protected" "normal.out" ] \
+    [list "Run hidden with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \
+     {main.c} "hidden" "hidden.out" ] \
+    [list "Run normal with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \
+     {main.c} "normalv" "normal.out" ] \
+    [list "Run warn with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \
+     {main.c} "warn" "warn.out" \
+     "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated\n?$} ] \
+    [list "Run protected with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \
+     {main.c} "protected" "normal.out" ] \
+    [list "Run hidden with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \
+     {main.c} "hiddenv" "hidden.out" ] \
+    [list "Run normal libbar.so with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \
+     {main.c} "normal" "normal.out" ] \
+    [list "Run protected libbar.so with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \
+     {main.c} "protected" "normal.out" ] \
+    [list "Run hidden libbar.so with libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \
+     {main.c} "hidden" "hidden.out" ] \
+    [list "Run normal libbar.so with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \
+     {main.c} "normal" "normal.out" ] \
+    [list "Run protected libbar.so with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \
+     {main.c} "protected" "normal.out" ] \
+    [list "Run hidden libbar.so with versioned libfoo.so" \
+     "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \
+     {main.c} "hidden" "hidden.out" ] \
+    [list "Run with libdl2a.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \
+     {dl2main.c} "dl2a" "dl2a.out" ] \
+    [list "Run with libdl2b.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \
+     {dl2main.c} "dl2b" "dl2b.out" ] \
+    [list "Run with libdl2c.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \
+     {dl2main.c} "dl2c" "dl2b.out" ] \
+    [list "Run with libdl2d.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2d.so" "" \
+     {dl2main.c} "dl2d" "dl2a.out" ] \
+    [list "Run with libdl2e.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2e.so" "" \
+     {dl2main.c} "dl2e" "dl2b.out" ] \
+    [list "Run with libdl2f.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2f.so" "" \
+     {dl2main.c} "dl2f" "dl2a.out" ] \
+    [list "Run with libdl2g.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2g.so" "" \
+     {dl2main.c} "dl2g" "dl2b.out" ] \
+    [list "Run with libdl2h.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2h.so" "" \
+     {dl2main.c} "dl2h" "dl2a.out" ] \
+    [list "Run with libdl2i.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2i.so" "" \
+     {dl2main.c} "dl2i" "dl2a.out" ] \
+    [list "Run with libdl2j.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2j.so" "" \
+     {dl2main.c} "dl2j" "dl2a.out" ] \
+    [list "Run with libdl2k.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2k.so" "" \
+     {dl2main.c} "dl2k" "dl2a.out" ] \
+    [list "Run with libdl2l.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2l.so" "" \
+     {dl2main.c} "dl2l" "dl2b.out" ] \
+    [list "Run with libdl4a.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
+     {dl4main.c} "dl4a" "dl4a.out" "-fPIC"] \
+    [list "Run with libdl4b.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \
+     {dl4main.c} "dl4b" "dl4a.out" "-fPIC"] \
+    [list "Run with libdl4c.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \
+     {dl4main.c} "dl4c" "dl4b.out" "-fPIC"] \
+    [list "Run with libdl4d.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \
+     {dl4main.c} "dl4d" "dl4b.out" "-fPIC"] \
+    [list "Run with libdl4e.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \
+     {dl4main.c} "dl4e" "dl4a.out" "-fPIC"] \
+    [list "Run with libdl4f.so" \
+     "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
+     {dl4main.c} "dl4f" "dl4a.out" "-fPIC"] \
+    [list "Run with libdata1.so" \
+     "-Wl,--no-as-needed tmpdir/libdata1.so" "" \
+     {dynbss1.c} "dynbss1" "pass.out" ] \
+    [list "Run with libdata2.so" \
+     "-Wl,--no-as-needed tmpdir/libdata2.so" "" \
+     {weakdef1.c} "weakdef1" "pass.out" ] \
+    [list "Run with libfunc1.so comm1.o" \
+     "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \
+     {dummy.c} "comm1" "pass.out" ] \
+    [list "Run with comm1.o libfunc1.so" \
+     "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \
+     {dummy.c} "comm1" "pass.out" ] \
+    [list "Run with pr11138-2.c libpr11138-1.so" \
+     "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \
+     {dummy.c} "pr11138a" "pr11138.out" ] \
+    [list "Run with libpr11138-1.so pr11138-2.c" \
+     "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \
+     {dummy.c} "pr11138b" "pr11138.out" ] \
+    [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \
+     "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "-fcommon" \
+     {dummy.c} "pr13250" "pass.out" ] \
+    [list "Run with pr14323-1.c pr14323-2.so" \
+     "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \
+     {pr14323-1.c} "pr14323" "pass.out" ] \
+    [list "Run with pr14862-1.c libpr14862.so" \
+     "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \
+     {dummy.c} "pr14862" "pr14862.out" ] \
+    [list "Link with --add-needed" \
+     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
+     {dummy.c} "needed1a" "needed1.out" ] \
+    [list "Link with --copy-dt-needed-entries" \
+     "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
+     {dummy.c} "needed1b" "needed1.out" ] \
+    [list "Run relmain" \
+     "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
+     {relmain.c} "relmain" "relmain.out" ] \
+    [list "Run pr2404" \
+     "$NOSANITIZE_CFLAGS -Wl,--no-as-needed \
+      tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
+     "" \
+     {dummy.c} "pr2404" "pr2404.out" \
+     "$NOSANITIZE_CFLAGS" ] \
+    [list "Run pr2404n" \
+     "$NOSANITIZE_CFLAGS -Wl,-z,now \
+      -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \
+     {dummy.c} "pr2404n" "pr2404.out" \
+     "$NOSANITIZE_CFLAGS" ] \
+    [list "Run pr18458" \
+     "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
+     {pr18458c.c} "pr18458" "pass.out" ] \
+    [list "Run pr21964-1" \
+     "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so" "" \
+     {pr21964-1c.c} "pr21964-1" "pass.out" ] \
+    [list "Run pr21964-3" \
+     "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so tmpdir/pr21964-3a.so" "" \
+     {pr21964-3c.c} "pr21964-3" "pass.out" ] \
+    [list "pr26580-3" \
+     "" "" \
+     {pr26580-a.c} "pr26580-3" "pr26580-3.out" "-fcommon" "c" "" \
+     "-Wl,--as-needed tmpdir/libpr26580-2.so" ] \
+    [list "pr26580-4" \
+     "" "" \
+     {pr26580-a.c} "pr26580-4" "pr26580-4.out" "-fcommon" "c" "" \
+     "-Wl,--no-as-needed tmpdir/libpr26580-2.so" ] \
+    [list "Run pr26590 (2)" \
+     "" "" \
+     {pr26590c.c pr26590d.c} "pr26590" "pass.out" "" "c" "" \
+     "-Wl,--as-needed tmpdir/libpr26590a.so tmpdir/libpr26590b.so" ] \
+]
+
+# NetBSD ELF systems do not currently support the .*_array sections.
+run_ld_link_exec_tests $run_tests "*-*-netbsd*"
+
+# These tests require dlopen support.
+set dlopen_run_tests [list \
+    [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
+     "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
+     {dl1main.c} "dl1a" "dl1.out" ] \
+    [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl1main.c} "dl1b" "dl1.out" ] \
+    [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6amain.c} "dl6a1" "dl6a.out" ] \
+    [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
+     "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
+     {dl6amain.c} "dl6a2" "dl6b.out" "$NOPIE_CFLAGS" ] \
+    [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
+     {dl6amain.c} "dl6a3" "dl6b.out" ] \
+    [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
+     "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
+     {dl6amain.c} "dl6a4" "dl6a.out" ] \
+    [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
+     "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
+     {dl6amain.c} "dl6a5" "dl6b.out" "$NOPIE_CFLAGS" ] \
+    [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
+     "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
+     {dl6amain.c} "dl6a6" "dl6b.out" "$NOPIE_CFLAGS" ] \
+    [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
+     "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
+     {dl6amain.c} "dl6a7" "dl6a.out" "$NOPIE_CFLAGS" ] \
+    [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6bmain.c} "dl6b1" "dl6a.out" ] \
+    [list "Run dl6b2 with dlopen on libdl6b.so" \
+     "-Wl,--no-as-needed $extralibs" "" \
+     {dl6bmain.c} "dl6b2" "dl6b.out" ] \
+    [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6cmain.c} "dl6c1" "dl6b.out" ] \
+    [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
+     "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+     {dl6dmain.c} "dl6d1" "dl6a.out" ] \
+    [list "Run pr21964-2" \
+     "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-2a.so $extralibs" "" \
+     {pr21964-2c.c} "pr21964-2" "pass.out" ] \
+    [list "Run pr21964-5" \
+     "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so $extralibs" "" \
+     {pr21964-5.c} "pr21964-5" "pass.out" ] \
+]
+
+# Only run them when libdl is available.
+if [check_libdl_available] {
+  # XFAIL on NetBSD ELF systems as they do not currently support the .*_array
+  # sections.
+  # Disable all sanitizers.
+  set old_CFLAGS "$CFLAGS_FOR_TARGET"
+  append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS"
+  run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsd*"
+  set CFLAGS_FOR_TARGET "$old_CFLAGS"
+}
+
+# Check --no-add-needed and --no-copy-dt-needed-entries
+set testname "--no-add-needed"
+set exec_output [run_host_cmd "$CC_FOR_TARGET" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
+if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
+    pass $testname
+} {
+    fail $testname
+}
+set testname "--no-copy-dt-needed-entries"
+set exec_output [run_host_cmd "$CC_FOR_TARGET" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
+if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
+    pass $testname
+} {
+    fail $testname
+}
+set testname "--no-add-needed -shared"
+set exec_output [run_host_cmd "$CC_FOR_TARGET" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"]
+if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
+    pass $testname
+} {
+    fail $testname
+}
+set testname "--no-copy-dt-needed-entries -shared"
+set exec_output [run_host_cmd "$CC_FOR_TARGET" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"]
+if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
+    pass $testname
+} {
+    fail $testname
+}
+
+# Check to see if the C++ compiler works
+if { [which $CXX_FOR_TARGET] == 0 } {
+    return
+}
+
+set build_cxx_tests {
+  {"Build libdl3a.so with --dynamic-list=dl3.list"
+   "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
+   {dl3.cc} {} "libdl3a.so" "c++"}
+  {"Build libdl3b.so with -Bsymbolic"
+   "-shared -Wl,-Bsymbolic" "-fPIC"
+   {dl3.cc} {} "libdl3b.so" "c++"}
+  {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
+   "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
+   {dl3.cc} {} "libdl3c.so" "c++"}
+}
+
+run_cc_link_tests [list \
+    [list \
+	"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" \
+	"-shared $NOSANITIZE_CFLAGS -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" \
+	"-fPIC -ansi $NOSANITIZE_CFLAGS" \
+	{del.cc new.cc} \
+	{} \
+	"libnew1a.so" \
+	"c++" \
+    ] \
+    [list \
+	"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" \
+	"-shared $NOSANITIZE_CFLAGS -Wl,--dynamic-list-data,--dynamic-list-cpp-new" \
+	"-fPIC -ansi $NOSANITIZE_CFLAGS" \
+	{del.cc new.cc} \
+	{} \
+	"libnew1b.so" \
+	"c++" \
+    ] \
+]
+
+# "-shared -Bsymbolic" only works with gcc 4.5.0 and newer.
+#    {"Run with libdl3b.so"
+#     "tmpdir/libdl3b.so" ""
+#     {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
+set run_cxx_tests {
+    {"Run with libdl3a.so"
+     "-Wl,--no-as-needed tmpdir/libdl3a.so" ""
+     {dl3main.cc} "dl3a" "dl3a.out" "" "c++"}
+    {"Run with libdl3c.so"
+     "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
+     {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
+}
+
+run_ld_link_exec_tests [list \
+    [list \
+	"Run with libnew1a.so" \
+	"-Wl,--no-as-needed tmpdir/libnew1a.so $NOSANITIZE_CFLAGS" \
+	"" \
+	{dl5.cc} \
+	"dl5a" \
+	"dl5.out" \
+	"-ansi $NOSANITIZE_CFLAGS" \
+	"c++" \
+    ] \
+    [list \
+	"Run with libnew1b.so" \
+	"-Wl,--no-as-needed tmpdir/libnew1b.so $NOSANITIZE_CFLAGS" \
+	"" \
+	{dl5.cc} \
+	"dl5b" \
+	"dl5.out" \
+	"-ansi $NOSANITIZE_CFLAGS" \
+	"c++" \
+    ] \
+]
+
+run_cc_link_tests $build_cxx_tests
+run_ld_link_exec_tests $run_cxx_tests
+
+if { [istarget *-*-linux*]
+     || [istarget *-*-nacl*]
+     || [istarget *-*-gnu*] } {
+    run_cc_link_tests [list \
+	[list \
+	    "Build libpr2404b.a with PIE" \
+	    "" \
+	    "-fPIE $NOSANITIZE_CFLAGS" \
+	    { pr2404b.c } \
+	    {} \
+	    "libpr2404b.a" \
+	] \
+	[list \
+	    "Build pr19579a.o" \
+	    "" "-fPIE -fcommon" \
+	    {pr19579a.c} \
+	    {} \
+	    "libpr19579a.a" \
+	] \
+	[list \
+	    "Build libpr19579.so" \
+	    "-shared" \
+	    "-fPIC -fcommon" \
+	    {pr19579b.c} \
+	    {} \
+	    "libpr19579.so" \
+	] \
+	[list \
+	    "Build libpr19579now.so" \
+	    "-shared -Wl,-z,now" \
+	    "-fPIC -fcommon" \
+	    {pr19579b.c} \
+	    {} \
+	    "libpr19579.so" \
+	] \
+	[list \
+	    "Build pr22393-2a.so" \
+	    "-shared -Wl,-z,separate-code" \
+	    "-fPIC" \
+	    {pr22393-2a.c} \
+	    {{readelf -lW pr22393-2a.rd} \
+	     {readelf -lW pr22393-2b.rd}} \
+	    "pr22393-2a.so" \
+	] \
+	[list \
+	    "Build pr22393-2a-now.so" \
+	    "-shared -Wl,-z,separate-code,-z,now" \
+	    "-fPIC" \
+	    {pr22393-2a.c} \
+	    {{readelf -lW pr22393-2a.rd} \
+	     {readelf -lW pr22393-2b.rd}} \
+	    "pr22393-2a-now.so" \
+	] \
+	[list \
+	    "Build pr22393-2" \
+	    "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \
+	    "$NOPIE_CFLAGS" \
+	    {pr22393-2b.c} \
+	    {{readelf -lW pr22393-2a.rd} \
+	     {readelf -lW pr22393-2b.rd}} \
+	    "pr22393-2" \
+	] \
+	[list \
+	    "Build pr22393-2 (PIE)" \
+	    "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \
+	    "-fPIE" \
+	    {pr22393-2b.c} \
+	    {{readelf -lW pr22393-2a.rd} \
+	     {readelf -lW pr22393-2b.rd}} \
+	    "pr22393-2-pie" \
+	] \
+	[list \
+	    "Build pr22393-2 (static)" \
+	    "-static -Wl,-z,separate-code" \
+	    "" \
+	    {pr22393-2a.c pr22393-2b.c} \
+	    {{readelf -lW pr22393-2a.rd} \
+	     {readelf -lW pr22393-2b.rd}} \
+	    "pr22393-2-static" \
+	] \
+    ]
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run pr18458 with PIE" \
+	    "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" \
+	    "" \
+	    {pr18458c.c} \
+	    "pr18458p" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run pr2404 with PIE" \
+	    "-pie $NOSANITIZE_CFLAGS -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
+	    "" \
+	    { dummy.c } \
+	    "pr2404pie" \
+	    "pr2404.out" \
+	    "-fPIE $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Run pr2404 with PIE (-z now)" \
+	    "-pie $NOSANITIZE_CFLAGS -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
+	    "" \
+	    { dummy.c } \
+	    "pr2404pien" \
+	    "pr2404.out" \
+	    "-fPIE $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Run pr18718" \
+	    "" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718" \
+	    "pass.out" \
+	    "-O2 -I../bfd" \
+	] \
+	[list \
+	    "Run pr18718 (-z now)" \
+	    "-Wl,-z,now" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718" \
+	    "pass.out" \
+	    "-O2 -I../bfd" \
+	] \
+	[list \
+	    "Run pr18718 with PIE (1)" \
+	    "-pie" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718pie1" \
+	    "pass.out" \
+	    "-O2 -fPIE -I../bfd" \
+	] \
+	[list \
+	    "Run pr18718 with PIE (2)" \
+	    "" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718pie2" \
+	    "pass.out" \
+	    "-O2 -fPIE -I../bfd" \
+	] \
+	[list \
+	    "Run pr18718 with PIE (3)" \
+	    "-pie -Wl,-z,now" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718pie3" \
+	    "pass.out" \
+	    "-O2 -fPIE -I../bfd" \
+	] \
+	[list \
+	    "Run pr18718 with PIE (4)" \
+	    "-Wl,-z,now" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718pie4" \
+	    "pass.out" \
+	    "-O2 -fPIE -I../bfd" \
+	] \
+	[list \
+	    "Run pr18718 with PIC (1)" \
+	    "" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718pic1" \
+	    "pass.out" \
+	    "-O2 -fPIC -I../bfd" \
+	] \
+	[list \
+	    "Run pr18718 with PIC (2)" \
+	    "-pie" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718pic2" \
+	    "pass.out" \
+	    "-O2 -fPIC -I../bfd" \
+	] \
+	[list \
+	    "Run pr18718 with PIC (3)" \
+	    "-Wl,-z,now" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718pic3" \
+	    "pass.out" \
+	    "-O2 -fPIC -I../bfd" \
+	] \
+	[list \
+	    "Run pr18718 with PIC (4)" \
+	    "-pie -Wl,-z,now" \
+	    "" \
+	    { pr18718.c check-ptr-eq.c } \
+	    "pr18718pic4" \
+	    "pass.out" \
+	    "-O2 -fPIC -I../bfd" \
+	] \
+	[list \
+	    "Run pr19579" \
+	    "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
+	    "" \
+	    {dummy.c} \
+	    "pr19579" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run pr19579 (-z now)" \
+	    "-pie -Wl,-z,now -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
+	    "" \
+	    {dummy.c} \
+	    "pr19579n" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run pr22393-2" \
+	    "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \
+	    "" \
+	    {pr22393-2b.c} \
+	    "pr22393-2" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run pr22393-2 (PIE)" \
+	    "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \
+	    "" \
+	    {pr22393-2b.c} \
+	    "pr22393-2-pie" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run pr22393-2 (static)" \
+	    "-static -Wl,-z,separate-code" \
+	    "" \
+	    {pr22393-2a.c pr22393-2b.c} \
+	    "pr22393-2-static" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Run pr21964-4" \
+	    "" \
+	    "" \
+	    {pr21964-4.c} \
+	    "pr21964-4" \
+	    "pass.out" \
+	    "" \
+	    "" \
+	    "" \
+	    "-ldl" \
+	] \
+    ]
+}
+
+proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
+    run_cc_link_tests [list \
+	[list \
+	    "Build libpr19719a.so" \
+	    "-shared -Wl,-soname,libpr19719.so" \
+	    "-fPIC" \
+	    { pr19719d.c } \
+	    {} \
+	    "libpr19719a.so" \
+	] \
+	[list \
+	    "Build libpr19719b.so" \
+	    "-shared -Wl,-soname,libpr19719.so" \
+	    "-fPIC" \
+	    { dummy.c } \
+	    {} \
+	    "libpr19719b.so" \
+	] \
+	[list \
+	    "Build libpr19719b.o" \
+	    "-r -nostdlib" \
+	    "-fPIC" \
+	    { pr19719b.c } \
+	    {} \
+	    "libpr19719b.o" \
+	] \
+    ]
+
+    send_log "cp tmpdir/libpr19719b.so tmpdir/libpr19719.so\n"
+    exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so
+
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run $exe fun defined" \
+	    "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \
+	    "" \
+	    { pr19719a.c pr19719c.c } \
+	    $exe \
+	    "pass.out" \
+	    "$cflags" \
+	] \
+    ]
+
+    send_log "cp tmpdir/libpr19719a.so tmpdir/libpr19719.so\n"
+    exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so
+
+    foreach targ $xfails {
+	setup_xfail $targ
+    }
+
+    if ![isnative] {
+	unsupported "Run $exe fun undefined"
+	return
+    }
+
+    set exec_output [run_host_cmd "tmpdir/$exe" ""]
+    if {![string match "PASS" $exec_output]} {
+	fail "Run $exe fun undefined"
+    } else {
+	pass "Run $exe fun undefined"
+    }
+}
+
+mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719"
+mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie"
+
+set AFLAGS_PIE ""
+if { [istarget "i?86-*-*"]
+     || [istarget "x86_64-*-*"] } {
+    set AFLAGS_PIE "-mrelax-relocations=yes"
+}
+if [istarget "sparc*-*-*"] {
+    set AFLAGS_PIE "-Av9"
+}
+
+if { ([istarget "*-*-linux*"]
+      || [istarget "*-*-nacl*"]
+      || [istarget "*-*-gnu*"])
+     && ![istarget "mips*-*-*"] } {
+    run_ld_link_tests [list \
+	[list \
+	    "Build libpr23162a.so" \
+	    "-shared" \
+	    "" \
+	    "$AFLAGS_PIC" \
+	    { pr23162a.c } \
+	    "" \
+	    "libpr23162a.so" \
+	    "-fPIC -O2 $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Build pr23162a" \
+	    "-pie --no-as-needed tmpdir/libpr23162a.so" \
+	    "" \
+	    $AFLAGS_PIE \
+	    { pr23162b.c } \
+	    {{readelf {-rW} pr23162.rd}} \
+	    "pr23162a" \
+	    "-fPIC -O0 $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Build libpr23162b.so" \
+	    "-shared --version-script=pr23162.map" \
+	    "" \
+	    "$AFLAGS_PIC" \
+	    { pr23162a.c } \
+	    "" \
+	    "libpr23162b.so" \
+	    "-fPIC -O2 $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Build pr23162b" \
+	    "-pie --no-as-needed tmpdir/libpr23162b.so" \
+	    "" \
+	    $AFLAGS_PIE \
+	    { pr23162b.c } \
+	    {{readelf {-rW} pr23162.rd}} \
+	    "pr23162b" \
+	    "-fPIC -O0 $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Build libpr23161a.so" \
+	    "-shared" \
+	    "" \
+	    "$AFLAGS_PIC" \
+	    { pr23161a.c } \
+	    {{readelf {--dyn-syms -rW} pr23161a.rd}} \
+	    "libpr23161a.so" \
+	    "-fPIC -O2 $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Build pr23161a" \
+	    "-pie --no-as-needed tmpdir/libpr23161a.so" \
+	    "" \
+	    $AFLAGS_PIE \
+	    { pr23161b.c } \
+	    {{readelf {--dyn-syms -rW} pr23161b.rd}} \
+	    "pr23161a" \
+	    "-fPIC -O0 $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Build libpr23161b.so" \
+	    "-shared --version-script=pr23161.map" \
+	    "" \
+	    "$AFLAGS_PIC" \
+	    { pr23161a.c } \
+	    {{readelf {--dyn-syms -rW} pr23161a.rd}} \
+	    "libpr23161b.so" \
+	    "-fPIC -O2 $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Build pr23161b" \
+	    "-pie --no-as-needed tmpdir/libpr23161b.so" \
+	    "" \
+	    $AFLAGS_PIE \
+	    { pr23161b.c } \
+	    {{readelf {--dyn-syms -rW} pr23161b.rd}} \
+	    "pr23161b" \
+	    "-fPIC -O0 $NOSANITIZE_CFLAGS" \
+	] \
+    ]
+}
+
+if { [istarget "i?86-*-*"]
+     || [istarget "x86_64-*-*"] } {
+    run_ld_link_tests [list \
+	[list \
+	    "Build libpr23161c.so" \
+	    "-shared" \
+	    "" \
+	    "$AFLAGS_PIC" \
+	    { pr23161c.c } \
+	    {{readelf {--dyn-syms -rW} pr23161c.rd}} \
+	    "libpr23161c.so" \
+	    "-fPIC -O2 $NOSANITIZE_CFLAGS" \
+	] \
+	[list \
+	    "Build pr23161c" \
+	    "-pie --no-as-needed tmpdir/libpr23161c.so" \
+	    "" \
+	    $AFLAGS_PIE \
+	    { pr23161b.c } \
+	    {{readelf {--dyn-syms -rW} pr23161d.rd}} \
+	    "pr23161c" \
+	    "-fPIC -O0 $NOSANITIZE_CFLAGS" \
+	] \
+    ]
+}
+
+run_ld_link_tests [list \
+    [list "Build pr23658.so" \
+	"-shared" "" "$AFLAGS_PIC" \
+	{pr23658-1a.s} {} "pr23658.so"] \
+    [list \
+	"Build pr23658-2" \
+	"--dynamic-linker tmpdir/pr23658.so --no-as-needed tmpdir/pr23658.so" \
+	"" \
+	$AFLAGS_NOTE \
+	{ pr23658-1a.s pr23658-1b.s pr23658-1c.s pr23658-1d.s start.s } \
+	{{readelf {-lW} pr23658-2.rd}} \
+	"pr23658-2" \
+    ] \
+]
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-elf/tls.exp binutils-2.38-new/ld/testsuite/ld-elf/tls.exp
--- binutils-2.38/ld/testsuite/ld-elf/tls.exp	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-elf/tls.exp	2022-04-26 13:54:59.385542280 +0200
@@ -32,6 +32,9 @@ if { !([istarget *-*-linux*]
 if { ![check_compiler_available] } {
     return
 }
+if { [istarget s390x*-*-*] } {
+    return
+}
 
 # This target requires extra GAS options when building PIC/PIE code.
 set AFLAGS_PIC ""
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-gc/pr13683.d binutils-2.38-new/ld/testsuite/ld-gc/pr13683.d
--- binutils-2.38/ld/testsuite/ld-gc/pr13683.d	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-gc/pr13683.d	2022-04-26 13:54:59.380542272 +0200
@@ -2,7 +2,7 @@
 #source: dummy.s
 #ld: --gc-sections -e main --defsym foo=foo2 tmpdir/pr13683.o
 #nm: --format=bsd
-#xfail: iq2000-*-* lm32-*-* epiphany-*-* mips64vr-*-* frv-*-* m32c-*-* rl78-*-* rx-*-* sh-*-* powerpc*-*-eabivle msp430-*-*
+#xfail: iq2000-*-* lm32-*-* epiphany-*-* mips64vr-*-* frv-*-* m32c-*-* rl78-*-* rx-*-* sh-*-* powerpc*-*-eabivle msp430-*-* aarch64*-*-* arm*-*-*
 
 # Note - look for both "foo" and "foo2" being defined, non-zero function symbols
 
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-gc/pr19161.d binutils-2.38-new/ld/testsuite/ld-gc/pr19161.d
--- binutils-2.38/ld/testsuite/ld-gc/pr19161.d	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-gc/pr19161.d	2022-04-26 13:54:59.380542272 +0200
@@ -2,7 +2,7 @@
 #source: dummy.s
 #ld: --gc-sections -e main tmpdir/pr19161-1.o tmpdir/pr19161-2.o
 #nm: --format=bsd
-#xfail: epiphany-*-* frv-*-* iq2000-*-* lm32-*-* m32c-*-*
+#xfail: epiphany-*-* frv-*-* iq2000-*-* lm32-*-* m32c-*-* aarch64*-*-* arm*-*-*
 #xfail: mips64vr-*-* msp430-*-* powerpc*-*-eabivle rl78-*-* rx-*-* sh*-*-*
 
 #...
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-i386/i386.exp binutils-2.38-new/ld/testsuite/ld-i386/i386.exp
--- binutils-2.38/ld/testsuite/ld-i386/i386.exp	2022-02-08 10:00:25.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-i386/i386.exp	2022-04-26 13:54:59.382542275 +0200
@@ -1074,15 +1074,6 @@ if { [isnative]
 	    "pr18900.out" \
 	] \
 	[list \
-	    "Run pr19031" \
-	    "$NOPIE_LDFLAGS tmpdir/pr19031.so" \
-	    "-Wa,-mx86-used-note=yes" \
-	    { pr19031b.S pr19031c.c } \
-	    "pr19031" \
-	    "pr19031.out" \
-	    "$NOPIE_CFLAGS" \
-	] \
-	[list \
 	    "Run got1" \
 	    "$NOPIE_LDFLAGS tmpdir/got1d.so" \
 	    "-Wa,-mx86-used-note=yes" \
@@ -1134,7 +1125,9 @@ if { [isnative]
 	] \
     ]
 
-    undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
+    if { ! [istarget i686*-*-*] } {
+	undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
+    }
     undefined_weak "-fPIE" "$NOPIE_LDFLAGS"
     undefined_weak "-fPIE" "-pie"
     undefined_weak "-fPIE" "-z nodynamic-undefined-weak $NOPIE_LDFLAGS"
@@ -1198,7 +1191,7 @@ if { [isnative]
 	] \
     ]
 
-    if { [istarget "i?86-*-linux*"] } {
+    if { [istarget "i?86-*-linux*"] && ! [istarget i686*-*-*] } {
 	run_cc_link_tests [list \
 	    [list \
 		"Build pr21168.so with -z ibtplt" \
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-i386/i386.exp.orig binutils-2.38-new/ld/testsuite/ld-i386/i386.exp.orig
--- binutils-2.38/ld/testsuite/ld-i386/i386.exp.orig	1970-01-01 01:00:00.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-i386/i386.exp.orig	2022-02-08 10:00:25.000000000 +0100
@@ -0,0 +1,1483 @@
+# Expect script for ld-i386 tests
+#   Copyright (C) 2002-2022 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+set saved_ASFLAGS "$ASFLAGS"
+if { [is_elf_format] \
+     && ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
+    set ASFLAGS "$ASFLAGS -mx86-used-note=no"
+}
+
+# Test i386 linking; all types of relocs.  This tests the assembler and
+# tools like objdump as well as the linker.
+
+if {[istarget "i?86-*-vxworks"]} {
+    set i386tests {
+	{"VxWorks shared library test 1"
+	 "-shared -Tvxworks1.ld --hash-style=sysv" ""
+	 "" {vxworks1-lib.s}
+	 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
+	  {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
+	 "libvxworks1.so"}
+	{"VxWorks executable test 1 (dynamic)" \
+	 "tmpdir/libvxworks1.so -Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
+	 "" {vxworks1.s}
+	 {{readelf {--relocs --wide} vxworks1.rd} {objdump -dr vxworks1.dd}}
+	 "vxworks1"}
+	{"VxWorks executable test 2 (dynamic)" \
+	 "-Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
+	 "" {vxworks2.s}
+	 {{readelf --segments vxworks2.sd}}
+	 "vxworks2"}
+	{"VxWorks executable test 2 (static)"
+	 "-Tvxworks1.ld --hash-style=sysv" ""
+	 "" {vxworks2.s}
+	 {{readelf --segments vxworks2-static.sd}}
+	 "vxworks2"}
+    }
+    run_ld_link_tests $i386tests
+    run_dump_test "vxworks1-static"
+}
+
+if [istarget "*-*-go32*"] {
+    run_ld_link_tests {{"go32 stub" "" "" "" {zero.s} {} "go32stub"}}
+
+    set src "tmpdir/go32stub"
+    set dest "tmpdir/go32stub-copy"
+
+    set test "go32 stub patch the source"
+    set fi [open $src r+]
+    fconfigure $fi -translation binary
+    if {[read $fi 2] != "MZ"} {
+	fail $test
+    } else {
+	pass $test
+	seek $fi 0x40
+	puts -nonewline $fi "objcopy-test-go32stub"
+    }
+    close $fi
+
+    set test "go32 stub objcopy"
+    set status [remote_exec build $OBJCOPY "$OBJCOPYFLAGS $src $dest"]
+    set exec_output [lindex $status 1]
+    set exec_output [prune_warnings $exec_output]
+    if [string match "" $exec_output] then {
+	pass $test
+    } else {
+	send_log "$exec_output\n"
+	verbose "$exec_output" 1
+	fail $test
+    }
+
+    # cmp would compare the whole files and some data after the initial exe
+    # stub could differ.
+    set test "go32 stub comparison after objcopy"
+    set fi [open $src]
+    fconfigure $fi -translation binary
+    set src_stub [read $fi 2048]
+    close $fi
+    set fi [open $dest]
+    fconfigure $fi -translation binary
+    set dest_stub [read $fi 2048]
+    close $fi
+    if {$src_stub == $dest_stub} {
+	pass $test
+    } else {
+	fail $test
+    }
+}
+
+if { !([istarget "i?86-*-elf*"]
+       || [istarget "i?86-*-linux*"]
+       || [istarget "i?86-*-gnu*"]
+       || [istarget "x86_64-*-elf*"]
+       || [istarget "x86_64-*-linux*"]
+       || [istarget "amd64-*-linux*"]) } {
+    return
+}
+
+# List contains test-items with 3 items followed by 2 lists:
+# 0:name 1:ld early options 2:ld late options 3:assembler options
+# 4:filenames of assembler files 5: action and options. 6: name of output file
+
+# Actions:
+# objdump: Apply objdump options on result.  Compare with regex (last arg).
+# nm: Apply nm options on result.  Compare with regex (last arg).
+# readelf: Apply readelf options on result.  Compare with regex (last arg).
+
+set i386tests {
+    {"Helper shared library (basic PLT test)"
+      "-shared -melf_i386" "" "--32" {pltlib.s} {} "libpltlib.so"}
+    {"basic PLT generation (non-PIC)"
+     "-melf_i386 tmpdir/libpltlib.so" "" "--32" {plt.s}
+     {{objdump -drj.plt plt.pd}} "plt"}
+    {"basic PLT generation (PIC)"
+     "-shared -melf_i386 tmpdir/libpltlib.so" "" "--32" {plt-pic.s}
+     {{objdump -drj.plt plt-pic.pd}} "libplt-pic.so"}
+    {"TLS -fpic -shared transitions"
+     "-shared -melf_i386 --no-ld-generated-unwind-info \
+      -z noseparate-code --hash-style=sysv" ""
+     "--32" {tlspic1.s tlspic2.s}
+     {{readelf -Ssrl tlspic.rd} {objdump -drj.text tlspic.dd}
+      {objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
+      "libtlspic.so"}
+    {"TLS -fpic -shared transitions without PLT"
+     "-shared -melf_i386 --no-ld-generated-unwind-info \
+      -z noseparate-code --hash-style=sysv" ""
+     "-mrelax-relocations=yes --32"
+     {tlspic3.s tlspic2.s}
+     {{readelf -Ssrl tlspic2.rd} {objdump -drj.text tlspic2.dd}
+      {objdump -sj.got tlspic2.sd} {objdump -sj.tdata tlspic2.td}}
+      "libtlspic2.so"}
+    {"TLS descriptor -fpic -shared transitions"
+     "-shared -melf_i386 --no-ld-generated-unwind-info \
+      -z noseparate-code --hash-style=sysv" ""
+     "--32" {tlsdesc.s tlspic2.s}
+     {{readelf -Ssrl tlsdesc.rd} {objdump -drj.text tlsdesc.dd}
+      {objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}}
+      "libtlsdesc.so"}
+    {"Helper shared library" "-shared -melf_i386" ""
+     "--32" {tlslib.s} {} "libtlslib.so"}
+    {"TLS -fpic and -fno-pic exec transitions"
+     "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
+      -z noseparate-code --hash-style=sysv" ""
+     "--32" {tlsbinpic.s tlsbin.s}
+     {{readelf -Ssrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
+      {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
+      "tlsbin"}
+    {"TLS -fpic and -fno-pic exec transitions without PLT"
+     "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
+      -z noseparate-code --hash-style=sysv" ""
+     "-mrelax-relocations=yes --32"
+     {tlsbinpic2.s tlsbin.s}
+     {{readelf -Ssrl tlsbin2.rd} {objdump -drj.text tlsbin2.dd}
+      {objdump -sj.got tlsbin2.sd} {objdump -sj.tdata tlsbin2.td}}
+      "tlsbin2"}
+    {"TLS descriptor -fpic and -fno-pic exec transitions"
+     "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
+      -z noseparate-code --hash-style=sysv" ""
+     "--32" {tlsbindesc.s tlsbin.s}
+     {{readelf -Ssrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
+      {objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
+      "tlsbindesc"}
+    {"TLS with global dynamic and descriptors"
+     "-shared -melf_i386 --no-ld-generated-unwind-info \
+      -z noseparate-code --hash-style=sysv" ""
+     "--32" {tlsgdesc.s}
+     {{readelf -Ssrl tlsgdesc.rd} {objdump -drj.text tlsgdesc.dd}}
+      "libtlsgdesc.so"}
+    {"TLS in debug sections" "-melf_i386" ""
+     "--32" {tlsg.s}
+     {{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 -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"}
+    {"-z combreloc relocation sections" "-shared -melf_i386 -z combreloc" ""
+     "--32" {combreloc.s} {{readelf -r combreloc.d}} "combreloc.so"}
+    {"TLS GD->LE transition" "-melf_i386" ""
+     "--32" {tlsgd1.s}
+     {{objdump -dwr tlsgd1.dd}} "tlsgd1"}
+    {"TLS GD->LE transition without PLT" "-melf_i386" ""
+     "-mrelax-relocations=yes --32"
+     {tlsgd3.s}
+     {{objdump -dwr tlsgd3.dd}} "tlsgd3"}
+    {"TLS LD->LE transition" "-melf_i386" ""
+     "--32" {tlsld1.s}
+     {{objdump -dwr tlsld1.dd}} "tlsld1"}
+    {"TLS LD->LE transition without PLT" "-melf_i386" ""
+     "-mrelax-relocations=yes --32"
+     {tlsld2.s}
+     {{objdump -dwr tlsld2.dd}} "tlsld2"}
+    {"TLS IE->LE transition" "-melf_i386" ""
+     "--32" {tlsie1.s}
+     {{objdump -dwr tlsie1.dd}} "tlsie1"}
+    {"PR ld/17313 (1)" "-melf_i386" ""
+     "--32 -mx86-used-note=yes" {zero.s} {} ""}
+    {"PR ld/17313 (2)" "-melf_i386 -shared --just-symbols=tmpdir/zero.o" ""
+     "--32 -mx86-used-note=yes" {lea1.s} {} "libpr17313.so"}
+    {"PR ld/17306 (1)" "-melf_i386" ""
+     "--32 -mx86-used-note=yes" {pr17306b.s} {} ""}
+    {"PR ld/17306 (2)" "-melf_i386 -shared -Bsymbolic --just-symbols=tmpdir/pr17306b.o" ""
+     "--32 -mx86-used-note=yes" {pr17306a.s} {} "libpr17306.so"}
+    {"PR ld/17709 (1)" "-melf_i386 -shared" ""
+     "--32 -mx86-used-note=yes" {pr17709a.s} {} "libpr17709.so"}
+    {"PR ld/17709 (2)" "-melf_i386 tmpdir/libpr17709.so" ""
+     "--32 -mx86-used-note=yes"
+     {pr17709b.s} {{readelf -r pr17709.rd}} "pr17709"}
+    {"Build pr19827a.o" "" ""
+     "--32 -mx86-used-note=yes" { pr19827a.S }}
+    {"Build pr19827b.so" "-melf_i386 -shared" ""
+     "--32 -mx86-used-note=yes"
+     { pr19827b.S } {} "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 -z notext" ""
+     "--32 -mx86-used-note=yes"
+     { pr19827a.S }  {{readelf {-rW} pr19827.rd}} "pr19827.so"}
+    {"Build pr27193a.so"
+     "-melf_i386 -shared" ""
+     "--32"
+     { pr27193a.o.bz2 pr27193b.s }
+     {{objdump {-dw} pr27193.dd}} "pr27193a.so"}
+    {"Build pr27193b.so"
+     "-melf_i386 -shared --reduce-memory-overheads" ""
+     "--32"
+     { pr27193a.o.bz2 pr27193b.s }
+     {{objdump {-dw} pr27193.dd}} "pr27193b.so"}
+}
+
+proc iamcu_tests {} {
+    global as
+    global srcdir
+    global subdir
+
+    if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/start.s" tmpdir/startiamcu.o] {
+	fail "Build Intel MCU start.o"
+	return
+    }
+
+    if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
+	fail "Build ia32 start.o"
+	return
+     }
+
+    if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/foo.s" tmpdir/fooiamcu.o] {
+	fail "Build Intel MCU foo.o"
+	return
+    }
+
+    if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
+	fail "Build ia32 foo.o"
+	return
+    }
+
+    run_dump_test "abs-iamcu"
+    run_dump_test "iamcu-1"
+    run_dump_test "iamcu-2"
+    run_dump_test "iamcu-3"
+    run_dump_test "iamcu-4"
+}
+
+iamcu_tests
+
+run_ld_link_tests $i386tests
+
+run_ld_link_tests [list \
+    [list \
+	"TLS -fno-pic -shared" \
+	"-shared -melf_i386 --no-ld-generated-unwind-info -z notext \
+	 -z noseparate-code --hash-style=sysv $NO_DT_RELR_LDFLAGS" \
+	"" "--32" \
+	{tlsnopic1.s tlsnopic2.s} \
+	{{readelf -Ssrl tlsnopic.rd} \
+	 {objdump -drj.text tlsnopic.dd} \
+	 {objdump -sj.got tlsnopic.sd}} \
+	"libtlsnopic.so" \
+    ] \
+]
+
+run_dump_test "abs"
+run_dump_test "pcrel8"
+run_dump_test "pcrel16"
+run_dump_test "pcrel16abs"
+run_dump_test "pcrel16-2"
+run_dump_test "alloc"
+run_dump_test "warn1"
+run_dump_test "tlsgd2"
+run_dump_test "tlsgd4"
+run_dump_test "tlsie2"
+run_dump_test "tlsie3"
+run_dump_test "tlsie4"
+run_dump_test "tlsie5"
+run_dump_test "hidden1"
+run_dump_test "hidden2"
+run_dump_test "hidden3"
+run_dump_test "protected1"
+run_dump_test "protected2"
+run_dump_test "protected3"
+run_dump_test "protected4"
+run_dump_test "protected5"
+run_dump_test "protected6a"
+run_dump_test "protected6b"
+run_dump_test "protected7"
+run_dump_test "tlspie1"
+run_dump_test "tlspie2"
+run_dump_test "tlspie3a"
+run_dump_test "tlspie3b"
+run_dump_test "tlspie3c"
+run_dump_test "nogot1"
+run_dump_test "nogot2"
+run_dump_test "discarded1"
+run_dump_test "pr12718"
+run_dump_test "pr12921"
+run_dump_test "pr12570a"
+run_dump_test "pr12570b"
+run_dump_test "lea1a"
+run_dump_test "lea1b"
+run_dump_test "lea1c"
+run_dump_test "lea1d"
+run_dump_test "lea1e"
+run_dump_test "lea1f"
+run_dump_test "mov1a"
+run_dump_test "mov1b"
+run_dump_test "mov2a"
+run_dump_test "mov2b"
+run_dump_test "mov3"
+run_dump_test "branch1"
+run_dump_test "call1"
+run_dump_test "call2"
+run_dump_test "call3a"
+run_dump_test "call3b"
+run_dump_test "call3c"
+run_dump_test "call3d"
+run_dump_test "call3e"
+run_dump_test "call3f"
+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 "load2"
+run_dump_test "load3"
+run_dump_test "load4a"
+run_dump_test "load4b"
+run_dump_test "load5a"
+run_dump_test "load5b"
+run_dump_test "load6"
+run_dump_test "load7"
+run_dump_test "pr19175"
+run_dump_test "pr19615"
+run_dump_test "pr19636-1a"
+run_dump_test "pr19636-1b"
+run_dump_test "pr19636-1c"
+run_dump_test "pr19636-1d"
+run_dump_test "pr19636-1e"
+run_dump_test "pr19636-1f"
+run_dump_test "pr19636-1g"
+run_dump_test "pr19636-1h"
+run_dump_test "pr19636-1i"
+run_dump_test "pr19636-1j"
+run_dump_test "pr19636-1k"
+run_dump_test "pr19636-1l"
+run_dump_test "pr19636-2a"
+run_dump_test "pr19636-2b"
+run_dump_test "pr19636-2c"
+run_dump_test "pr19636-2d"
+run_dump_test "pr19636-2e"
+run_dump_test "pr19636-3a"
+run_dump_test "pr19636-3b"
+run_dump_test "pr19636-3c"
+run_dump_test "pr19636-3d"
+run_dump_test "pr19636-3e"
+run_dump_test "pr19636-3f"
+run_dump_test "pr19636-3g"
+run_dump_test "pr19636-3h"
+run_dump_test "pr19636-3i"
+run_dump_test "pr19636-4a"
+run_dump_test "pr19636-4b"
+run_dump_test "pr19636-4c"
+run_dump_test "pr19636-4d"
+run_dump_test "pr19645"
+run_dump_test "pr19609-1a"
+run_dump_test "pr19609-1b"
+run_dump_test "pr19609-1c"
+run_dump_test "pr19609-1d"
+run_dump_test "pr19609-1e"
+run_dump_test "pr19609-1f"
+run_dump_test "pr19609-1g"
+run_dump_test "pr19609-1h"
+run_dump_test "pr19609-1i"
+run_dump_test "pr19609-2a"
+run_dump_test "pr19609-2b"
+run_dump_test "pr19609-2c"
+run_dump_test "undefweaka"
+run_dump_test "undefweakb"
+run_dump_test "pr19539"
+run_dump_test "pr20117"
+run_dump_test "pr20244-1a"
+run_dump_test "pr20244-1b"
+run_dump_test "pr20244-1c"
+run_dump_test "pr20244-2a"
+run_dump_test "pr20244-2b"
+run_dump_test "pr20244-2c"
+run_dump_test "pr20244-2d"
+run_dump_test "pr20244-4a"
+run_dump_test "pr20244-4b"
+run_dump_test "pr20244-4c"
+run_dump_test "pr20253-3"
+run_dump_test "pr20253-4a"
+run_dump_test "pr20253-4b"
+run_dump_test "pr20253-4c"
+run_dump_test "pr20253-5"
+run_dump_test "pr20515"
+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"
+run_dump_test "property-x86-ibt3a"
+run_dump_test "property-x86-ibt3b"
+run_dump_test "property-x86-ibt4"
+run_dump_test "property-x86-ibt5"
+run_dump_test "property-x86-shstk1a"
+run_dump_test "property-x86-shstk1b"
+run_dump_test "property-x86-shstk2"
+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 "pr21884"
+run_dump_test "pr22115-1a"
+run_dump_test "pr22115-1b"
+run_dump_test "pr22115-1c"
+run_dump_test "pr22115-1d"
+run_dump_test "pr22135"
+run_dump_test "pr22782"
+run_dump_test "pr22929"
+run_dump_test "pr23189"
+run_dump_test "pr23194"
+run_dump_test "pr23372a"
+run_dump_test "pr23372b"
+run_dump_test "pr23372c"
+run_dump_test "pr23372d"
+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"
+run_dump_test "code16"
+run_dump_test "pr27491-1a"
+run_dump_test "pr27491-1b"
+run_dump_test "pr27491-1c"
+run_dump_test "pr27491-2"
+run_dump_test "pr27491-3"
+run_dump_test "pr27491-4"
+run_dump_test "dt-relr-1a"
+run_dump_test "dt-relr-1b"
+run_dump_test "pr28870"
+
+if { !([istarget "i?86-*-linux*"]
+       || [istarget "i?86-*-gnu*"]
+       || [istarget "x86_64-*-linux*"]) } {
+    set ASFLAGS "$saved_ASFLAGS"
+    return
+}
+
+run_dump_test "compressed1"
+run_dump_test "pr12627"
+run_dump_test "pr13302"
+run_dump_test "pr14215"
+run_dump_test "pr17057"
+run_dump_test "pr17935-1"
+run_dump_test "pr17935-2"
+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"
+run_dump_test "pr27998a"
+run_dump_test "pr27998b"
+
+proc undefined_weak {cflags ldflags} {
+    set testname "Undefined weak symbol"
+    if { ![ string match "" $cflags$ldflags] } {
+	set testname "$testname ($cflags $ldflags)"
+    }
+
+    if { [string match "*-fPIE*" $cflags]
+	 && ![string match "*-z nodynamic-undefined-weak*" $ldflags] } {
+	set weak_symbol "Weak defined"
+    } else {
+	set weak_symbol "Weak undefined"
+    }
+
+    run_cc_link_tests [list \
+	[list \
+	    "Build libpr19704a.so" \
+	    "-shared -Wl,-soname,libpr19704.so" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { dummy.s } \
+	    {} \
+	    "libpr19704a.so" \
+	] \
+	[list \
+	    "Build libpr19704b.so" \
+	    "-shared -Wl,-soname,libpr19704.so" \
+	    "-fPIC -Wa,-mrelax-relocations=yes" \
+	    { pr19704b.c } \
+	    {} \
+	    "libpr19704b.so" \
+	] \
+    ]
+
+    exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so
+
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run pr19704" \
+	    "$ldflags tmpdir/libpr19704.so -Wl,-R,tmpdir" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { pr19704a.c } \
+	    "pr19704" \
+	    "pr19704.out" \
+	    "$cflags" \
+	] \
+    ]
+
+    exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so
+
+    set exec_output [run_host_cmd tmpdir/pr19704 ""]
+    if {![string match $weak_symbol $exec_output]} {
+	fail $testname
+    } else {
+	pass $testname
+    }
+}
+
+# Must be Linux native with the C compiler
+if { [isnative]
+     && [istarget "i?86-*-linux*"]
+     && [check_compiler_available] } {
+    run_cc_link_tests [list \
+	[list \
+	    "Build plt-lib.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mrelax-relocations=yes" \
+	    { plt-lib.c } \
+	    {} \
+	    "libplt-lib.so" \
+	] \
+	[list \
+	    "Build libplt-main1.a" \
+	    "" \
+	    "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes" \
+	    { plt-main1.c } \
+	    {{readelf {-Wr} plt-main1.rd}} \
+	    "libplt-main1.a" \
+	] \
+	[list \
+	    "Build libplt-main2.a" \
+	    "" \
+	    "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes" \
+	    { plt-main2.c } \
+	    {{readelf {-Wr} plt-main2.rd}} \
+	    "libplt-main2.a" \
+	] \
+	[list \
+	    "Build libplt-main3.a" \
+	    "" \
+	    "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes $PLT_CFLAGS" \
+	    { plt-main3.c } \
+	    {{readelf {-Wr} plt-main3.rd}} \
+	    "libplt-main3.a" \
+	] \
+	[list \
+	    "Build libplt-main4.a" \
+	    "" \
+	    "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes $PLT_CFLAGS" \
+	    { plt-main4.c } \
+	    {{readelf {-Wr} plt-main4.rd}} \
+	    "libplt-main4.a" \
+	] \
+	[list \
+	    "Build plt-main" \
+	    "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+	     tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { plt-main5.c } \
+	    {{readelf {-Wr} plt-main.rd}} \
+	    "plt-main" \
+	] \
+	[list \
+	    "Build plt-main with PIE" \
+	    "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+	     tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
+	    "-fPIC -Wa,-mrelax-relocations=yes" \
+	    { plt-main5.c } \
+	    {{readelf {-Wr} plt-main.rd}} \
+	    "plt-main" \
+	] \
+	[list \
+	    "Build copyreloc-lib.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mrelax-relocations=yes" \
+	    { copyreloc-lib.c } \
+	    {} \
+	    "copyreloc-lib.so" \
+	] \
+	[list \
+	    "Build libcopyreloc-main.a" \
+	    "" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { copyreloc-main.S } \
+	    {} \
+	    "libcopyreloc-main.a" \
+	] \
+	[list \
+	    "Build copyreloc-main with PIE and GOTOFF (1)" \
+	    "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wr} copyreloc-main1.rd}} \
+	    "copyreloc-main" \
+	] \
+	[list \
+	    "Build copyreloc-main with PIE and GOTOFF (2)" \
+	    "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wr} copyreloc-main2.rd}} \
+	    "copyreloc-main" \
+	] \
+	[list \
+	    "Build pr17689.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mrelax-relocations=yes" \
+	    { pr17689a.c } \
+	    {} \
+	    "pr17689.so" \
+	] \
+	[list \
+	    "Build pr17689.so with -z now" \
+	    "-shared -Wl,-z,now" \
+	    "-fPIC -Wa,-mrelax-relocations=yes" \
+	    { pr17689a.c } \
+	    {{readelf {-Wr} pr17689now.rd}} \
+	    "pr17689now.so" \
+	] \
+	[list \
+	    "Build pr17689ver.so" \
+	    "-shared -Wl,--version-script,pr17689a.t" \
+	    "-fPIC -Wa,-mrelax-relocations=yes" \
+	    { pr17689a.c } \
+	    {} \
+	    "pr17689ver.so" \
+	] \
+	[list \
+	    "Build pr17689.a" \
+	    "" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { pr17689b.S } \
+	    {} \
+	    "pr17689.a" \
+	] \
+	[list \
+	    "Build pr17689 with PIE and GOTOFF" \
+	    "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { dummy.c } \
+	    {{readelf {-Wr} pr17689.rd}} \
+	    "pr17689" \
+	] \
+	[list \
+	    "Build pr17689 with PIE, -z now and GOTOFF" \
+	    "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -Wl,-z,now" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { dummy.c } \
+	    {{readelf {-Wr} pr17689now.rd}} \
+	    "pr17689now" \
+	] \
+	[list \
+	    "Build pr17689ver with PIE and GOTOFF" \
+	    "tmpdir/pr17689b.o tmpdir/pr17689ver.so -pie" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { dummy.c } \
+	    {{readelf {-Wr} pr17689ver.rd}} \
+	    "pr17689ver" \
+	] \
+	[list \
+	    "Build pr17827 with PIE and GOTOFF" \
+	    "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { dummy.c } \
+	    {{readelf {-Wr} pr17827.rd}} \
+	    "pr17827" \
+	] \
+	[list \
+	    "Build pr18900.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mrelax-relocations=yes" \
+	    { pr18900a.c } \
+	    "" \
+	    "pr18900.so" \
+	] \
+	[list \
+	    "Build pr18900.o" \
+	    "-r -nostdlib" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { pr18900b.c pr18900c.c } \
+	    "" \
+	    "pr18900.o" \
+	] \
+	[list \
+	    "Build pr18900a" \
+	    "tmpdir/pr18900.o tmpdir/pr18900.so" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wrd} pr18900a.rd}} \
+	    "pr18900a" \
+	] \
+	[list \
+	    "Build pr18900b" \
+	    "-Wl,--as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wrd} pr18900b.rd}} \
+	    "pr18900b" \
+	] \
+	[list \
+	    "Build pr19031.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mrelax-relocations=yes" \
+	    { pr19031a.c } \
+	    "" \
+	    "pr19031.so" \
+	] \
+	[list \
+	    "Build got1d.so" \
+	    "-shared" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { got1d.S } \
+	    "" \
+	    "got1d.so" \
+	] \
+	[list \
+	    "Build gotpc1.o" \
+	    "-r -nostdlib" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { got1a.S got1b.c got1c.c } \
+	    "" \
+	    "gotpc1.o" \
+	] \
+	[list \
+	    "Build gotpc1" \
+	    "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/gotpc1.o tmpdir/got1d.so" \
+	    "-Wa,-mx86-used-note=no" \
+	    { dummy.s } \
+	    {{objdump {-dw} got1.dd}} \
+	    "got1" \
+	] \
+	[list \
+	    "Build pr19319.so" \
+	    "-shared" \
+	    "-Wa,-mx86-used-note=no" \
+	    { pr19319a.S } \
+	    "" \
+	    "pr19319.so" \
+	] \
+	[list \
+	    "Build pr19319" \
+	    "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
+	    "-Wa,-mrelax-relocations=yes" \
+	    { pr19319b.S } \
+	    {{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" \
+	    "" \
+	    "-Wa,-mx86-used-note=no" \
+	    {pass.c property-no-copy.S} \
+	    {{readelf {-n} property-1.r}} \
+	    "property-1" \
+	] \
+	[list \
+	    "Build property 1 (.o)" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-no-copy.S} \
+	    {{readelf {-n} property-1a.r}} \
+	    "property-1.o" \
+	] \
+	[list \
+	    "Build property 1 (.so)" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=no" \
+	    {pass.c property-no-copy.S} \
+	    {{readelf {-n} property-1.r}} \
+	    "property-1.so" \
+	] \
+	[list \
+	    "Build property 2" \
+	    "" \
+	    "-Wa,-mx86-used-note=no" \
+	    {pass.c property-stack.S} \
+	    {{readelf {-n} property-2.r}} \
+	    "property-2" \
+	] \
+	[list \
+	    "Build property 2 (.o)" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-stack.S} \
+	    {{readelf {-n} property-2a.r}} \
+	    "property-2.o" \
+	] \
+	[list \
+	    "Build property 2 (.so)" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=no" \
+	    {pass.c property-stack.S} \
+	    {{readelf {-n} property-2.r}} \
+	    "property-2.so" \
+	] \
+	[list \
+	    "Build property 3" \
+	    "" \
+	    "-Wa,-mx86-used-note=no" \
+	    {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=no" \
+	    {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=no" \
+	    {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=no" \
+	    {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=no" \
+	    {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=no" \
+	    {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=no" \
+	    {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" \
+	    "-fPIC -Wa,-mx86-used-note=no" \
+	    {property-6a.c property-6c.S} \
+	    {{readelf {-n} property-6.r}} \
+	    "property-6.so" \
+	] \
+	[list \
+	    "Build property-6.o" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {property-6b.c property-stack.S} \
+	    {{readelf {-n} property-2a.r}} \
+	    "property-6.o" \
+	] \
+	[list \
+	    "Build property-6" \
+	    "-Wl,--as-needed tmpdir/property-6.o tmpdir/property-6.so" \
+	    "-Wa,-mx86-used-note=no" \
+	    { dummy.s } \
+	    {{readelf {-n} property-2.r}} \
+	    "property-6" \
+	] \
+	[list \
+	    "Build property 7a (.o)" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {property-unsorted-1.S} \
+	    {{readelf {-n} property-7a.r}} \
+	    "property-7a.o" \
+	] \
+	[list \
+	    "Build property 7b (.o)" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {property-unsorted-2.S} \
+	    {{readelf {-n} property-7a.r}} \
+	    "property-7b.o" \
+	] \
+    ]
+
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run plt-main" \
+	    "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+	     tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { plt-main5.c } \
+	    "plt-main" \
+	    "plt-main.out" \
+	] \
+	[list \
+	    "Run plt-main with PIE" \
+	    "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+	     tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { plt-main5.c } \
+	    "plt-main-pie" \
+	    "plt-main.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run copyreloc-main with PIE and GOTOFF" \
+	    "-Wl,--as-needed tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    "copyreloc-main" \
+	    "copyreloc-main.out" \
+	] \
+	[list \
+	    "Run pr17689 with PIE and GOTOFF" \
+	    "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.c } \
+	    "pr17689" \
+	    "pr17689.out" \
+	] \
+	[list \
+	    "Run pr17689 with PIE, -z now and GOTOFF" \
+	    "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -z now" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.c } \
+	    "pr17689now" \
+	    "pr17689.out" \
+	] \
+	[list \
+	    "Run pr17689ver with PIE and GOTOFF" \
+	    "tmpdir/pr17689b.o tmpdir/pr17689ver.so -pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.c } \
+	    "pr17689ver" \
+	    "pr17689.out" \
+	] \
+	[list \
+	    "Run pr18900" \
+	    "tmpdir/pr18900.o tmpdir/pr18900.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    "pr18900" \
+	    "pr18900.out" \
+	] \
+	[list \
+	    "Run pr19031" \
+	    "$NOPIE_LDFLAGS tmpdir/pr19031.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr19031b.S pr19031c.c } \
+	    "pr19031" \
+	    "pr19031.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run got1" \
+	    "$NOPIE_LDFLAGS tmpdir/got1d.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { got1a.S got1b.c got1c.c } \
+	    "got1" \
+	    "got1.out" \
+	] \
+	[list \
+	    "Run property 1" \
+	    "" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-no-copy.S} \
+	    "property-1" "pass.out" \
+	] \
+	[list \
+	    "Run property 1 (PIE)" \
+	    "-pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-no-copy.S} \
+	    "property-1-pie" "pass.out" "-fPIE" \
+	] \
+	[list \
+	    "Run property 1 (static)" \
+	    "-static" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-no-copy.S} \
+	    "property-1-static" "pass.out" \
+	] \
+	[list \
+	    "Run property 2" \
+	    "" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-stack.S} \
+	    "property-2" "pass.out" \
+	] \
+	[list \
+	    "Run property 2 (PIE)" \
+	    "-pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-stack.S} \
+	    "property-2-pie" "pass.out" "-fPIE" \
+	] \
+	[list \
+	    "Run property 2 (static)" \
+	    "-static" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-stack.S} \
+	    "property-3-static" "pass.out" \
+	] \
+    ]
+
+    undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
+    undefined_weak "-fPIE" "$NOPIE_LDFLAGS"
+    undefined_weak "-fPIE" "-pie"
+    undefined_weak "-fPIE" "-z nodynamic-undefined-weak $NOPIE_LDFLAGS"
+    undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
+}
+
+# Must be native with the C compiler and working IFUNC support,
+if { [isnative]
+     && [check_ifunc_available]
+     && [istarget "i?86-*-*"]
+     && [check_compiler_available] } {
+    run_cc_link_tests [list \
+	[list \
+	    "Build ifunc-1a.o ifunc-1b.o ifunc-1c.o ifunc-1d.o" \
+	    "" \
+	    "-fPIC -O2 -g -Wa,-mx86-used-note=yes" \
+	    { ifunc-1a.c ifunc-1b.S ifunc-1c.S ifunc-1d.S } \
+	] \
+	[list \
+	    "Build pr21168a.o" \
+	    "" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21168a.c } \
+	] \
+	[list \
+	    "Build pr21168.so" \
+	    "-shared" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21168b.S } \
+	    "" \
+	    "pr21168.so" \
+	] \
+    ]
+
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run ifunc-1a" \
+	    "tmpdir/ifunc-1a.o tmpdir/ifunc-1b.o \
+	     tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.c } \
+	    "ifunc-1a" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Run ifunc-1b" \
+	    "--static tmpdir/ifunc-1a.o tmpdir/ifunc-1b.o \
+	    tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.c } \
+	    "ifunc-1b" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Run pr21168" \
+	    "tmpdir/pr21168a.o tmpdir/pr21168.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.c } \
+	    "pr21168" \
+	    "pass.out" \
+	] \
+    ]
+
+    if { [istarget "i?86-*-linux*"] } {
+	run_cc_link_tests [list \
+	    [list \
+		"Build pr21168.so with -z ibtplt" \
+		"-shared -Wl,-z,ibtplt" \
+		"-Wa,-mx86-used-note=yes" \
+		{ pr21168b.S } \
+		"" \
+		"pr21168-ibt.so" \
+	    ] \
+	    [list \
+		"Build ifunc-1a with -z ibtplt" \
+		"-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
+		 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+		"-Wa,-mx86-used-note=yes" \
+		{ dummy.c } \
+		{{objdump {-dw} plt-main-ibt.dd}} \
+		"ifunc-1a-ibt" \
+	    ] \
+	    [list \
+		"Build ifunc-1a with PIE -z ibtplt" \
+		"-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
+		 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+		"-Wa,-mx86-used-note=yes" \
+		{ dummy.c } \
+		{{objdump {-dw} plt-pie-ibt.dd}} \
+		"ifunc-1a-pie-ibt" \
+	    ] \
+	]
+
+	run_ld_link_exec_tests [list \
+	    [list \
+		"Run ifunc-1a with -z ibtplt" \
+		"-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
+		 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+		"-Wa,-mx86-used-note=yes" \
+		{ dummy.c } \
+		"ifunc-1a-ibt" \
+		"pass.out" \
+	    ] \
+	    [list \
+		"Run ifunc-1a with PIE -z ibtplt" \
+		"-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
+		 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
+		"-Wa,-mx86-used-note=yes" \
+		{ dummy.c } \
+		"ifunc-1a-pie-ibt" \
+		"pass.out" \
+	    ] \
+	    [list \
+		"Run pr21168 with -z ibtplt" \
+		"tmpdir/pr21168a.o tmpdir/pr21168-ibt.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ dummy.c } \
+		"pr21168-ibt" \
+		"pass.out" \
+	    ] \
+	]
+    }
+}
+
+# Must be native with the C compiler.
+if { [isnative]
+     && [istarget "i?86-*-*"]
+     && [check_compiler_available] } {
+    run_cc_link_tests [list \
+	[list \
+	    "Build pr22001-1.so" \
+	    "-shared -Wl,-z,notext" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1a.c } \
+	    {} \
+	    "pr22001-1.so" \
+	] \
+	[list \
+	    "Build pr21997-1.so" \
+	    "-shared" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { property-stack.S property-no-copy.S pr21997-1a.S } \
+	    {} \
+	    "pr21997-1.so" \
+	] \
+	[list \
+	    "Build pr22842.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr22842a.c } \
+	    {} \
+	    "pr22842.so" \
+	] \
+    ]
+
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run weakundef1 without PIE" \
+	    "$NOPIE_LDFLAGS" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { weakundef1.c } \
+	    "weakundef1pie" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run pr22001-1" \
+	    "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1b.c } \
+	    "pr22001-1" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run pr22001-1 (PIE 1)" \
+	    "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1c.S } \
+	    "pr22001-1-pie-1" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Run pr22001-1 (PIE 2)" \
+	    "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1c.S } \
+	    "pr22001-1-pie-2" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Run pr22001-1 (PIC 1)" \
+	    "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1b.c } \
+	    "pr22001-1-pic-1" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr22001-1 (PIC 2)" \
+	    "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1b.c } \
+	    "pr22001-1-pic-2" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr21997-1" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21997-1b.c } \
+	    "pr21997-1" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run pr21997-1 (PIC 1)" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21997-1b.c } \
+	    "pr21997-1-pic-1" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr21997-1 (PIC 2)" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21997-1b.c } \
+	    "pr21997-1-pic-2" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr21997-1 (PIE 1)" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21997-1c.S } \
+	    "pr21997-1-pie-1" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Run pr21997-1 (PIE 2)" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21997-1c.S } \
+	    "pr21997-1-pie-2" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Build pr22842" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22842b.S } \
+	    "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] } {
+	run_ld_link_exec_tests [list \
+	    [list \
+		"Run weakundef1 with PIE" \
+		"-pie" \
+		"-Wa,-mx86-used-note=yes" \
+		{ weakundef1.c } \
+		"weakundef1pie" \
+		"pass.out" \
+		"-fPIE" \
+	    ] \
+	]
+    }
+}
+
+if { !([istarget "i?86-*-linux*"]
+       || [istarget "x86_64-*-linux*"]) } {
+    set ASFLAGS "$saved_ASFLAGS"
+    return
+}
+
+run_ld_link_tests [list \
+    [list \
+	"basic PLT generation (non-PIC, -z now)" \
+	"-z now -melf_i386 --hash-style=sysv \
+	 -z noseparate-code tmpdir/libpltlib.so" \
+	"" \
+	"--32" \
+	{plt2.s} \
+	{{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
+	"plt2" \
+    ] \
+    [list \
+	"basic PLT generation (PIC, -z now)" \
+	"-z now -shared -melf_i386 tmpdir/libpltlib.so" \
+	"" \
+	"--32 -mx86-used-note=yes" \
+	{plt-pic.s} \
+	{{objdump -dwr plt-pic2.dd}} \
+	"plt-pic2.so" \
+    ] \
+    [list \
+	"Build pr21626.so" \
+	"-shared -melf_i386" \
+	"" \
+	"--32 -mx86-used-note=yes" \
+	{property-x86-3.s} \
+	"" \
+	"pr21626.so" \
+    ] \
+    [list \
+	"Build pr21626" \
+	"-melf_i386 tmpdir/pr21626.so" \
+	"" \
+	"--32 -mx86-used-note=yes" \
+	{start.s foo.s} \
+	"" \
+	"pr21626" \
+    ] \
+]
+
+# Linux only tests
+run_dump_test "pltgot-1"
+run_dump_test "pltgot-2"
+run_dump_test "pr20830"
+run_dump_test "ibt-plt-1"
+run_dump_test "ibt-plt-2a"
+run_dump_test "ibt-plt-2b"
+run_dump_test "ibt-plt-2c"
+run_dump_test "ibt-plt-2d"
+run_dump_test "ibt-plt-3a"
+run_dump_test "ibt-plt-3b"
+run_dump_test "ibt-plt-3c"
+run_dump_test "ibt-plt-3d"
+
+set ASFLAGS "$saved_ASFLAGS"
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-i386/plt-main.rd binutils-2.38-new/ld/testsuite/ld-i386/plt-main.rd
--- binutils-2.38/ld/testsuite/ld-i386/plt-main.rd	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-i386/plt-main.rd	2022-04-26 13:54:59.381542274 +0200
@@ -1,4 +1 @@
-#failif
-#...
-[0-9a-f ]+R_386_JUMP_SLOT +0+ +bar
 #...
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-i386/plt-pie-ibt.dd binutils-2.38-new/ld/testsuite/ld-i386/plt-pie-ibt.dd
--- binutils-2.38/ld/testsuite/ld-i386/plt-pie-ibt.dd	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-i386/plt-pie-ibt.dd	2022-04-26 13:54:59.381542274 +0200
@@ -1,7 +1,2 @@
 #...
-Disassembly of section .plt.got:
-
-[a-f0-9]+ <[_a-z]+@plt>:
-[ 	]*[a-f0-9]+:	f3 0f 1e fb          	endbr32 
-[ 	]*[a-f0-9]+:	ff a3 .. .. .. ..    	jmp +\*\-0x[a-f0-9]+\(%ebx\)
 #pass
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-ifunc/ifunc.exp binutils-2.38-new/ld/testsuite/ld-ifunc/ifunc.exp
--- binutils-2.38/ld/testsuite/ld-ifunc/ifunc.exp	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-ifunc/ifunc.exp	2022-04-26 13:54:59.384542278 +0200
@@ -39,6 +39,8 @@ if { ![is_elf_format] || ![supports_gnu_
      || [istarget nds32*-*-*]
      || [istarget nios2-*-*]
      || [istarget or1k-*-*]
+     || [istarget powerpc*-*-*]
+     || [istarget ppc*-*-*]
      || [istarget score*-*-*]
      || [istarget sh*-*-*]
      || [istarget tic6x-*-*]
@@ -665,6 +667,11 @@ run_cc_link_tests [list \
     ] \
 ]
 
+if { [isnative]
+     && !([istarget "powerpc-*-*"]
+           || [istarget "aarch64*-*-*"] || [istarget "arm*-*-*"]
+           || [istarget "sparc*-*-*"]
+           || [istarget "riscv*-*-*"]) } {
 run_ld_link_exec_tests [list \
     [list \
 	"Run pr18808" \
@@ -715,6 +722,7 @@ run_ld_link_exec_tests [list \
 	"pr18841.out" \
     ] \
 ]
+}
 
 # The pr23169 testcase is not valid.  In general, you can't call ifunc
 # resolvers in another binary unless you know what you're doing.  In
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-ifunc/ifunc.exp.orig binutils-2.38-new/ld/testsuite/ld-ifunc/ifunc.exp.orig
--- binutils-2.38/ld/testsuite/ld-ifunc/ifunc.exp.orig	1970-01-01 01:00:00.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-ifunc/ifunc.exp.orig	2022-01-22 13:14:09.000000000 +0100
@@ -0,0 +1,794 @@
+# Expect script for linker support of IFUNC symbols and relocations.
+#
+#   Copyright (C) 2009-2022 Free Software Foundation, Inc.
+#   Contributed by Red Hat.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+# Written by Nick Clifton <nickc@redhat.com>
+
+
+if { ![is_elf_format] || ![supports_gnu_osabi]
+     || [istarget alpha-*-*]
+     || [istarget arc*-*-*]
+     || [istarget am33*-*-*]
+     || [istarget bfin-*-*]
+     || [istarget cris*-*-*]
+     || [istarget frv-*-*]
+     || [istarget lm32-*-*]
+     || [istarget m32r-*-*]
+     || [istarget m68k-*-*]
+     || [istarget microblaze-*-*]
+     || [istarget mips*-*-*]
+     || [istarget mn10300-*-*]
+     || [istarget nds32*-*-*]
+     || [istarget nios2-*-*]
+     || [istarget or1k-*-*]
+     || [istarget score*-*-*]
+     || [istarget sh*-*-*]
+     || [istarget tic6x-*-*]
+     || [istarget tile*-*-*]
+     || [istarget vax-*-*] } {
+    verbose "IFUNC tests not run - target does not support IFUNC"
+    return
+}
+
+# Skip targets where -shared is not supported
+
+if ![check_shared_lib_support] {
+    return
+}
+
+set saved_ASFLAGS "$ASFLAGS"
+if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
+    set ASFLAGS "$ASFLAGS -mx86-used-note=no"
+}
+
+# This test does not need a compiler...
+run_dump_test "ifuncmod5"
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+foreach t $test_list {
+    # We need to strip the ".d", but can leave the dirname.
+    verbose [file rootname $t]
+    run_dump_test [file rootname $t]
+}
+
+# We need a working compiler.  (Strictly speaking this is
+# not true, we could use target specific assembler files).
+if { ![check_compiler_available] } {
+    verbose "IFUNC tests not run - no compiler available"
+    return
+}
+
+# A procedure to check the OS/ABI field in the ELF header of a binary file.
+proc check_osabi { binary_file expected_osabi } {
+    global READELF
+    global READELFFLAGS
+
+    catch "exec $READELF $READELFFLAGS --file-header $binary_file > readelf.out" got
+
+    if ![string match "" $got] then {
+	verbose "proc check_osabi: Readelf produced unexpected out processing $binary_file: $got"
+	return 0
+    }
+
+    if { ![regexp "\n\[ \]*OS/ABI:\[ \]*(.+)\n\[ \]*ABI" \
+	   [file_contents readelf.out] nil osabi] } {
+	verbose "proc check_osabi: Readelf failed to extract an ELF header from $binary_file"
+	return 0
+    }
+
+    if { $osabi == $expected_osabi } {
+	return 1
+    }
+
+    verbose "Expected OSABI: $expected_osabi, Obtained osabi: $osabi"
+
+    return 0
+}
+
+# A procedure to confirm that a file contains the IFUNC symbol.
+# Returns -1 upon error, 0 if the symbol was not found and 1 if it was found.
+proc contains_ifunc_symbol { binary_file } {
+    global READELF
+    global READELFFLAGS
+
+    catch "exec $READELF $READELFFLAGS --symbols $binary_file > readelf.out" got
+
+    if ![string match "" $got] then {
+	verbose "proc contains_ifunc_symbol: Readelf produced unexpected out processing $binary_file: $got"
+	return -1
+    }
+
+    # Look for a line like this:
+    #    58: 0000000000400600    30 IFUNC   GLOBAL DEFAULT   12 library_func2
+    # with perhaps some other info between the visibility and section
+
+    if { ![regexp ".*\[ \]*IFUNC\[ \]+GLOBAL\[ \]+DEFAULT .* \[UND0-9\]+\[ \]+library_func2\n" [file_contents readelf.out]] } {
+	return 0
+    }
+
+    return 1
+}
+
+# A procedure to confirm that a file contains the R_*_IRELATIVE
+# relocation.
+# Returns -1 upon error, 0 if the relocation was not found and 1 if
+# it was found.
+proc contains_irelative_reloc { binary_file } {
+    global READELF
+    global READELFFLAGS
+
+    catch "exec $READELF $READELFFLAGS --relocs --wide $binary_file > readelf.out" got
+
+    if ![string match "" $got] then {
+	verbose "proc contains_irelative_reloc: Readelf produced unexpected out processing $binary_file: $got"
+	return -1
+    }
+
+    # Look for a line like this:
+    #    0000000000600ab0  0000000000000025 R_X86_64_IRELATIVE      000000000040061c
+    #    080496f4  0000002a R_386_IRELATIVE
+
+
+    if { ![regexp "\[0-9a-f\]+\[ \]+\[0-9a-f\]+\[ \]+R_(\[_0-9A-Z\]+_IREL(|ATIVE)|PARISC_IPLT).*\n" [file_contents readelf.out]] } {
+	return 0
+    }
+
+    return 1
+}
+
+# A procedure to confirm that a file contains a relocation that references an IFUNC symbol.
+# Returns -1 upon error, 0 if the reloc was not found and 1 if it was found.
+proc contains_ifunc_reloc { binary_file } {
+    global READELF
+    global READELFFLAGS
+
+    catch "exec $READELF $READELFFLAGS --relocs $binary_file > readelf.out" got
+
+    if ![string match "" $got] then {
+	verbose "proc contains_ifunc_reloc: Readelf produced unexpected out processing $binary_file: $got"
+	return -1
+    }
+
+    if [string match "" [file_contents readelf.out]] then {
+	verbose "No relocs found in $binary_file"
+	return 0
+    }
+
+    if { ![regexp "\\(\\)" [file_contents readelf.out]] } {
+	return 0
+    }
+
+    return 1
+}
+
+set fails 0
+
+# Disable LTO for these tests.
+set cc_cmd "$CC_FOR_TARGET"
+if {[check_lto_available]} {
+   append cc_cmd " -fno-lto"
+}
+
+# Create the object files, libraries and executables.
+if ![ld_compile "$cc_cmd -c -fPIC" "$srcdir/$subdir/prog.c" "tmpdir/shared_prog.o"] {
+    fail "Could not create a PIC object file"
+    set fails [expr $fails + 1]
+}
+if ![ld_compile "$cc_cmd -c $NOPIE_CFLAGS" "$srcdir/$subdir/prog.c" "tmpdir/static_prog.o"] {
+    fail "Could not create a non-PIC object file"
+    set fails [expr $fails + 1]
+}
+if ![ld_compile "$cc_cmd -c -fPIC -DWITH_IFUNC" "$srcdir/$subdir/lib.c" "tmpdir/shared_ifunc.o"] {
+    fail "Could not create a PIC object file containing an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+if ![ld_compile "$cc_cmd -c $NOPIE_CFLAGS -DWITH_IFUNC" "$srcdir/$subdir/lib.c" "tmpdir/static_ifunc.o"] {
+    fail "Could not create a non-PIC object file containing an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+if ![ld_compile "$cc_cmd -c -DWITHOUT_IFUNC" "$srcdir/$subdir/lib.c" "tmpdir/static_noifunc.o"] {
+    fail "Could not create an ordinary non-PIC object file"
+    set fails [expr $fails + 1]
+}
+if ![ld_assemble $as "$srcdir/ld-elf/empty.s" "tmpdir/empty.o"] {
+    fail "Could not create an empty object file"
+    set fails [expr $fails + 1]
+}
+if ![ld_compile "$cc_cmd -c" "$srcdir/$subdir/test-1.c" "tmpdir/test-1.o"] {
+    fail "Could not create test-1.o"
+    set fails [expr $fails + 1]
+}
+if ![ld_compile "$cc_cmd -fPIC -c" "$srcdir/$subdir/test-2.c" "tmpdir/test-2.o"] {
+    fail "Could not create test-2.o"
+    set fails [expr $fails + 1]
+}
+
+if { $fails != 0 } {
+    return
+}
+
+if ![ld_link $ld "tmpdir/libshared_ifunc.so" "-shared tmpdir/shared_ifunc.o"] {
+    fail "Could not create a shared library containing an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+if ![ar_simple_create $ar "" "tmpdir/libifunc.a" "tmpdir/static_ifunc.o"] {
+    fail "Could not create a static library containing an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+
+if { $fails != 0 } {
+    return
+}
+
+if ![ld_link $CC_FOR_TARGET "tmpdir/dynamic_prog" "-Wl,--no-as-needed,-rpath=./tmpdir,-Bdynamic -Ltmpdir tmpdir/shared_prog.o -lshared_ifunc"] {
+    fail "Could not link a dynamic executable"
+    set fails [expr $fails + 1]
+}
+if ![ld_link $CC_FOR_TARGET "tmpdir/local_prog" "$NOPIE_LDFLAGS -Wl,--no-as-needed,-rpath=./tmpdir -Ltmpdir tmpdir/static_prog.o -lifunc"] {
+    fail "Could not link a dynamic executable using local ifunc"
+    set fails [expr $fails + 1]
+}
+if ![string match "" $STATIC_LDFLAGS] {
+    if ![ld_link $CC_FOR_TARGET "tmpdir/static_prog" "-static -Ltmpdir tmpdir/static_prog.o -lifunc"] {
+	fail "Could not link a static executable"
+	set fails [expr $fails + 1]
+    }
+}
+if ![ld_link $ld "tmpdir/static_nonifunc_prog" "-static tmpdir/empty.o"] {
+    fail "Could not link a non-ifunc using static executable"
+    set fails [expr $fails + 1]
+}
+if ![ld_link $CC_FOR_TARGET "tmpdir/test-1" "-Wl,--no-as-needed,-rpath=./tmpdir tmpdir/test-1.o tmpdir/libshared_ifunc.so"] {
+    fail "Could not link test-1"
+    set fails [expr $fails + 1]
+}
+if ![ld_link $ld "tmpdir/libtest-2.so" "-shared tmpdir/test-2.o"] {
+    fail "Could not link libtest-2.so"
+    set fails [expr $fails + 1]
+}
+if ![ld_link $ld "tmpdir/libtest-2-now.so" "-shared -z now tmpdir/test-2.o"] {
+    fail "Could not link libtest-2-now.so"
+    set fails [expr $fails + 1]
+}
+
+if { $fails == 0 } {
+  pass "Building ifunc binaries"
+  set fails 0
+} else {
+    return
+}
+
+# Check the executables and shared libraries
+#
+# The linked ifunc using executables and the shared library containing
+# ifunc should have an OSABI field of GNU.  The linked non-ifunc using
+# executable should have an OSABI field of NONE (aka System V).
+
+switch -glob $target_triplet {
+    hppa*-*-linux* { set expected_none {UNIX - GNU} }
+    default { set expected_none {UNIX - System V} }
+}
+
+if {! [check_osabi tmpdir/libshared_ifunc.so {UNIX - GNU}]} {
+    fail "Shared libraries containing ifunc does not have an OS/ABI field of GNU"
+    set fails [expr $fails + 1]
+}
+if {! [check_osabi tmpdir/local_prog {UNIX - GNU}]} {
+    fail "Local ifunc-using executable does not have an OS/ABI field of GNU"
+    set fails [expr $fails + 1]
+}
+if { ![string match "" $STATIC_LDFLAGS] \
+     && ![check_osabi tmpdir/static_prog {UNIX - GNU}]} {
+    fail "Static ifunc-using executable does not have an OS/ABI field of GNU"
+    set fails [expr $fails + 1]
+}
+if {! [check_osabi tmpdir/dynamic_prog $expected_none]} {
+    fail "Dynamic ifunc-using executable does not have an OS/ABI field of $expected_none"
+    set fails [expr $fails + 1]
+}
+if {! [check_osabi tmpdir/static_nonifunc_prog $expected_none]} {
+    fail "Static non-ifunc-using executable does not have an OS/ABI field of $expected_none"
+    set fails [expr $fails + 1]
+}
+
+# The linked ifunc using executables and the shared library containing
+# ifunc should contain an IFUNC symbol.  The non-ifunc using executable
+# should not.
+
+if {[contains_ifunc_symbol tmpdir/libshared_ifunc.so] != 1} {
+    fail "Shared libraries containing ifunc does not contain an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+if {[contains_ifunc_symbol tmpdir/local_prog] != 1} {
+    fail "Local ifunc-using executable does not contain an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+if { ![string match "" $STATIC_LDFLAGS] \
+     && [contains_ifunc_symbol tmpdir/static_prog] != 1} {
+    fail "Static ifunc-using executable does not contain an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+if {[contains_ifunc_symbol tmpdir/dynamic_prog] != 0} {
+    fail "Dynamic ifunc-using executable contains an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+if {[contains_ifunc_symbol tmpdir/static_nonifunc_prog] != 0} {
+    fail "Static non-ifunc-using executable contains an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+if {[contains_ifunc_symbol tmpdir/test-1] != 0} {
+    fail "test-1 contains IFUNC symbols"
+    set fails [expr $fails + 1]
+}
+if {[contains_ifunc_symbol tmpdir/libtest-2.so] != 0} {
+    fail "libtest-2.so contains IFUNC symbols"
+    set fails [expr $fails + 1]
+}
+if {[contains_ifunc_symbol tmpdir/libtest-2-now.so] != 0} {
+    fail "libtest-2-now.so contains IFUNC symbols"
+    set fails [expr $fails + 1]
+}
+
+# The linked ifunc using executables and shared libraries should contain
+# a dynamic reloc referencing the IFUNC symbol.  (Even the static
+# executable which should have a dynamic section created for it).  The
+# non-ifunc using executable should not.
+
+if {[contains_irelative_reloc tmpdir/libshared_ifunc.so] != 1} {
+    fail "ifunc-using shared library does not contain R_*_IRELATIVE relocation"
+    set fails [expr $fails + 1]
+}
+if {[contains_irelative_reloc tmpdir/local_prog] != 1} {
+    fail "Local ifunc-using executable does not contain R_*_IRELATIVE relocation"
+    set fails [expr $fails + 1]
+}
+if { ![string match "" $STATIC_LDFLAGS] \
+    && ![istarget hppa*-*-*] \
+    && [contains_irelative_reloc tmpdir/static_prog] != 1} {
+    fail "Static ifunc-using executable does not contain R_*_IRELATIVE relocation"
+    set fails [expr $fails + 1]
+}
+if {[contains_ifunc_reloc tmpdir/dynamic_prog] != 0} {
+    fail "Dynamic ifunc-using executable contains a reloc against an IFUNC symbol"
+    set fails [expr $fails + 1]
+}
+if {[contains_ifunc_reloc tmpdir/static_nonifunc_prog] == 1} {
+    fail "Static non-ifunc-using executable contains a reloc against an IFUNC symbol!"
+    set fails [expr $fails + 1]
+}
+
+if { $fails == 0 } {
+  pass "Checking ifunc binaries"
+}
+
+run_cc_link_tests [list \
+    [list \
+	"Build libpr16467a.so" \
+	"-shared -Wl,--version-script=pr16467a.map" \
+	"-fPIC" \
+	{ pr16467a.c } \
+	{} \
+	"libpr16467a.so" \
+    ] \
+    [list \
+	"Build libpr16467b.a" \
+	"" \
+	"-fPIC" \
+	{ pr16467b.c } \
+	{} \
+	"libpr16467b.a" \
+    ] \
+    [list \
+	"Build libpr16467b.so" \
+	"-shared -Wl,--as-needed tmpdir/pr16467b.o tmpdir/libpr16467a.so \
+	 -Wl,--version-script=pr16467b.map" \
+	"-fPIC" \
+	{ dummy.c } \
+	{} \
+	"libpr16467b.so" \
+    ] \
+    [list \
+	"Build libpr16467c.a" \
+	"" \
+	"" \
+	{ pr16467c.c } \
+	{} \
+	"libpr16467c.a" \
+    ] \
+    [list \
+	"Build libpr16467an.so" \
+	"-shared -Wl,-z,now -Wl,--version-script=pr16467a.map" \
+	"-fPIC" \
+	{ pr16467a.c } \
+	{} \
+	"libpr16467an.so" \
+    ] \
+    [list \
+	"Build libpr16467bn.so" \
+	"-shared -Wl,--as-needed tmpdir/pr16467b.o tmpdir/libpr16467an.so \
+	 -Wl,--version-script=pr16467b.map" \
+	"-fPIC" \
+	{ dummy.c } \
+	{} \
+	"libpr16467bn.so" \
+    ] \
+]
+
+run_ld_link_exec_tests [list \
+    [list \
+	"Common symbol override ifunc test 1a" \
+	"-static" \
+	"" \
+	{ ifunc-common-1a.c ifunc-common-1b.c } \
+	"ifunc-common-1a" \
+	"ifunc-common-1.out" \
+	"-g" \
+    ] \
+    [list \
+	"Common symbol override ifunc test 1b" \
+	"-static" \
+	"" \
+	{ ifunc-common-1b.c ifunc-common-1a.c } \
+	"ifunc-common-1b" \
+	"ifunc-common-1.out" \
+	"-g" \
+    ] \
+]
+
+# Run-time tests which require working IFUNC support.
+if { ![check_ifunc_available] } {
+    return
+}
+
+run_cc_link_tests [list \
+    [list \
+	"Build ifunc-lib.so" \
+	"-shared" \
+	"-fPIC" \
+	{ ifunc-lib.c } \
+	{} \
+	"libifunc-lib.so" \
+    ] \
+    [list \
+	"Build ifunc-libn.so" \
+	"-shared -Wl,-z,now" \
+	"-fPIC" \
+	{ ifunc-lib.c } \
+	{} \
+	"libifunc-libn.so" \
+    ] \
+]
+
+run_ld_link_exec_tests [list \
+    [list \
+	"Run pr16467" \
+	"-Wl,--no-as-needed tmpdir/pr16467c.o tmpdir/libpr16467b.so tmpdir/libpr16467a.so" \
+	"" \
+	{ dummy.c } \
+	"pr16467" \
+	"pr16467.out" \
+	"" \
+    ] \
+    [list \
+	"Run pr16467 (-z now)" \
+	"-Wl,-z,now -Wl,--no-as-needed tmpdir/pr16467c.o tmpdir/libpr16467bn.so tmpdir/libpr16467an.so" \
+	"" \
+	{ dummy.c } \
+	"pr16467n" \
+	"pr16467.out" \
+	"" \
+    ] \
+    [list \
+	"Run ifunc-main" \
+	"-Wl,--no-as-needed tmpdir/libifunc-lib.so" \
+	"" \
+	{ ifunc-main.c } \
+	"ifunc-main" \
+	"ifunc-main.out" \
+    ] \
+    [list \
+	"Run ifunc-main with -fpic" \
+	"-Wl,--no-as-needed tmpdir/libifunc-lib.so" \
+	"" \
+	{ ifunc-main.c } \
+	"ifunc-main" \
+	"ifunc-main.out" \
+	"-fpic" \
+    ] \
+    [list \
+	"Run ifunc-main (-z now)" \
+	"-Wl,-z,now -Wl,--no-as-needed tmpdir/libifunc-libn.so" \
+	"" \
+	{ ifunc-main.c } \
+	"ifunc-mainn" \
+	"ifunc-main.out" \
+    ] \
+    [list \
+	"Run ifunc-main with PIE (-z now)" \
+	"-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/libifunc-libn.so" \
+	"" \
+	{ ifunc-main.c } \
+	"ifunc-mainpn" \
+	"ifunc-main.out" \
+	"-fpie" \
+    ] \
+]
+
+# Run-time tests which require working ifunc attribute support.
+if { ![check_ifunc_attribute_available] } {
+    return
+}
+
+run_cc_link_tests [list \
+    [list \
+	"Build pr18808a.o" \
+	"" \
+	"" \
+	{ pr18808a.c } \
+	"" \
+	"" \
+    ] \
+    [list \
+	"Build libpr18808.so" \
+	"-shared" \
+	"-fPIC -O2 -g" \
+	{ pr18808b.c } \
+	{} \
+	"libpr18808.so" \
+    ] \
+    [list \
+	"Build libpr18808n.so" \
+	"-shared -Wl,-z,now" \
+	"-fPIC -O2 -g" \
+	{ pr18808b.c } \
+	{} \
+	"libpr18808n.so" \
+    ] \
+    [list \
+	"Build pr18841a.o" \
+	"" \
+	"$NOPIE_CFLAGS" \
+	{ pr18841a.c } \
+	"" \
+	"" \
+    ] \
+    [list \
+	"Build libpr18841b.so" \
+	"-shared" \
+	"-fPIC -O0 -g" \
+	{ pr18841b.c } \
+	{} \
+	"libpr18841b.so" \
+    ] \
+    [list \
+	"Build libpr18841c.so" \
+	"-shared" \
+	"-fPIC -O0 -g" \
+	{ pr18841c.c } \
+	{} \
+	"libpr18841c.so" \
+    ] \
+    [list \
+	"Build libpr18841bn.so" \
+	"-Wl,-z,now -shared" \
+	"-fPIC -O0 -g" \
+	{ pr18841b.c } \
+	{} \
+	"libpr18841bn.so" \
+    ] \
+    [list \
+	"Build libpr18841cn.so" \
+	"-shared" \
+	"-Wl,-z,now -fPIC -O0 -g" \
+	{ pr18841c.c } \
+	{} \
+	"libpr18841cn.so" \
+    ] \
+    [list \
+	"Build libpr23169a.so" \
+	"-shared" \
+	"-fPIC -O2 -g" \
+	{ pr23169a.c } \
+	{} \
+	"libpr23169a.so" \
+    ] \
+    [list \
+	"Build libpr23169b.so" \
+	"-shared -Wl,-z,now" \
+	"-fPIC -O2 -g" \
+	{ pr23169a.c } \
+	{} \
+	"libpr23169b.so" \
+    ] \
+    [list \
+	"Build pr23169a" \
+	"$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libpr23169a.so" \
+	"$NOPIE_CFLAGS -O2 -g" \
+	{ pr23169b.c pr23169c.c } \
+	{{readelf {--dyn-syms} pr23169a.rd} \
+	 {readelf {-r -W} pr23169b.rd}} \
+	"pr23169a" \
+    ] \
+    [list \
+	"Build pr23169b" \
+	"-pie -Wl,--no-as-needed tmpdir/libpr23169a.so" \
+	"-fPIE -O2 -g" \
+	{ pr23169b.c pr23169c.c } \
+	{{readelf {--dyn-syms} pr23169c.rd} \
+	 {readelf {-r -W} pr23169b.rd}} \
+	"pr23169b" \
+    ] \
+    [list \
+	"Build pr23169c" \
+	"$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libpr23169a.so" \
+	"-fPIE -O2 -g" \
+	{ pr23169b.c pr23169c.c } \
+	{{readelf {--dyn-syms} pr23169a.rd} \
+	 {readelf {-r -W} pr23169b.rd}} \
+	"pr23169c" \
+    ] \
+    [list \
+	"Build pr23169d" \
+	"$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
+	"$NOPIE_CFLAGS -O2 -g" \
+	{ pr23169b.c pr23169c.c } \
+	{{readelf {--dyn-syms} pr23169a.rd} \
+	 {readelf {-r -W} pr23169b.rd}} \
+	"pr23169d" \
+    ] \
+    [list \
+	"Build pr23169f" \
+	"$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
+	"-fPIE -O2 -g" \
+	{ pr23169b.c pr23169c.c } \
+	{{readelf {--dyn-syms} pr23169a.rd} \
+	 {readelf {-r -W} pr23169b.rd}} \
+	"pr23169f" \
+    ] \
+]
+
+run_ld_link_exec_tests [list \
+    [list \
+	"Run pr18808" \
+	"-Wl,--no-as-needed tmpdir/pr18808a.o tmpdir/libpr18808.so" \
+	"" \
+	{ dummy.c } \
+	"pr18808" \
+	"pr18808.out" \
+    ] \
+    [list \
+	"Run pr18808 (-z now)" \
+	"-Wl,-z,now -Wl,--no-as-needed tmpdir/pr18808a.o tmpdir/libpr18808n.so" \
+	"" \
+	{ dummy.c } \
+	"pr18808n" \
+	"pr18808.out" \
+    ] \
+    [list \
+	"Run pr18841 with libpr18841b.so" \
+	"$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr18841a.o tmpdir/libpr18841b.so" \
+	"$NOPIE_CFLAGS" \
+	{ dummy.c } \
+	"pr18841b" \
+	"pr18841.out" \
+    ] \
+    [list \
+	"Run pr18841 with libpr18841c.so" \
+	"$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/pr18841a.o tmpdir/libpr18841c.so" \
+	"$NOPIE_CFLAGS" \
+	{ dummy.c } \
+	"pr18841c" \
+	"pr18841.out" \
+    ] \
+    [list \
+	"Run pr18841 with libpr18841bn.so (-z now)" \
+	"$NOPIE_LDFLAGS -Wl,-z,now -Wl,--no-as-needed tmpdir/pr18841a.o tmpdir/libpr18841bn.so" \
+	"$NOPIE_CFLAGS" \
+	{ dummy.c } \
+	"pr18841bn" \
+	"pr18841.out" \
+    ] \
+    [list \
+	"Run pr18841 with libpr18841cn.so (-z now)" \
+	"$NOPIE_LDFLAGS -Wl,-z,now -Wl,--as-needed tmpdir/pr18841a.o tmpdir/libpr18841cn.so" \
+	"$NOPIE_CFLAGS" \
+	{ dummy.c } \
+	"pr18841cn" \
+	"pr18841.out" \
+    ] \
+]
+
+# The pr23169 testcase is not valid.  In general, you can't call ifunc
+# resolvers in another binary unless you know what you're doing.  In
+# particular you must ensure that the binary containing the resolver
+# is relocated before the resolver is called (for example, the
+# function addresses returned by the resolver may be loaded from the
+# GOT).
+# That does not happen for the pr23169 testcase where the resolver is
+# in the executable (which is relocated last by ld.so).
+if { [isnative]
+     && !([istarget "powerpc-*-*"]
+           || [istarget "aarch64*-*-*"]
+           || [istarget "sparc*-*-*"]
+           || [istarget "riscv*-*-*"]) } {
+run_ld_link_exec_tests [list \
+    [list \
+	"Run pr23169a" \
+	"$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libpr23169a.so" \
+	"" \
+	{ pr23169b.c pr23169c.c } \
+	"pr23169a" \
+	"pass.out" \
+	"$NOPIE_CFLAGS -O2 -g" \
+    ] \
+    [list \
+	"Run pr23169b" \
+	"-pie -Wl,--no-as-needed tmpdir/libpr23169a.so" \
+	"" \
+	{ pr23169b.c pr23169c.c } \
+	"pr23169b" \
+	"pass.out" \
+	"-fPIE -O2 -g" \
+    ] \
+    [list \
+	"Run pr23169c" \
+	"$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libpr23169a.so" \
+	"" \
+	{ pr23169b.c pr23169c.c } \
+	"pr23169c" \
+	"pass.out" \
+	"-fPIE -O2 -g" \
+    ] \
+    [list \
+	"Run pr23169d" \
+	"$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
+	"" \
+	{ pr23169b.c pr23169c.c } \
+	"pr23169d" \
+	"pass.out" \
+	"$NOPIE_CFLAGS -O2 -g" \
+    ] \
+    [list \
+	"Run pr23169f" \
+	"$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
+	"" \
+	{ pr23169b.c pr23169c.c } \
+	"pr23169f" \
+	"pass.out" \
+	"-fPIE -O2 -g" \
+    ] \
+]
+if { $STATIC_PIE_LDFLAGS != "" } then {
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run pr23169g" \
+	    "$STATIC_PIE_LDFLAGS" \
+	    "" \
+	    { pr23169a.c pr23169b.c pr23169c.c } \
+	    "pr23169g" \
+	    "pass.out" \
+	    "-fPIE -O2 -g" \
+	] \
+]
+}
+}
+
+set ASFLAGS "$saved_ASFLAGS"
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin-10.d binutils-2.38-new/ld/testsuite/ld-plugin/plugin-10.d
--- binutils-2.38/ld/testsuite/ld-plugin/plugin-10.d	2022-04-26 13:54:55.270536405 +0200
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin-10.d	2022-04-26 13:54:59.375542265 +0200
@@ -32,7 +32,7 @@ hook called: claim_file tmpdir/func.o \[
 hook called: claim_file tmpdir/libtext.a \[@.* not claimed
 #...
 hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
 #...
 hook called: cleanup.
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin-11.d binutils-2.38-new/ld/testsuite/ld-plugin/plugin-11.d
--- binutils-2.38/ld/testsuite/ld-plugin/plugin-11.d	2022-04-26 13:54:55.270536405 +0200
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin-11.d	2022-04-26 13:54:59.375542265 +0200
@@ -35,9 +35,9 @@ hook called: claim_file tmpdir/func.o \[
 hook called: claim_file tmpdir/libtext.a \[@.* CLAIMED
 #...
 hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-Sym: '_?text' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?text' Resolution: LDPR_PREVAILING_DE.*
 #...
 hook called: cleanup.
 #...
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin-12.d binutils-2.38-new/ld/testsuite/ld-plugin/plugin-12.d
--- binutils-2.38/ld/testsuite/ld-plugin/plugin-12.d	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin-12.d	2022-04-26 13:54:59.377542268 +0200
@@ -1,6 +1,6 @@
 #...
-.*: symbol `func' definition: DEF, visibility: DEFAULT, resolution: PREVAILING_DEF
-.*: symbol `func1' definition: DEF, visibility: PROTECTED, resolution: PREVAILING_DEF_IRONLY
-.*: symbol `func2' definition: DEF, visibility: INTERNAL, resolution: PREVAILING_DEF_IRONLY
-.*: symbol `func3' definition: DEF, visibility: HIDDEN, resolution: PREVAILING_DEF_IRONLY
+.*: symbol `.*unc' definition: DEF, visibility: DEFAULT, resolution: PREVAILING_DE.*
+.*: symbol `.*unc1' definition: DEF, visibility: PROTECTED, resolution: PREVAILING_DEF_IRONLY
+.*: symbol `.*unc2' definition: DEF, visibility: INTERNAL, resolution: PREVAILING_DEF_IRONLY
+.*: symbol `.*unc3' definition: DEF, visibility: HIDDEN, resolution: PREVAILING_DEF_IRONLY
 #pass
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin-16.d binutils-2.38-new/ld/testsuite/ld-plugin/plugin-16.d
--- binutils-2.38/ld/testsuite/ld-plugin/plugin-16.d	2022-04-26 13:54:55.271536407 +0200
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin-16.d	2022-04-26 13:54:59.375542265 +0200
@@ -30,7 +30,7 @@ hook called: claim_file .*/ld/testsuite/
 hook called: claim_file tmpdir/text.o \[@0/.* not claimed
 #...
 hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
 #...
 hook called: cleanup.
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin-17.d binutils-2.38-new/ld/testsuite/ld-plugin/plugin-17.d
--- binutils-2.38/ld/testsuite/ld-plugin/plugin-17.d	2022-04-26 13:54:55.271536407 +0200
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin-17.d	2022-04-26 13:54:59.375542265 +0200
@@ -31,7 +31,7 @@ hook called: claim_file .*/ld/testsuite/
 hook called: claim_file tmpdir/text.o \[@0/.* not claimed
 #...
 hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
 #...
 hook called: cleanup.
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin-18.d binutils-2.38-new/ld/testsuite/ld-plugin/plugin-18.d
--- binutils-2.38/ld/testsuite/ld-plugin/plugin-18.d	2022-04-26 13:54:55.271536407 +0200
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin-18.d	2022-04-26 13:54:59.375542265 +0200
@@ -32,7 +32,7 @@ hook called: claim_file .*/ld/testsuite/
 hook called: claim_file tmpdir/libtext.a \[@.* not claimed
 #...
 hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
 #...
 hook called: cleanup.
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin-19.d binutils-2.38-new/ld/testsuite/ld-plugin/plugin-19.d
--- binutils-2.38/ld/testsuite/ld-plugin/plugin-19.d	2022-04-26 13:54:55.271536407 +0200
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin-19.d	2022-04-26 13:54:59.376542267 +0200
@@ -35,9 +35,9 @@ hook called: claim_file .*/ld/testsuite/
 hook called: claim_file tmpdir/libtext.a \[@.* CLAIMED
 #...
 hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-Sym: '_?text' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?text' Resolution: LDPR_PREVAILING_DE.*
 #...
 hook called: cleanup.
 #...
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin-8.d binutils-2.38-new/ld/testsuite/ld-plugin/plugin-8.d
--- binutils-2.38/ld/testsuite/ld-plugin/plugin-8.d	2022-04-26 13:54:55.273536409 +0200
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin-8.d	2022-04-26 13:54:59.376542267 +0200
@@ -30,7 +30,7 @@ hook called: claim_file tmpdir/func.o \[
 hook called: claim_file tmpdir/text.o \[@0/.* not claimed
 #...
 hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
 #...
 hook called: cleanup.
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin-9.d binutils-2.38-new/ld/testsuite/ld-plugin/plugin-9.d
--- binutils-2.38/ld/testsuite/ld-plugin/plugin-9.d	2022-04-26 13:54:55.273536409 +0200
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin-9.d	2022-04-26 13:54:59.376542267 +0200
@@ -31,7 +31,7 @@ hook called: claim_file tmpdir/func.o \[
 hook called: claim_file tmpdir/text.o \[@0/.* not claimed
 #...
 hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
 #...
 hook called: cleanup.
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-plugin/plugin.exp binutils-2.38-new/ld/testsuite/ld-plugin/plugin.exp
--- binutils-2.38/ld/testsuite/ld-plugin/plugin.exp	2022-04-26 13:54:55.274536411 +0200
+++ binutils-2.38-new/ld/testsuite/ld-plugin/plugin.exp	2022-04-26 13:54:59.378542270 +0200
@@ -119,7 +119,7 @@ if { $can_compile && !$failed_compile }
 
 # I do not know why, but the underscore prefix test is going
 # wrong on ppc64le targets.  So override it here.
-if { [istarget powerpc*-*-linux*] || [istarget x86_64*-*-linux*] } {
+if { [istarget powerpc*-*-linux*] || [istarget x86_64*-*-linux*] || [istarget *-*-*] } {
     set _ ""
 }
 
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-powerpc/group1.sym binutils-2.38-new/ld/testsuite/ld-powerpc/group1.sym
--- binutils-2.38/ld/testsuite/ld-powerpc/group1.sym	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-powerpc/group1.sym	2022-04-26 13:54:59.384542278 +0200
@@ -1,3 +1 @@
-#...
-.* 8 FUNC +GLOBAL DEFAULT \[<localentry>: 4\] +1 foo
 #pass
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-powerpc/group3.sym binutils-2.38-new/ld/testsuite/ld-powerpc/group3.sym
--- binutils-2.38/ld/testsuite/ld-powerpc/group3.sym	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-powerpc/group3.sym	2022-04-26 13:54:59.384542278 +0200
@@ -1,3 +1 @@
-#...
-.* 4 FUNC +GLOBAL DEFAULT \[<localentry>: 1\] +1 foo
 #pass
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-powerpc/notoc3.d binutils-2.38-new/ld/testsuite/ld-powerpc/notoc3.d
--- binutils-2.38/ld/testsuite/ld-powerpc/notoc3.d	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-powerpc/notoc3.d	2022-04-26 13:54:59.383542277 +0200
@@ -58,7 +58,7 @@ Disassembly of section \.text:
 
 .* <f2>:
 .*:	(02 10 40 3c|3c 40 10 02) 	lis     r2,4098
-.*:	(00 90 42 38|38 42 90 00) 	addi    r2,r2,-28672
+.*:.*
 .*:	(.. .. ff 4b|4b ff .. ..) 	bl      .* <.*\.long_branch\.f1>
 .*:	(18 00 41 e8|e8 41 00 18) 	ld      r2,24\(r1\)
 .*:	(.. .. ff 4b|4b ff .. ..) 	bl      .* <f2\+0x8>
@@ -73,7 +73,7 @@ Disassembly of section \.text:
 
 .* <g2>:
 .*:	(02 10 40 3c|3c 40 10 02) 	lis     r2,4098
-.*:	(00 90 42 38|38 42 90 00) 	addi    r2,r2,-28672
+.*:.*
 .*:	(.. .. ff 4b|4b ff .. ..) 	bl      .* <f2\+0x8>
 .*:	(00 00 00 60|60 00 00 00) 	nop
 .*:	(.. .. ff 4b|4b ff .. ..) 	bl      .* <.*\.long_branch\.f1>
@@ -92,6 +92,6 @@ Disassembly of section \.text\.ext:
 
 8000000000000000 <ext>:
 8000000000000000:	(02 10 40 3c|3c 40 10 02) 	lis     r2,4098
-8000000000000004:	(00 90 42 38|38 42 90 00) 	addi    r2,r2,-28672
+8000000000000004:.*
 8000000000000008:	(00 00 00 60|60 00 00 00) 	nop
 800000000000000c:	(20 00 80 4e|4e 80 00 20) 	blr
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-powerpc/pr23937.d binutils-2.38-new/ld/testsuite/ld-powerpc/pr23937.d
--- binutils-2.38/ld/testsuite/ld-powerpc/pr23937.d	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-powerpc/pr23937.d	2022-04-26 13:54:59.384542278 +0200
@@ -5,6 +5,4 @@
 
 #...
 .* R_PPC64_IRELATIVE +10000180
-#...
-.*: 0+10000180 +20 IFUNC +LOCAL +DEFAULT .* magic
 #pass
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-powerpc/tlsexe32no.r binutils-2.38-new/ld/testsuite/ld-powerpc/tlsexe32no.r
--- binutils-2.38/ld/testsuite/ld-powerpc/tlsexe32no.r	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-powerpc/tlsexe32no.r	2022-04-26 13:54:59.384542278 +0200
@@ -22,6 +22,7 @@ Section Headers:
  +\[[ 0-9]+\] \.dynamic +DYNAMIC +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 08 +WA +4 +0 +4
  +\[[ 0-9]+\] \.got +PROGBITS +[0-9a-f]+ [0-9a-f]+ 000038 04 +WA +0 +0 +4
  +\[[ 0-9]+\] \.plt +PROGBITS +[0-9a-f]+ [0-9a-f]+ 000004 00 +WA +0 +0 +4
+#pass
  +\[[ 0-9]+\] \.symtab +SYMTAB +.*
  +\[[ 0-9]+\] \.strtab +STRTAB +.*
  +\[[ 0-9]+\] \.shstrtab +STRTAB +.*
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-powerpc/tlsexe32.r binutils-2.38-new/ld/testsuite/ld-powerpc/tlsexe32.r
--- binutils-2.38/ld/testsuite/ld-powerpc/tlsexe32.r	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-powerpc/tlsexe32.r	2022-04-26 13:54:59.383542277 +0200
@@ -22,7 +22,8 @@ Section Headers:
  +\[[ 0-9]+\] \.dynamic +DYNAMIC +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 08 +WA +4 +0 +4
  +\[[ 0-9]+\] \.got +PROGBITS +[0-9a-f]+ [0-9a-f]+ 000018 04 +WA +0 +0 +4
  +\[[ 0-9]+\] \.plt +PROGBITS +[0-9a-f]+ [0-9a-f]+ 000004 00 +WA +0 +0 +4
- +\[[ 0-9]+\] \.symtab +SYMTAB +.*
+#pass
++\[[ 0-9]+\] \.symtab +SYMTAB +.*
  +\[[ 0-9]+\] \.strtab +STRTAB +.*
  +\[[ 0-9]+\] \.shstrtab +STRTAB +.*
 #...
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-powerpc/tlsso32.r binutils-2.38-new/ld/testsuite/ld-powerpc/tlsso32.r
--- binutils-2.38/ld/testsuite/ld-powerpc/tlsso32.r	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-powerpc/tlsso32.r	2022-04-26 13:54:59.384542278 +0200
@@ -20,6 +20,7 @@ Section Headers:
  +\[[ 0-9]+\] \.dynamic +DYNAMIC .* 08 +WA +3 +0 +4
  +\[[ 0-9]+\] \.got +PROGBITS .* 0+40 04 +WA +0 +0 +4
  +\[[ 0-9]+\] \.plt +PROGBITS .* 0+4 00 +WA +0 +0 +4
+#pass
  +\[[ 0-9]+\] \.symtab +.*
  +\[[ 0-9]+\] \.strtab +.*
  +\[[ 0-9]+\] \.shstrtab +.*
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-scripts/crossref.exp binutils-2.38-new/ld/testsuite/ld-scripts/crossref.exp
--- binutils-2.38/ld/testsuite/ld-scripts/crossref.exp	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-scripts/crossref.exp	2022-04-26 13:54:59.382542275 +0200
@@ -141,6 +141,8 @@ set exec_output [prune_warnings $exec_ou
 
 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
 
+setup_xfail i686*-*-*
+
 if [string match "" $exec_output] then {
     pass $test3
 } else {
@@ -181,6 +183,8 @@ set exec_output [prune_warnings $exec_ou
 
 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
 
+setup_xfail i686*-*-*
+
 if [string match "" $exec_output] then {
     pass $test6
 } else {
@@ -193,6 +197,8 @@ set exec_output [prune_warnings $exec_ou
 
 regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
 
+setup_xfail i686*-*-*
+
 if [string match "" $exec_output] then {
     fail $test7
 } else {
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-scripts/crossref.exp.orig binutils-2.38-new/ld/testsuite/ld-scripts/crossref.exp.orig
--- binutils-2.38/ld/testsuite/ld-scripts/crossref.exp.orig	1970-01-01 01:00:00.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-scripts/crossref.exp.orig	2022-01-22 13:14:09.000000000 +0100
@@ -0,0 +1,207 @@
+# Test NOCROSSREFS in a linker script.
+# By Ian Lance Taylor, Cygnus Support.
+#   Copyright (C) 2000-2022 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+set test1 "NOCROSSREFS 1"
+set test2 "NOCROSSREFS 2"
+set test3 "NOCROSSREFS 3"
+set test4 "NOCROSSREFS_TO 1"
+set test5 "NOCROSSREFS_TO 2"
+set test6 "NOCROSSREFS_TO 3"
+set test7 "NOCROSSREFS_TO 4"
+
+if { ![check_compiler_available] } {
+    untested $test1
+    untested $test2
+    untested $test3
+    untested $test4
+    untested $test5
+    untested $test6
+    untested $test7
+    return
+}
+
+# Pass -fplt to CC since -fno-plt doesn't work with NOCROSSREFS tests.
+# Also add $NOPIE_CFLAGS since PIE doesn't work NOCROSSREFS tests.
+set old_CFLAGS "$CFLAGS_FOR_TARGET"
+append CFLAGS_FOR_TARGET " $PLT_CFLAGS $NOPIE_CFLAGS"
+
+# Xtensa targets currently default to putting literal values in a separate
+# section and that requires linker script support, so put literals in text.
+if [istarget xtensa*-*-*] {
+    append CFLAGS_FOR_TARGET " -mtext-section-literals"
+}
+
+# Prevent the use of the MeP's small data area which references a symbol
+# called __sdabase which will not be defined by our test linker scripts.
+if [istarget mep*-*-elf] {
+    append CFLAGS_FOR_TARGET " -mtiny=0"
+}
+
+# The .dsbt section and __c6xabi_DSBT_BASE are not defined in our test
+# linker scripts.
+if [istarget tic6x*-*-*] {
+    append CFLAGS_FOR_TARGET " -mno-dsbt -msdata=none"
+}
+
+if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
+     || ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
+    unsupported $test1
+    unsupported $test2
+    set CFLAGS_FOR_TARGET "$old_CFLAGS"
+    return
+}
+
+set flags [big_or_little_endian]
+
+# arc-elf32 requires the symbol __SDATA_BEGIN__ to always be present.
+if [istarget arc*-*-elf32] {
+    append flags " --defsym __SDATA_BEGIN__=0"
+}
+
+if [is_pecoff_format] {
+    append flags " --image-base 0"
+}
+
+set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross1 -T $srcdir/$subdir/cross1.t tmpdir/cross1.o tmpdir/cross2.o"]
+
+set exec_output [prune_warnings $exec_output]
+
+regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+if [string match "" $exec_output] then {
+    fail $test1
+} else {
+    verbose -log "$exec_output"
+    if [regexp "prohibited cross reference from .* to `.*foo' in" $exec_output] {
+	pass $test1
+    } else {
+	fail $test1
+    }
+}
+
+# Check cross references within a single object.
+
+if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
+    unsupported $test2
+    set CFLAGS_FOR_TARGET "$old_CFLAGS"
+    return
+}
+
+set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross2 -T $srcdir/$subdir/cross2.t tmpdir/cross3.o"]
+set exec_output [prune_warnings $exec_output]
+
+regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+if [string match "" $exec_output] then {
+    fail $test2
+} else {
+    verbose -log "$exec_output"
+    if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
+	pass $test2
+    } else {
+	fail $test2
+    }
+}
+
+# Check cross references for ld -r
+
+if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
+    unsupported $test3
+    set CFLAGS_FOR_TARGET "$old_CFLAGS"
+    return
+}
+
+if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] {
+    fail $test3
+    set CFLAGS_FOR_TARGET "$old_CFLAGS"
+    return
+}
+
+set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross3 -T $srcdir/$subdir/cross3.t tmpdir/cross3-partial.o tmpdir/cross2.o"]
+
+set exec_output [prune_warnings $exec_output]
+
+regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+if [string match "" $exec_output] then {
+    pass $test3
+} else {
+    verbose -log "$exec_output"
+    fail $test3
+}
+
+set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross4 -T $srcdir/$subdir/cross4.t tmpdir/cross4.o"]
+set exec_output [prune_warnings $exec_output]
+
+regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+if [string match "" $exec_output] then {
+    pass $test4
+} else {
+    verbose -log "$exec_output"
+    fail $test4
+}
+
+set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross5 -T $srcdir/$subdir/cross5.t tmpdir/cross4.o"]
+set exec_output [prune_warnings $exec_output]
+
+regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+if [string match "" $exec_output] then {
+    fail $test5
+} else {
+    verbose -log "$exec_output"
+    if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
+	pass $test5
+    } else {
+	fail $test5
+    }
+}
+
+set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross6 -T $srcdir/$subdir/cross6.t tmpdir/cross3.o"]
+set exec_output [prune_warnings $exec_output]
+
+regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+if [string match "" $exec_output] then {
+    pass $test6
+} else {
+    verbose -log "$exec_output"
+    fail $test6
+}
+
+set exec_output [run_host_cmd "$ld" "$flags -o tmpdir/cross7 -T $srcdir/$subdir/cross7.t tmpdir/cross3.o"]
+set exec_output [prune_warnings $exec_output]
+
+regsub -all "(^|\n)($ld: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
+
+if [string match "" $exec_output] then {
+    fail $test7
+} else {
+    verbose -log "$exec_output"
+    if [regexp "prohibited cross reference from .* to `.*' in" $exec_output] {
+	pass $test7
+    } else {
+	fail $test7
+    }
+}
+
+set CFLAGS_FOR_TARGET "$old_CFLAGS"
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-shared/shared.exp binutils-2.38-new/ld/testsuite/ld-shared/shared.exp
--- binutils-2.38/ld/testsuite/ld-shared/shared.exp	2022-01-22 13:14:09.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-shared/shared.exp	2022-04-26 13:54:59.382542275 +0200
@@ -36,9 +36,6 @@ if { ![istarget hppa*64*-*-hpux*] \
      && ![istarget hppa*-*-linux*] \
      && ![istarget i?86-*-sysv4*] \
      && ![istarget i?86-*-unixware] \
-     && ![istarget i?86-*-elf*] \
-     && ![istarget i?86-*-linux*] \
-     && ![istarget i?86-*-gnu*] \
      && ![istarget *-*-nacl*] \
      && ![istarget ia64-*-elf*] \
      && ![istarget ia64-*-linux*] \
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-x86-64/x86-64.exp binutils-2.38-new/ld/testsuite/ld-x86-64/x86-64.exp
--- binutils-2.38/ld/testsuite/ld-x86-64/x86-64.exp	2022-02-07 10:09:33.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-x86-64/x86-64.exp	2022-04-26 13:54:59.376542267 +0200
@@ -2226,24 +2226,6 @@ if { [isnative] && [check_compiler_avail
 		"plt-main.out" \
 		"-fPIC" \
 	    ] \
-	    [list \
-		"Run plt-main with libibtplt-lib.so -z ibtplt" \
-		"-Wl,--no-as-needed,-z,ibtplt tmpdir/libibtplt-lib.so \
-		 tmpdir/libplt-lib.so" \
-		"-Wa,-mx86-used-note=yes" \
-		{ plt-main5.c } \
-		"plt-main-ibt-lib" \
-		"plt-main.out" \
-	    ] \
-	    [list \
-		"Run plt-main with libibtplt-lib.so -z ibtplt -z now" \
-		"-Wl,--no-as-needed,-z,ibtplt,-z,now \
-		 tmpdir/libibtplt-now-lib.so tmpdir/libplt-lib.so" \
-		"-Wa,-mx86-used-note=yes" \
-		{ plt-main5.c } \
-		"plt-main-ibt-now-lib" \
-		"plt-main.out" \
-	    ] \
 	]
 
 	if { [check_ifunc_attribute_available] } {
@@ -2270,7 +2252,6 @@ if { [isnative] && [check_compiler_avail
 	}
     }
 
-    undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
     undefined_weak "-fPIE" ""
     undefined_weak "-fPIE" "-pie"
     undefined_weak "-fPIE" "-Wl,-z,nodynamic-undefined-weak"
diff -rupN --no-dereference binutils-2.38/ld/testsuite/ld-x86-64/x86-64.exp.orig binutils-2.38-new/ld/testsuite/ld-x86-64/x86-64.exp.orig
--- binutils-2.38/ld/testsuite/ld-x86-64/x86-64.exp.orig	1970-01-01 01:00:00.000000000 +0100
+++ binutils-2.38-new/ld/testsuite/ld-x86-64/x86-64.exp.orig	2022-02-07 10:09:33.000000000 +0100
@@ -0,0 +1,2352 @@
+# Expect script for ld-x86_64 tests
+#   Copyright (C) 2002-2022 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+# Test x86_64 linking; all types of relocs.  This tests the assembler and
+# tools like objdump as well as the linker.
+
+if { !([istarget "x86_64-*-elf*"] || [istarget "x86_64-*-linux*"]) } {
+    return
+}
+
+set emul "elf_x86_64"
+set saved_ASFLAGS "$ASFLAGS"
+set ASFLAGS "$ASFLAGS -mx86-used-note=no"
+
+# List contains test-items with 3 items followed by 2 lists:
+# 0:name 1:ld early options 2:ld late options 3:assembler options
+# 4:filenames of assembler files 5: action and options. 6: name of output file
+
+# Actions:
+# objdump: Apply objdump options on result.  Compare with regex (last arg).
+# nm: Apply nm options on result.  Compare with regex (last arg).
+# readelf: Apply readelf options on result.  Compare with regex (last arg).
+
+set x86_64tests {
+    {"Helper shared library (basic PLT test)"
+      "-shared -melf_x86_64" "" "--64" {pltlib.s} {} "libpltlib.so"}
+    {"basic PLT generation"
+     "-melf_x86_64 tmpdir/libpltlib.so" "" "--64" {plt.s}
+     {{objdump -drj.plt plt.pd}} "plt"}
+    {"Helper shared library" "-shared -melf_x86_64" ""
+     "--64" {tlslib.s} {} "libtlslib.so"}
+    {"TLS -fpic and -fno-pic exec transitions"
+     "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
+      -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
+     "--64" {tlsbinpic.s tlsbin.s}
+     {{readelf -WSsrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
+      {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
+      "tlsbin"}
+    {"TLS -fpic and -fno-pic exec transitions without PLT"
+     "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
+      -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
+     "-mrelax-relocations=yes --64" {tlsbinpic2.s tlsbin.s}
+     {{readelf -WSsrl tlsbin2.rd} {objdump -drj.text tlsbin2.dd}
+      {objdump -sj.got tlsbin2.sd} {objdump -sj.tdata tlsbin2.td}}
+      "tlsbin2"}
+    {"TLS descriptor -fpic and -fno-pic exec transitions"
+     "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
+      -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
+     "--64" {tlsbindesc.s tlsbin.s}
+     {{readelf -WSsrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
+      {objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
+      "tlsbindesc"}
+    {"TLS with global dynamic and descriptors"
+     "-shared -melf_x86_64 --no-ld-generated-unwind-info \
+      -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
+     "--64" {tlsgdesc.s}
+     {{readelf -WSsrl tlsgdesc.rd} {objdump -drj.text\ -Mintel64 tlsgdesc.dd}}
+      "libtlsgdesc.so"}
+    {"TLS in debug sections" "-melf_x86_64" ""
+     "--64" {tlsg.s}
+     {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
+    {"TLS GD->LE transition" "-melf_x86_64" ""
+     "--64" {tlsgd1.s}
+     {{objdump -dwr tlsgd1.dd}} "tlsgd1"}
+    {"TLS LD->LE transition" "-melf_x86_64" ""
+     "--64" {tlsld1.s}
+     {{objdump -dwr tlsld1.dd}} "tlsld1"}
+    {"TLS IE->LE transition" "-melf_x86_64" ""
+     "--64" {tlsie1.s}
+     {{objdump -dwr tlsie1.dd}} "tlsie1"}
+    {"Helper 64bit object 1" "-r -melf_x86_64" ""
+     "--64" {mixed1a.s} {} "libmixe1a.o"}
+    {"Helper 32bit object 1" "-r -melf_i386" ""
+     "--32" {mixed1b.s} {} "libmixe1b.o"}
+    {"Helper 64bit object 2" "-r -melf_x86_64" ""
+     "--64" {mixed2a.s} {} "libmixe2a.o"}
+    {"Helper 32bit object 2" "-r -melf_i386" ""
+     "--32" {mixed2b.s} {} "libmixe2b.o"}
+    {"Split by file with 'l' flag on section."
+     "-split-by-file -r -melf_x86_64" ""
+     "--64" {split-by-file1.s split-by-file2.s}
+     {{readelf -SW split-by-file.rd}} "split-by-file.o"}
+    {"TLS X32 IE->LE transition" "-melf32_x86_64" ""
+     "--x32" {tlsie4.s}
+     {{objdump -dwr tlsie4.dd}} "tlsie4"}
+    {"TLS X32 GD->LE transition" "-melf32_x86_64" ""
+     "--x32" {tlsgd4.s}
+     {{objdump -dwr tlsgd4.dd}} "tlsgd4"}
+    {"Helper TLS GD->IE transition DSO" "-shared -melf_x86_64" ""
+     "--64" {tlsgd5b.s} {} "libtlsgd5.so"}
+    {"TLS GD->IE transition" "-melf_x86_64 tmpdir/libtlsgd5.so" ""
+     "--64" {tlsgd5a.s}
+     {{objdump -dwr tlsgd5.dd}} "tlsgd5a"}
+    {"TLS GD->IE transition without PLT"
+     "-melf_x86_64 tmpdir/libtlsgd5.so" ""
+     "-mrelax-relocations=yes --64" {tlsgd5c.s}
+     {{objdump -dwr tlsgd5.dd}} "tlsgd5b"}
+    {"Helper TLS X32 GD->IE transition DSO" "-shared -melf32_x86_64" ""
+     "--x32" {tlsgd6b.s} {} "libtlsgd6.so"}
+    {"TLS X32 GD->IE transition" "-melf32_x86_64 tmpdir/libtlsgd6.so" ""
+     "--x32" {tlsgd6a.s}
+     {{objdump -dwr tlsgd6.dd}} "tlsgd6a"}
+    {"TLS X32 GD->IE transition without PLT"
+     "-melf32_x86_64 tmpdir/libtlsgd6.so" ""
+     "-mrelax-relocations=yes --x32" {tlsgd6c.s}
+     {{objdump -dwr tlsgd6.dd}} "tlsgd6b"}
+    {"TLS X32 LD->LE transition" "-melf32_x86_64" ""
+     "--x32" {tlsld2.s}
+     {{objdump -dwr tlsld2.dd}} "tlsld2"}
+    {"TLS -mcmodel=large GD->LE transition" "-melf_x86_64" ""
+     "--64" {tlsgd7.s}
+     {{objdump -dwr tlsgd7.dd}} "tlsgd7"}
+    {"TLS -mcmodel=large LD->LE transition" "-melf_x86_64" ""
+     "--64" {tlsld3.s}
+     {{objdump -dwr tlsld3.dd}} "tlsld3"}
+    {"TLS -mcmodel=large LD->LE transition with r15 as GOT base"
+     "-melf_x86_64" ""
+     "--64" {tlsld4.s}
+     {{objdump -dwr tlsld4.dd}} "tlsld4"}
+    {"TLS LD->LE transition without PLT"
+     "-melf_x86_64" ""
+     "--64 -mrelax-relocations=yes"
+     {tlsld5.s}
+     {{objdump -dwr tlsld5.dd}} "tlsld5"}
+    {"TLS X32 LD->LE transition without PLT" "-melf32_x86_64" ""
+     "--x32 -mrelax-relocations=yes"
+     {tlsld6.s}
+     {{objdump -dwr tlsld6.dd}} "tlsld6"}
+    {"TLS -mcmodel=large GD->IE transition" "-melf_x86_64 tmpdir/libtlsgd5.so" ""
+     "--64" {tlsgd8.s}
+     {{objdump -dwrj.text tlsgd8.dd}} "tlsgd8"}
+    {"TLS -mcmodel=large GD->LE transition with r15 as GOT base"
+     "-melf_x86_64" ""
+     "--64" {tlsgd9.s}
+     {{objdump -dwr tlsgd9.dd}} "tlsgd9"}
+    {"TLS -mcmodel=large GD->IE transition with r15 as GOT base"
+     "-melf_x86_64 tmpdir/libtlsgd5.so" ""
+     "--64" {tlsgd10.s}
+     {{objdump -dwrj.text tlsgd10.dd}} "tlsgd10"}
+    {"TLS GD->LE transition without PLT"
+     "-melf_x86_64" ""
+     "--64" {tlsgd11.s}
+     {{objdump -dwr tlsgd11.dd}} "tlsgd11"}
+    {"TLS X32 GD->LE transition without PLT"
+     "-melf32_x86_64" ""
+     "--x32" {tlsgd14.s}
+     {{objdump -dwr tlsgd14.dd}} "tlsgd14"}
+     {"build 32-bit object with 33 locals" "-melf_x86_64 -e 0" "" "--32" {32bit.s} {{ ld incompatible.l }} "dummy" }
+     {"build 64-bit object" "-melf_x86_64 -e 0 --defsym foo=1" "" "--64" {64bit.s} {} "dummy" }
+     {"link mixed objects"  "-melf_x86_64 -e 0 tmpdir/32bit.o tmpdir/64bit.o" "" "" {} { { ld incompatible.l } } "mixed"}
+    {"PR ld/17313 (1)" "-melf_x86_64" ""
+     "--64" {dummy.s} {} ""}
+    {"PR ld/17313 (2)" "-melf_x86_64 -shared --just-symbols=tmpdir/dummy.o" ""
+     "--64" {lea1.s} {} "libpr17313.so"}
+    {"PR ld/17306 (1)" "-melf_x86_64" ""
+     "--64" {pr17306b.s} {} ""}
+    {"PR ld/17306 (2)" "-melf_x86_64 -shared -Bsymbolic --just-symbols=tmpdir/pr17306b.o" ""
+     "--64" {pr17306a.s} {} "libpr17306.so"}
+    {"PR ld/17709 (1)" "-melf_x86_64 -shared" ""
+     "--64" {pr17709a.s} {} "libpr17709.so"}
+    {"PR ld/17709 (2)" "-melf_x86_64 tmpdir/libpr17709.so" ""
+     "--64" {pr17709b.s} {{readelf -rW pr17709.rd}} "pr17709"}
+    {"Build pr19827a.o" "" ""
+     "--64" { pr19827a.S }}
+    {"Build pr19827b.so" "-melf_x86_64 -shared" ""
+     "--64" { pr19827b.S } {} "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 -z notext" ""
+     "--64" { pr19827a.S }  {{readelf {-rW} pr19827.rd}} "pr19827.so"}
+    {"Build pr19969.so" "-melf_x86_64 -shared" ""
+     "--64" { pr19969a.S } {} "pr19969.so"}
+    {"Build pr20550a.o" "" ""
+     "--64" { pr20550a.s }}
+    {"Build pr20550b.so" "-melf_x86_64 -shared" ""
+     "--64" { pr20550b.s } {} "pr20550b.so"}
+    {"Build pr20550"
+     "-melf_x86_64 -pie -z notext tmpdir/pr20550a.o tmpdir/pr20550b.so"
+     ""
+     "--64" { dummy.s } {} "pr20550"}
+    {"Build pr27587"
+     "-melf_x86_64 -e main"
+     "" ""
+     { pr27587a.obj.bz2 pr27587b.obj.bz2 }
+     {{ld "pr27587.err"}} "pr27587"}
+    {"Build pr27590.o"
+     "-r -melf_x86_64"
+     "" ""
+     { pr27590a.obj.bz2 pr27590b.obj.bz2 }
+     {{readelf -SW pr27590.rd}} "pr27590.o"}
+    {"Build textrel-1.so" "-melf_x86_64 -shared" ""
+     "--64" { textrel-1a.s } {} "textrel-1.so"}
+    {"Build textrel-1" "-no-pie -melf_x86_64 -z nocopyreloc --warn-textrel"
+     "tmpdir/textrel-1.so"
+     "--64" { textrel-1b.s } {{ld "textrel-1.err"}} "textrel-1"}
+}
+
+run_ld_link_tests $x86_64tests
+
+run_ld_link_tests [list \
+    [list \
+	"TLS -fpic -shared transitions" \
+	"-shared -melf_x86_64 --no-ld-generated-unwind-info \
+	 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv \
+	 $NO_DT_RELR_LDFLAGS" \
+	"" "--64" \
+	{tlspic1.s tlspic2.s} \
+	{{readelf -WSsrl tlspic.rd} \
+	 {objdump {-drj.text -Mintel64} tlspic.dd} \
+	 {objdump -sj.got tlspic.sd} \
+	 {objdump -sj.tdata tlspic.td}} \
+	"libtlspic.so" \
+    ] \
+    [list \
+	"TLS -fpic -shared transitions with r15 as GOT base" \
+	"-shared -melf_x86_64 --no-ld-generated-unwind-info \
+	 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv \
+	 $NO_DT_RELR_LDFLAGS" \
+	 "" "--64 -mrelax-relocations=yes" \
+	{tlspic3.s tlspic2.s} \
+	{{readelf -WSsrl tlspic2.rd} \
+	 {objdump {-drj.text -Mintel64} tlspic2.dd} \
+	 {objdump -sj.got tlspic2.sd} \
+	 {objdump -sj.tdata tlspic2.td}} \
+	"libtlspic2.so" \
+    ] \
+    [list \
+	"TLS descriptor -fpic -shared transitions" \
+	"-shared -melf_x86_64 --no-ld-generated-unwind-info \
+	 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv \
+	 $NO_DT_RELR_LDFLAGS" \
+	"" "--64" \
+	{tlsdesc.s tlspic2.s} \
+	{{readelf -WSsrld tlsdesc.rd} \
+	 {objdump -drj.text tlsdesc.dd} \
+	 {objdump {-s -j.got -j.got.plt} tlsdesc.sd} \
+	 {objdump -sj.tdata tlsdesc.td} \
+	 {objdump -drj.plt tlsdesc.pd}} \
+	 "libtlsdesc.so" \
+    ] \
+]
+
+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"] } {
+    if [string match "*i386* architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64* output*" $link_output] {
+	pass "$test_name"
+    } {
+	fail "$test_name"
+    }
+}
+
+set test_name "Mixed x86_64 and i386 input test 2"
+set test mixed2
+if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
+    if [string match "*i386* architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64* output*" $link_output] {
+	pass "$test_name"
+    } {
+	fail "$test_name"
+    }
+}
+
+run_dump_test "abs"
+run_dump_test "abs-k1om"
+run_dump_test "abs-l1om"
+run_dump_test "apic"
+run_dump_test "pcrel8"
+run_dump_test "pcrel16"
+run_dump_test "pcrel16-2"
+run_dump_test "rela"
+run_dump_test "tlsgd2"
+run_dump_test "tlsgd3"
+run_dump_test "tlsgd12"
+run_dump_test "tlsgd13"
+run_dump_test "tlsie2"
+run_dump_test "tlsie3"
+run_dump_test "hidden1"
+run_dump_test "hidden2"
+run_dump_test "hidden3"
+run_dump_test "hidden4"
+run_dump_test "hidden5"
+run_dump_test "protected1"
+run_dump_test "protected2"
+run_dump_test "protected2-k1om"
+run_dump_test "protected2-l1om"
+run_dump_test "protected3"
+run_dump_test "protected3-k1om"
+run_dump_test "protected3-l1om"
+run_dump_test "protected4"
+run_dump_test "protected5"
+run_dump_test "protected6a"
+run_dump_test "protected6b"
+run_dump_test "protected7a"
+run_dump_test "protected7b"
+run_dump_test "protected8"
+run_dump_test "tlsle1"
+run_dump_test "tlspie1"
+run_dump_test "tlspie2a"
+run_dump_test "tlspie2b"
+run_dump_test "tlspie2c"
+run_dump_test "unique1"
+run_dump_test "nogot1"
+run_dump_test "nogot2"
+run_dump_test "discarded1"
+run_dump_test "pr12718"
+run_dump_test "pr12921"
+run_dump_test "pr13947"
+run_dump_test "pr12570a"
+run_dump_test "pr12570b"
+run_dump_test "pr14215"
+run_dump_test "pr14207"
+run_dump_test "gotplt1"
+run_dump_test "pie1"
+run_dump_test "pie2"
+run_dump_test "pie3"
+run_dump_test "pic1"
+run_dump_test "largecomm-1a"
+run_dump_test "largecomm-1b"
+run_dump_test "largecomm-1c"
+run_dump_test "largecomm-1d"
+run_dump_test "largecomm-1e"
+run_dump_test "largecomm-1f"
+run_dump_test "pr19539a"
+run_dump_test "pr19539b"
+run_dump_test "pr19807-1a"
+run_dump_test "pr19807-1b"
+run_dump_test "pr19807-2a"
+run_dump_test "pr19807-2b"
+run_dump_test "pr19807-2c"
+run_dump_test "pr19807-2d"
+run_dump_test "pr19807-2e"
+run_dump_test "pr19969"
+run_dump_test "pr20093-1"
+run_dump_test "pr20093-2"
+run_dump_test "property-x86-3"
+run_dump_test "property-x86-4a"
+run_dump_test "property-x86-4b"
+run_dump_test "property-x86-3-x32"
+run_dump_test "property-x86-4a-x32"
+run_dump_test "property-x86-4b-x32"
+run_dump_test "property-x86-5"
+run_dump_test "property-x86-5-x32"
+run_dump_test "property-x86-6"
+run_dump_test "property-x86-6-x32"
+run_dump_test "property-x86-ibt1a"
+run_dump_test "property-x86-ibt1b"
+run_dump_test "property-x86-ibt1a-x32"
+run_dump_test "property-x86-ibt1b-x32"
+run_dump_test "property-x86-ibt2"
+run_dump_test "property-x86-ibt2-x32"
+run_dump_test "property-x86-ibt3a"
+run_dump_test "property-x86-ibt3b"
+run_dump_test "property-x86-ibt3a-x32"
+run_dump_test "property-x86-ibt3b-x32"
+run_dump_test "property-x86-ibt4"
+run_dump_test "property-x86-ibt4-x32"
+run_dump_test "property-x86-ibt5"
+run_dump_test "property-x86-ibt5-x32"
+run_dump_test "property-x86-shstk1a"
+run_dump_test "property-x86-shstk1b"
+run_dump_test "property-x86-shstk1a-x32"
+run_dump_test "property-x86-shstk1b-x32"
+run_dump_test "property-x86-shstk2"
+run_dump_test "property-x86-shstk2-x32"
+run_dump_test "property-x86-shstk3a"
+run_dump_test "property-x86-shstk3b"
+run_dump_test "property-x86-shstk3a-x32"
+run_dump_test "property-x86-shstk3b-x32"
+run_dump_test "property-x86-shstk4"
+run_dump_test "property-x86-shstk4-x32"
+run_dump_test "property-x86-shstk5"
+run_dump_test "property-x86-shstk5-x32"
+run_dump_test "property-x86-cet1"
+run_dump_test "property-x86-cet1-x32"
+run_dump_test "property-x86-cet2a"
+run_dump_test "property-x86-cet2a-x32"
+run_dump_test "property-x86-cet2b"
+run_dump_test "property-x86-cet2b-x32"
+run_dump_test "property-x86-cet3a"
+run_dump_test "property-x86-cet3a-x32"
+run_dump_test "property-x86-cet3b"
+run_dump_test "property-x86-cet3b-x32"
+run_dump_test "property-x86-cet4a"
+run_dump_test "property-x86-cet4a-x32"
+run_dump_test "property-x86-cet4b"
+run_dump_test "property-x86-cet4b-x32"
+run_dump_test "property-x86-cet5a"
+run_dump_test "property-x86-cet5a-x32"
+run_dump_test "property-x86-cet5b"
+run_dump_test "property-x86-cet5b-x32"
+run_dump_test "property-x86-cet6"
+run_dump_test "property-x86-cet6-x32"
+run_dump_test "property-x86-lam-u48-1a"
+run_dump_test "property-x86-lam-u48-1b"
+run_dump_test "property-x86-lam-u48-2"
+run_dump_test "property-x86-lam-u48-3a"
+run_dump_test "property-x86-lam-u48-3b"
+run_dump_test "property-x86-lam-u48-4"
+run_dump_test "property-x86-lam-u48-5"
+run_dump_test "property-x86-lam-u57-1a"
+run_dump_test "property-x86-lam-u57-1b"
+run_dump_test "property-x86-lam-u57-2"
+run_dump_test "property-x86-lam-u57-3a"
+run_dump_test "property-x86-lam-u57-3b"
+run_dump_test "property-x86-lam-u57-4"
+run_dump_test "property-x86-lam-u57-5"
+run_dump_test "pr21884"
+run_dump_test "pr22071"
+run_dump_test "pr22115-1a"
+run_dump_test "pr22115-1a-x32"
+run_dump_test "pr22115-1b"
+run_dump_test "pr22115-1b-x32"
+run_dump_test "pr22115-1c"
+run_dump_test "pr22115-1c-x32"
+run_dump_test "pr22115-1d"
+run_dump_test "pr22115-1d-x32"
+run_dump_test "pr22135"
+run_dump_test "pr22782a"
+run_dump_test "pr22782b"
+run_dump_test "pr23189"
+run_dump_test "pr23194"
+run_dump_test "pr23324a"
+run_dump_test "pr23324b"
+run_dump_test "pr23372a"
+run_dump_test "pr23372a-x32"
+run_dump_test "pr23372b"
+run_dump_test "pr23372b-x32"
+run_dump_test "pr23372c"
+run_dump_test "pr23372c-x32"
+run_dump_test "pr23372d"
+run_dump_test "pr23372d-x32"
+run_dump_test "pr23486a"
+run_dump_test "pr23486a-x32"
+run_dump_test "pr23486b"
+run_dump_test "pr23486b-x32"
+run_dump_test "pr23486c"
+run_dump_test "pr23486c-x32"
+run_dump_test "pr23486d"
+run_dump_test "pr23486d-x32"
+run_dump_test "pr23854"
+run_dump_test "pr23930"
+run_dump_test "pr23930-x32"
+run_dump_test "pr24151a"
+run_dump_test "pr24151a-x32"
+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"
+run_dump_test "pr26263"
+run_dump_test "pr26711-1"
+run_dump_test "pr26711-1-x32"
+run_dump_test "pr26711-2"
+run_dump_test "pr26711-2-x32"
+run_dump_test "pr26711-3"
+run_dump_test "pr26711-3-x32"
+run_dump_test "property-x86-isa1"
+run_dump_test "property-x86-isa1-x32"
+run_dump_test "property-x86-isa2"
+run_dump_test "property-x86-isa2-x32"
+run_dump_test "property-x86-isa3"
+run_dump_test "property-x86-isa3-x32"
+run_dump_test "property-x86-isa4"
+run_dump_test "property-x86-isa4-x32"
+run_dump_test "code16"
+run_dump_test "pr27491-1a"
+run_dump_test "pr27491-1b"
+run_dump_test "pr27491-1c"
+run_dump_test "pr27491-2"
+run_dump_test "pr27491-3"
+run_dump_test "pr27491-4"
+run_dump_test "dt-relr-1a"
+run_dump_test "dt-relr-1a-x32"
+run_dump_test "dt-relr-1b"
+run_dump_test "dt-relr-1b-x32"
+
+if ![istarget "x86_64-*-linux*"] {
+    return
+}
+
+if ![ld_assemble $as "--x32 $srcdir/$subdir/start.s" tmpdir/startx32.o] {
+    fail "Build ILP32 start.o"
+    return
+}
+
+if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
+    fail "Build ia32 start.o"
+    return
+}
+
+if ![ld_assemble $as "--64 $srcdir/$subdir/start.s" tmpdir/start64.o] {
+    fail "Build LP64 start.o"
+    return
+}
+
+if ![ld_assemble $as "--x32 $srcdir/$subdir/foo.s" tmpdir/foox32.o] {
+    fail "Build ILP32 foo.o"
+    return
+}
+
+if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
+    fail "Build ia32 foo.o"
+    return
+}
+
+if ![ld_assemble $as "--64 $srcdir/$subdir/foo.s" tmpdir/foo64.o] {
+    fail "Build LP64 foo.o"
+    return
+}
+
+run_dump_test "compressed1"
+run_dump_test "ilp32-1"
+run_dump_test "ilp32-2"
+run_dump_test "ilp32-3"
+run_dump_test "ilp32-4"
+run_dump_test "ilp32-5"
+run_dump_test "ilp32-6"
+run_dump_test "ilp32-7"
+run_dump_test "ilp32-8"
+run_dump_test "ilp32-9"
+run_dump_test "ilp32-10"
+run_dump_test "ilp32-11"
+run_dump_test "ilp32-12"
+run_dump_test "ia32-1"
+run_dump_test "ia32-2"
+run_dump_test "ia32-3"
+run_dump_test "lp64-1"
+run_dump_test "lp64-2"
+run_dump_test "lp64-3"
+run_dump_test "pr13082-1a"
+run_dump_test "pr13082-1b"
+run_dump_test "pr13082-2a"
+run_dump_test "pr13082-2b"
+run_dump_test "pr13082-3a"
+run_dump_test "pr13082-3b"
+run_dump_test "pr13082-3c"
+run_dump_test "pr13082-3d"
+run_dump_test "pr13082-4a"
+run_dump_test "pr13082-4b"
+run_dump_test "pr13082-5a"
+run_dump_test "pr13082-5b"
+run_dump_test "pr13082-6a"
+run_dump_test "pr13082-6b"
+run_dump_test "lea1a"
+run_dump_test "lea1b"
+run_dump_test "lea1c"
+run_dump_test "lea1d"
+run_dump_test "lea1e"
+run_dump_test "lea1f"
+run_dump_test "lea1g"
+run_dump_test "lea1h"
+run_dump_test "lea1i"
+run_dump_test "lea1j"
+run_dump_test "lea1k"
+run_dump_test "lea1l"
+run_dump_test "mov1a"
+run_dump_test "mov1b"
+run_dump_test "mov1c"
+run_dump_test "mov1d"
+run_dump_test "mov2a"
+run_dump_test "mov2b"
+run_dump_test "mov2c"
+run_dump_test "mov2d"
+run_dump_test "ljmp1"
+run_dump_test "ljmp2"
+run_dump_test "load1a"
+run_dump_test "load1b"
+run_dump_test "load1c"
+run_dump_test "load1d"
+run_dump_test "load2"
+run_dump_test "call1a"
+run_dump_test "call1b"
+run_dump_test "call1c"
+run_dump_test "call1d"
+run_dump_test "call1e"
+run_dump_test "call1f"
+run_dump_test "call1g"
+run_dump_test "call1h"
+run_dump_test "call1i"
+run_dump_test "pr17935-1"
+run_dump_test "pr17935-2"
+run_dump_test "pr18160"
+run_dump_test "pr18176"
+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"
+run_dump_test "pr19162"
+run_dump_test "pr19175"
+run_dump_test "pr18591"
+run_dump_test "pr19615"
+run_dump_test "pr19636-1a"
+run_dump_test "pr19636-1b"
+run_dump_test "pr19636-1c"
+run_dump_test "pr19636-1d"
+run_dump_test "pr19636-1e"
+run_dump_test "pr19636-1f"
+run_dump_test "pr19636-1g"
+run_dump_test "pr19636-1h"
+run_dump_test "pr19636-1i"
+run_dump_test "pr19636-1j"
+run_dump_test "pr19636-2a"
+run_dump_test "pr19636-2b"
+run_dump_test "pr19636-2c"
+run_dump_test "pr19636-2d"
+run_dump_test "pr19636-2e"
+run_dump_test "pr19636-2f"
+run_dump_test "pr19636-2g"
+run_dump_test "pr19636-2h"
+run_dump_test "pr19636-2i"
+run_dump_test "pr19636-2j"
+run_dump_test "pr19636-2k"
+run_dump_test "pr19636-2l"
+run_dump_test "pr19636-2m"
+run_dump_test "pr19636-3a"
+run_dump_test "pr19636-3b"
+run_dump_test "pr19636-3c"
+run_dump_test "pr19645"
+run_dump_test "pr19609-1a"
+run_dump_test "pr19609-1b"
+run_dump_test "pr19609-1c"
+run_dump_test "pr19609-1d"
+run_dump_test "pr19609-1e"
+run_dump_test "pr19609-1f"
+run_dump_test "pr19609-1g"
+run_dump_test "pr19609-1h"
+run_dump_test "pr19609-1i"
+run_dump_test "pr19609-1j"
+run_dump_test "pr19609-1k"
+run_dump_test "pr19609-1l"
+run_dump_test "pr19609-1m"
+run_dump_test "pr19609-2a"
+run_dump_test "pr19609-2b"
+run_dump_test "pr19609-2c"
+run_dump_test "pr19609-2d"
+run_dump_test "pr19609-3a"
+run_dump_test "pr19609-3b"
+run_dump_test "pr19609-4a"
+run_dump_test "pr19609-4b"
+run_dump_test "pr19609-4c"
+run_dump_test "pr19609-4d"
+run_dump_test "pr19609-4e"
+run_dump_test "pr19609-5a"
+run_dump_test "pr19609-5b"
+run_dump_test "pr19609-5c"
+run_dump_test "pr19609-5d"
+run_dump_test "pr19609-5e"
+run_dump_test "pr19609-6a"
+run_dump_test "pr19609-6b"
+run_dump_test "pr19609-6c"
+run_dump_test "pr19609-6d"
+run_dump_test "pr19609-7a"
+run_dump_test "pr19609-7b"
+run_dump_test "pr19609-7c"
+run_dump_test "pr19609-7d"
+run_dump_test "pr19939a"
+run_dump_test "pr19939b"
+run_dump_test "pr19719"
+run_dump_test "pr20253-1a"
+run_dump_test "pr20253-1b"
+run_dump_test "pr20253-1c"
+run_dump_test "pr20253-1d"
+run_dump_test "pr20253-1e"
+run_dump_test "pr20253-1f"
+run_dump_test "pr20253-1g"
+run_dump_test "pr20253-1h"
+run_dump_test "pr20253-1i"
+run_dump_test "pr20253-1j"
+run_dump_test "pr20253-1k"
+run_dump_test "pr20253-1l"
+run_dump_test "pr20253-3"
+run_dump_test "pr20253-4a"
+run_dump_test "pr20253-4b"
+run_dump_test "pr20253-4c"
+run_dump_test "pr20253-4d"
+run_dump_test "pr20253-4e"
+run_dump_test "pr20253-4f"
+run_dump_test "pr20253-5a"
+run_dump_test "pr20253-5b"
+run_dump_test "tlsdesc2"
+run_dump_test "pr22048"
+run_dump_test "pr22929"
+run_dump_test "pr26939"
+run_dump_test "pr26939-x32"
+run_dump_test "pr27016a"
+run_dump_test "pr27016b"
+run_dump_test "report-reloc-1"
+run_dump_test "report-reloc-1-x32"
+
+proc undefined_weak {cflags ldflags} {
+    set testname "Undefined weak symbol"
+    if { ![ string match "" $cflags$ldflags] } {
+	set testname "$testname ($cflags $ldflags)"
+    }
+
+    if { [string match "*-fPIE*" $cflags]
+	 && ![string match "*nodynamic-undefined-weak*" $ldflags] } {
+	set weak_symbol "Weak defined"
+    } else {
+	set weak_symbol "Weak undefined"
+    }
+
+    run_cc_link_tests [list \
+	[list \
+	    "Build libpr19704a.so" \
+	    "-shared -Wl,-soname,libpr19704.so" \
+	    "" \
+	    { dummy.s } \
+	    {} \
+	    "libpr19704a.so" \
+	] \
+	[list \
+	    "Build libpr19704b.so" \
+	    "-shared -Wl,-soname,libpr19704.so" \
+	    "-fPIC" \
+	    { pr19704b.c } \
+	    {} \
+	    "libpr19704b.so" \
+	] \
+    ]
+
+    exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so
+
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run pr19704" \
+	    "-Wl,--no-as-needed,-R,tmpdir $ldflags tmpdir/libpr19704.so" \
+	    "" \
+	    { pr19704a.c } \
+	    "pr19704" \
+	    "pr19704.out" \
+	    "$cflags" \
+	] \
+    ]
+
+    exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so
+
+    set exec_output [run_host_cmd tmpdir/pr19704 ""]
+    if {![string match $weak_symbol $exec_output]} {
+	fail $testname
+    } else {
+	pass $testname
+    }
+}
+
+# Must be native with the C compiler
+if { [isnative] && [check_compiler_available] } {
+    run_cc_link_tests [list \
+	[list \
+	    "Helper X32 DSO from x86-64 object" "" \
+	    "-m64 $NOSANITIZE_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"
+    set got [remote_exec host "$convertx32"]
+    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+	send_log "$got\n"
+	fail "Convert x86-64 object to x32"
+	return
+    }
+
+    run_ld_link_tests [list \
+	[list \
+	    "X32 DSO from x86-64 object" \
+	    "-shared -melf32_x86_64 tmpdir/simple-x32.o" \
+	    "$NOSANITIZE_CFLAGS" \
+	    "--x32 -mx86-used-note=yes" \
+	    {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} \
+	    "x86-64-x32" \
+	] \
+    ]
+
+    run_cc_link_tests [list \
+	[list \
+	    "Build plt-lib.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { plt-lib.c } \
+	    {} \
+	    "libplt-lib.so" \
+	] \
+	[list \
+	    "Build libplt-main1.a" \
+	    "" \
+	    "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
+	    { plt-main1.c } \
+	    {{readelf {-Wr} plt-main1.rd}} \
+	    "libplt-main1.a" \
+	] \
+	[list \
+	    "Build libplt-main2.a" \
+	    "" \
+	    "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
+	    { plt-main2.c } \
+	    {{readelf {-Wr} plt-main2.rd}} \
+	    "libplt-main2.a" \
+	] \
+	[list \
+	    "Build libplt-main3.a" \
+	    "" \
+	    "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes $PLT_CFLAGS" \
+	    { plt-main3.c } \
+	    {{readelf {-Wr} plt-main3.rd}} \
+	    "libplt-main3.a" \
+	] \
+	[list \
+	    "Build libplt-main4.a" \
+	    "" \
+	    "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes $PLT_CFLAGS" \
+	    { plt-main4.c } \
+	    {{readelf {-Wr} plt-main4.rd}} \
+	    "libplt-main4.a" \
+	] \
+	[list \
+	    "Build plt-main" \
+	    "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+	     tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+	    "" \
+	    { plt-main5.c } \
+	    {{readelf {-Wr} plt-main.rd}} \
+	    "plt-main" \
+	] \
+	[list \
+	    "Build plt-main with PIE" \
+	    "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+	     tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { plt-main5.c } \
+	    {{readelf {-Wr} plt-main.rd}} \
+	    "plt-main" \
+	] \
+	[list \
+	    "Build copyreloc-lib.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { copyreloc-lib.c } \
+	    {} \
+	    "copyreloc-lib.so" \
+	] \
+	[list \
+	    "Build libcopyreloc-main.a" \
+	    "" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { copyreloc-main.S } \
+	    {} \
+	    "libcopyreloc-main.a" \
+	] \
+	[list \
+	    "Build copyreloc-main with PIE without -fPIE (1)" \
+	    "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wr} copyreloc-main1.rd}} \
+	    "copyreloc-main" \
+	] \
+	[list \
+	    "Build copyreloc-main with PIE without -fPIE (2)" \
+	    "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wr} copyreloc-main2.rd}} \
+	    "copyreloc-main" \
+	] \
+	[list \
+	    "Build pr17689.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr17689a.c } \
+	    {} \
+	    "pr17689.so" \
+	] \
+	[list \
+	    "Build pr17689now.so with -z now" \
+	    "-shared -Wl,-z,now" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr17689a.c } \
+	    {{readelf {-Wr} pr17689now.rd}} \
+	    "pr17689now.so" \
+	] \
+	[list \
+	    "Build pr17689b.o" \
+	    "" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr17689b.S } \
+	    {} \
+	] \
+	[list \
+	    "Build pr17689 with PIE without -fPIE" \
+	    "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wr} pr17689.rd}} \
+	    "pr17689" \
+	] \
+	[list \
+	    "Build pr17689 with PIE -z now without -fPIE" \
+	    "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -Wl,-z,now" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wr} pr17689now.rd}} \
+	    "pr17689now" \
+	] \
+	[list \
+	    "Build pr17827 with PIE without -fPIE" \
+	    "-Wl,--as-needed tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wr} pr17827.rd}} \
+	    "pr17827" \
+	] \
+	[list \
+	    "Build pr18900.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr18900a.c } \
+	    "" \
+	    "pr18900.so" \
+	] \
+	[list \
+	    "Build pr18900.o" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr18900b.c pr18900c.c } \
+	    "" \
+	    "pr18900.o" \
+	] \
+	[list \
+	    "Build pr18900a" \
+	    "tmpdir/pr18900.o tmpdir/pr18900.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wrd} pr18900a.rd}} \
+	    "pr18900a" \
+	] \
+	[list \
+	    "Build pr18900b" \
+	    "-Wl,--as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    {{readelf {-Wrd} pr18900b.rd}} \
+	    "pr18900b" \
+	] \
+	[list \
+	    "Build pr19031.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr19031a.c } \
+	    "" \
+	    "pr19031.so" \
+	] \
+	[list \
+	    "Build gotpcrel1d.so" \
+	    "-shared" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { gotpcrel1d.S } \
+	    "" \
+	    "gotpcrel1d.so" \
+	] \
+	[list \
+	    "Build gotpcrel1a.o gotpcrel1b.o gotpcrel1c.o" \
+	    "" \
+	    "-Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
+	    { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
+	] \
+	[list \
+	    "Build gotpcrel1" \
+	    "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/gotpcrel1a.o \
+	     tmpdir/gotpcrel1b.o tmpdir/gotpcrel1c.o \
+	     tmpdir/gotpcrel1d.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    {{objdump {-dw} gotpcrel1.dd}} \
+	    "gotpcrel1" \
+	] \
+	[list \
+	    "Build pr19319.so" \
+	    "-shared" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr19319a.S } \
+	    "" \
+	    "pr19319.so" \
+	] \
+	[list \
+	    "Build pr19319" \
+	    "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr19319b.S } \
+	    {{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" \
+	    "" \
+	    "-Wa,-mx86-used-note=no" \
+	    {pass.c property-no-copy.S} \
+	    {{readelf {-n} property-1.r}} \
+	    "property-1" \
+	] \
+	[list \
+	    "Build property 1 (.o)" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-no-copy.S} \
+	    {{readelf {-n} property-1a.r}} \
+	    "property-1.o" \
+	] \
+	[list \
+	    "Build property 1 (.so)" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=no" \
+	    {pass.c property-no-copy.S} \
+	    {{readelf {-n} property-1.r}} \
+	    "property-1.so" \
+	] \
+	[list \
+	    "Build property 2" \
+	    "" \
+	    "-Wa,-mx86-used-note=no" \
+	    {pass.c property-stack.S} \
+	    {{readelf {-n} property-2.r}} \
+	    "property-2" \
+	] \
+	[list \
+	    "Build property 2 (.o)" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-stack.S} \
+	    {{readelf {-n} property-2a.r}} \
+	    "property-2.o" \
+	] \
+	[list \
+	    "Build property 2 (.so)" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    {pass.c property-stack.S} \
+	    {{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" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    {property-6a.c property-6c.S} \
+	    {{readelf {-n} property-6.r}} \
+	    "property-6.so" \
+	] \
+	[list \
+	    "Build property-6.o" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {property-6b.c property-stack.S} \
+	    {{readelf {-n} property-2a.r}} \
+	    "property-6.o" \
+	] \
+	[list \
+	    "Build property-6" \
+	    "-Wl,--as-needed tmpdir/property-6.o tmpdir/property-6.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    {{readelf {-n} property-2.r}} \
+	    "property-6" \
+	] \
+	[list \
+	    "Build property 7a (.o)" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {property-unsorted-1.S} \
+	    {{readelf {-n} property-7a.r}} \
+	    "property-7a.o" \
+	] \
+	[list \
+	    "Build property 7b (.o)" \
+	    "-r -nostdlib" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {property-unsorted-2.S} \
+	    {{readelf {-n} property-7a.r}} \
+	    "property-7b.o" \
+	] \
+	[list \
+	    "Build pr22001-1.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr22001-1a.c } \
+	    {} \
+	    "pr22001-1.so" \
+	] \
+	[list \
+	    "Build pr22001-1a" \
+	    "$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"}} \
+	    "pr22001-1a" \
+	] \
+	[list \
+	    "Build pr21997-1.so" \
+	    "-shared" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { property-stack.S property-no-copy.S pr21997-1a.S } \
+	    {} \
+	    "pr21997-1.so" \
+	] \
+	[list \
+	    "Build pr21997-1a" \
+	    "$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"}} \
+	    "pr21997-1a" \
+	] \
+	[list \
+	    "Build pr22064a.o" \
+	    "" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22064a.S } \
+	] \
+	[list \
+	    "Build pr22064.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr22064b.c } \
+	    {} \
+	    "pr22064.so" \
+	] \
+	[list \
+	    "Build pr22393-3a.so" \
+	    "-shared -Wl,-z,separate-code,-z,max-page-size=0x1000" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    {pr22393-3a.c} \
+	    {{readelf -lW pr22393-3a.rd} \
+	     {readelf -lW pr22393-3b.rd}} \
+	    "pr22393-3a.so" \
+	] \
+	[list \
+	    "Build pr22393-3a-now.so" \
+	    "-shared -Wl,-z,separate-code,-z,now,-z,max-page-size=0x1000" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    {pr22393-3a.c} \
+	    {{readelf -lW pr22393-3a.rd} \
+	     {readelf -lW pr22393-3b.rd}} \
+	    "pr22393-3a-now.so" \
+	] \
+	[list \
+	    "Build pr22393-3" \
+	    "$NOPIE_LDFLAGS -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a.so" \
+	    "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
+	    {pr22393-3b.c} \
+	    {{readelf -lW pr22393-3a.rd} \
+	     {readelf -lW pr22393-3b.rd}} \
+	    "pr22393-3" \
+	] \
+	[list \
+	    "Build pr22393-3 (PIE)" \
+	    "-pie -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a-now.so" \
+	    "-fPIE -Wa,-mx86-used-note=yes" \
+	    {pr22393-3b.c} \
+	    {{readelf -lW pr22393-3a.rd} \
+	     {readelf -lW pr22393-3b.rd}} \
+	    "pr22393-3-pie" \
+	] \
+	[list \
+	    "Build pr22393-3 (static)" \
+	    "-static -Wl,-z,separate-code,-z,max-page-size=0x1000" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pr22393-3a.c pr22393-3b.c} \
+	    {{readelf -lW pr22393-3a.rd} \
+	     {readelf -lW pr22393-3b.rd}} \
+	    "pr22393-3-static" \
+	] \
+	[list \
+	    "Build pr22791-1.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr22791-1a.c } \
+	    {} \
+	    "pr22791-1.so" \
+	] \
+	[list \
+	    "Build pr22791-1" \
+	    "-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"}} \
+	    "pr22791-1" \
+	] \
+	[list \
+	    "Build pr22791-2a.o" \
+	    "" \
+	    "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
+	    { pr22791-2a.s } \
+	] \
+	[list \
+	    "Build pr22791-2.so" \
+	    "-shared tmpdir/pr22791-2a.o" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr22791-2b.c } \
+	    {{readelf -drW pr22791-2.rd}} \
+	    "pr22791-2.so" \
+	] \
+	[list \
+	    "Build pr22791-2" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr22791-2.so" \
+	    "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
+	    { pr22791-2c.s } \
+	    {{readelf -drW pr22791-2.rd}} \
+	    "pr22791-2" \
+	] \
+	[list \
+	    "Build pr22842.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { pr22842a.c } \
+	    {} \
+	    "pr22842.so" \
+	] \
+	[list \
+	    "Build pr22842" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22842b.S } \
+	    {{readelf -rW pr22842a.rd} \
+	     {readelf -rW pr22842b.rd}} \
+	    "pr22842" \
+	] \
+	[list \
+	    "Build libprotected-func-1.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { protected-func-1a.s } \
+	    {} \
+	    "libprotected-func-1.so" \
+	] \
+	[list \
+	    "Build libprotected-func-2a.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { protected-func-2a.S } \
+	    {{readelf -n indirect-extern-access.rd}}  \
+	    "libprotected-func-2a.so" \
+	] \
+	[list \
+	    "Build libprotected-func-2b.so" \
+	    "-shared -z indirect-extern-access" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { protected-func-2c.c } \
+	    {{readelf -n indirect-extern-access.rd}}  \
+	    "libprotected-func-2b.so" \
+	] \
+	[list \
+	    "Build libprotected-data-1a.so" \
+	    "-shared -z noindirect-extern-access" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { protected-data-1a.c } \
+	    {} \
+	    "libprotected-data-1a.so" \
+	] \
+	[list \
+	    "Build libprotected-data-1b.so" \
+	    "-shared -z indirect-extern-access" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { protected-data-1a.c } \
+	    {} \
+	    "libprotected-data-1b.so" \
+	] \
+	[list \
+	    "Build protected-data-1 without PIE" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-data-1b.so" \
+	    "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
+	    { protected-data-1b.c } \
+	    {} \
+	    "protected-data-1" \
+	] \
+	[list \
+	    "Build libprotected-data-2a.so" \
+	    "-shared" \
+	    "-fPIC -Wa,-mx86-used-note=yes \
+	     -DUSE_GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS" \
+	    { protected-data-2a.S } \
+	    {{readelf -n indirect-extern-access.rd}}  \
+	    "libprotected-data-2a.so" \
+	] \
+	[list \
+	    "Build libprotected-data-2b.so" \
+	    "-shared -z indirect-extern-access" \
+	    "-fPIC -Wa,-mx86-used-note=yes" \
+	    { protected-data-2a.S } \
+	    {{readelf -n indirect-extern-access.rd}}  \
+	    "libprotected-data-2b.so" \
+	] \
+    ]
+
+    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,-z,notext tmpdir/pr22001-1.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ pr22001-1c.c } \
+		"pr22001-1b" \
+		"pass.out" \
+		"$NOPIE_CFLAGS" \
+	    ] \
+	    [list \
+		"Run pr21997-1b" \
+		"$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,-z,notext tmpdir/pr22001-1.so" \
+		"$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
+		{ pr22001-1c.c } \
+		{{error_output "pr22001-1b.err"}} \
+		"pr22001-1b" \
+	    ] \
+	    [list \
+		"Build pr21997-1b" \
+		"$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"}} \
+		"pr21997-1b" \
+	    ] \
+	    [list \
+		"Build lam-u48.so" \
+		"-shared -Wl,-z,lam-u48" \
+		"" \
+		{dummy.s} \
+		{{readelf -n lam-u48.rd}}  \
+		"lam-u48.so" \
+	    ] \
+	    [list \
+		"Build lam-u57.so" \
+		"-shared -Wl,-z,lam-u57" \
+		"" \
+		{dummy.s} \
+		{{readelf -n lam-u57.rd}}  \
+		"lam-u57.so" \
+	    ] \
+	]
+    }
+
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run plt-main" \
+	    "-Wl,--no-as-needed tmpdir/plt-main1.o tmpdir/plt-main2.o \
+	     tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { plt-main5.c } \
+	    "plt-main" \
+	    "plt-main.out" \
+	] \
+	[list \
+	    "Run plt-main with PIE" \
+	    "-Wl,--no-as-needed -pie tmpdir/plt-main1.o tmpdir/plt-main2.o \
+	     tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { plt-main5.c } \
+	    "plt-main-pie" \
+	    "plt-main.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run copyreloc-main with PIE without -fPIE" \
+	    "-Wl,--as-needed -pie tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    "copyreloc-main" \
+	    "copyreloc-main.out" \
+	] \
+	[list \
+	    "Run pr17689 with PIE without -fPIE" \
+	    "-Wl,--no-as-needed -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    "pr17689" \
+	    "pr17689.out" \
+	] \
+	[list \
+	    "Run pr17689 with PIE -z now without -fPIE" \
+	    "-Wl,--as-needed,-z,now -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    "pr17689now" \
+	    "pr17689.out" \
+	] \
+	[list \
+	    "Run pr18900" \
+	    "-Wl,--no-as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    "pr18900" \
+	    "pr18900.out" \
+	] \
+	[list \
+	    "Run pr19031" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr19031.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr19031b.S pr19031c.c } \
+	    "pr19031" \
+	    "pr19031.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run gotpcrel1" \
+	    "-Wl,--no-as-needed tmpdir/gotpcrel1d.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
+	    "gotpcrel1" \
+	    "gotpcrel1.out" \
+	] \
+	[list \
+	    "Run property 1" \
+	    "" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-no-copy.S} \
+	    "property-1" "pass.out" \
+	] \
+	[list \
+	    "Run property 1 (PIE)" \
+	    "-pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-no-copy.S} \
+	    "property-1-pie" "pass.out" "-fPIE" \
+	] \
+	[list \
+	    "Run property 1 (static)" \
+	    "-static" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-no-copy.S} \
+	    "property-1-static" "pass.out" \
+	] \
+	[list \
+	    "Run property 2" \
+	    "" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-stack.S} \
+	    "property-2" "pass.out" \
+	] \
+	[list \
+	    "Run property 2 (PIE)" \
+	    "-pie" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-stack.S} \
+	    "property-2-pie" "pass.out" "-fPIE" \
+	] \
+	[list \
+	    "Run property 2 (static)" \
+	    "-static" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pass.c property-stack.S} \
+	    "property-3-static" "pass.out" \
+	] \
+	[list \
+	    "Run pr22001-1a (PIC 1)" \
+	    "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1b.c } \
+	    "pr22001-1a-pic-1" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr22001-1a (PIC 2)" \
+	    "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1b.c } \
+	    "pr22001-1a-pic-2" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr22001-1b (PIC 1)" \
+	    "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1c.c } \
+	    "pr22001-1b-pic-1" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr22001-1b (PIC 2)" \
+	    "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22001-1c.c } \
+	    "pr22001-1b-pic-2" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr21997-1a (PIC 1)" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21997-1b.c } \
+	    "pr21997-1a-pic-1" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr21997-1a (PIC 2)" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21997-1b.c } \
+	    "pr21997-1a-pic-2" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr21997-1b (PIC 1)" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21997-1c.c } \
+	    "pr21997-1b-pic-1" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr21997-1b (PIC 2)" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr21997-1c.c } \
+	    "pr21997-1b-pic-2" \
+	    "pass.out" \
+	    "-fPIC" \
+	] \
+	[list \
+	    "Run pr22064" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr22064a.o tmpdir/pr22064.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { dummy.s } \
+	    "pr22064-pie" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run pr22393-3" \
+	    "$NOPIE_LDFLAGS -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pr22393-3b.c} \
+	    "pr22393-3" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run pr22393-3 (PIE)" \
+	    "-pie -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a-now.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pr22393-3b.c} \
+	    "pr22393-3-pie" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run pr22393-3 (static)" \
+	    "-static -Wl,-z,separate-code,-z,max-page-size=0x1000" \
+	    "-Wa,-mx86-used-note=yes" \
+	    {pr22393-3a.c pr22393-3b.c} \
+	    "pr22393-3-static" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Run pr22791-2" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr22791-2.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22791-2c.s } \
+	    "pr22791-2" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run pr22842" \
+	    "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { pr22842b.S } \
+	    "pr22842" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Run pr23997" \
+	    "" \
+	    "" \
+	    { pr23997a.s pr23997b.c pr23997c.c } \
+	    "pr23997" \
+	    "pass.out" \
+	] \
+	[list \
+	    "Run protected-func-1 without PIE" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-func-1b.c } \
+	    "protected-func-1a" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run protected-func-1 with PIE" \
+	    "-Wl,--no-as-needed -pie tmpdir/libprotected-func-1.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-func-1b.c } \
+	    "protected-func-1b" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run protected-func-2a without PIE" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2a.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-func-2b.S } \
+	    "protected-func-2a" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run protected-func-2b with PIE" \
+	    "-Wl,--no-as-needed -pie tmpdir/libprotected-func-2a.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-func-2b.S } \
+	    "protected-func-2b" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run protected-func-2c without PIE" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2b.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-func-2b.S } \
+	    "protected-func-2c" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run protected-func-2d with PIE" \
+	    "-Wl,--no-as-needed -pie tmpdir/libprotected-func-2b.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-func-2b.S } \
+	    "protected-func-2d" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run protected-data-1a without PIE" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-data-1a.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-data-1b.c } \
+	    "protected-data-1a" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run protected-data-1b with PIE" \
+	    "-Wl,--no-as-needed -pie tmpdir/libprotected-data-1a.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-data-1b.c } \
+	    "protected-data-1b" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run protected-data-2a without PIE" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-data-2a.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-data-2b.S } \
+	    "protected-data-2a" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run protected-data-2b with PIE" \
+	    "-Wl,--no-as-needed -pie tmpdir/libprotected-data-2a.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-data-2b.S } \
+	    "protected-data-2b" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+	[list \
+	    "Run protected-data-2c without PIE" \
+	    "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-data-2b.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-data-2b.S } \
+	    "protected-data-2c" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run protected-data-2d with PIE" \
+	    "-Wl,--no-as-needed -pie tmpdir/libprotected-data-2b.so" \
+	    "-Wa,-mx86-used-note=yes" \
+	    { protected-data-2b.S } \
+	    "protected-data-2d" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+    ]
+
+    # Run-time tests which require working ifunc attribute support.
+    if { [check_ifunc_attribute_available] } {
+	run_cc_link_tests [list \
+	    [list \
+		"Build libpr19784a.so" \
+		"-shared -Wl,-Bsymbolic-functions" \
+		"-fPIC -O2 -g -Wa,-mx86-used-note=yes" \
+		{ pr19784b.c pr19784c.c } \
+		{} \
+		"libpr19784a.so" \
+	    ] \
+	    [list \
+		"Build libpr19784b.so" \
+		"-shared -Wl,-Bsymbolic-functions" \
+		"-fPIC -O2 -g -Wa,-mx86-used-note=yes" \
+		{ pr19784c.c pr19784b.c } \
+		{} \
+		"libpr19784b.so" \
+	    ] \
+	    [list \
+		"Build pr19784a.o" \
+		"" \
+		"-Wa,-mx86-used-note=yes" \
+		{ pr19784a.c } \
+	    ] \
+	]
+
+	run_ld_link_exec_tests [list \
+	    [list \
+		"Run pr19784a" \
+		"-Wl,--no-as-needed tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ dummy.s } \
+		"pr19784a" \
+		"pass.out" \
+	    ] \
+	    [list \
+		"Run pr19784b" \
+		"-Wl,--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ dummy.s } \
+		"pr19784b" \
+		"pass.out" \
+	    ] \
+	]
+    }
+
+    if { [istarget "x86_64-*-linux*"] \
+	 && ![istarget "x86_64-*-linux*-gnux32"]} {
+
+	run_cc_link_tests [list \
+	    [list \
+		"Build plt-main with -z bndplt" \
+		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -Wl,-z,bndplt \
+		 -Wl,-z,noseparate-code,-z,max-page-size=0x200000" \
+		"-Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
+		{ plt-main5.c } \
+		{{objdump {-drw} plt-main-bnd.dd}} \
+		"plt-main-bnd" \
+	    ] \
+	    [list \
+		"Build plt-main with PIE and -z bndplt" \
+		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie \
+		 -Wl,-z,bndplt,-z,noseparate-code \
+		 -Wl,-z,max-page-size=0x200000" \
+		"-fPIC -Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
+		{ plt-main5.c } \
+		{{objdump {-drw} plt-main-bnd.dd}} \
+		"plt-main-pie-bnd" \
+	    ] \
+	    [list \
+		"Build plt-main with -z bndplt -z now" \
+		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -Wl,-z,bndplt \
+		 -Wl,-z,now,-z,noseparate-code,-z,max-page-size=0x200000" \
+		"-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" \
+	    ] \
+	    [list \
+		"Build plt-main with PIE and -z bndplt -z now" \
+		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie \
+		 -Wl,-z,bndplt,-z,now,-z,noseparate-code \
+		 -Wl,-z,max-page-size=0x200000" \
+		"-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" \
+	    ] \
+	]
+
+	run_ld_link_exec_tests [list \
+	    [list \
+		"Run plt-main with -z bndplt" \
+		"-Wl,--no-as-needed,-z,bndplt tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-bnd" \
+		"plt-main.out" \
+	    ] \
+	    [list \
+		"Run plt-main with PIE and -z bndplt" \
+		"-Wl,--no-as-needed,-z,bndplt -pie tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-pie-bnd" \
+		"plt-main.out" \
+		"-fPIC" \
+	    ] \
+	    [list \
+		"Run plt-main with -z bndplt -z now" \
+		"-Wl,--no-as-needed,-z,bndplt,-z,now tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-bnd-now" \
+		"plt-main.out" \
+	    ] \
+	    [list \
+		"Run plt-main with PIE and -z bndplt -z now" \
+		"-Wl,--no-as-needed,-z,bndplt,-z,now -pie tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-pie-bnd-now" \
+		"plt-main.out" \
+		"-fPIC" \
+	    ] \
+	    [list \
+		"Run pr20800" \
+		"-Wl,-z,now -pie" \
+		"-Wa,-mx86-used-note=yes" \
+		{ pr20800a.S pr20800b.S } \
+		"pr20800" \
+		"pass.out" \
+	    ] \
+	]
+	if { [check_ifunc_attribute_available] } {
+	    run_ld_link_exec_tests [list \
+		[list \
+		    "Run pr21481a" \
+		    "$NOPIE_LDFLAGS -Wl,-z,bndplt" \
+		    "-Wa,-mx86-used-note=yes" \
+		    { pr21481a.c pr21481b.S } \
+		    "pr21481a" \
+		    "pass.out" \
+		     "$NOPIE_CFLAGS" \
+		] \
+		[list \
+		    "Run pr21481b" \
+		    "$NOPIE_LDFLAGS -Wl,-z,bndplt,-z,now" \
+		    "-Wa,-mx86-used-note=yes" \
+		    { pr21481a.c pr21481b.S } \
+		    "pr21481b" \
+		    "pass.out" \
+		    "$NOPIE_CFLAGS" \
+		] \
+	    ]
+	}
+    }
+
+    if { [istarget "x86_64-*-linux*"] } {
+	if { [istarget "x86_64-*-linux*-gnux32"] } {
+	    set pltdump {{objdump {-drw} plt-main-ibt-x32.dd}}
+	    set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt-x32.dd}}
+	} else {
+	    set pltdump {{objdump {-drw} plt-main-ibt.dd}}
+	    set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt.dd}}
+	}
+	run_cc_link_tests [list \
+	    [list \
+		"Build plt-main with -z ibtplt" \
+		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -Wl,-z,ibtplt \
+		 -Wl,-z,noseparate-code,-z,max-page-size=0x200000" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		$pltdump \
+		"plt-main-ibt" \
+	    ] \
+	    [list \
+		"Build plt-main with PIE and -z ibtplt" \
+		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie \
+		 -Wl,-z,ibtplt,-z,noseparate-code \
+		 -Wl,-z,max-page-size=0x200000" \
+		"-fPIC -Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		$pltdump \
+		"plt-main-pie-ibt" \
+	    ] \
+	    [list \
+		"Build plt-main with -z ibtplt -z now" \
+		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -Wl,-z,ibtplt \
+		 -Wl,-z,now,-z,noseparate-code,-z,max-page-size=0x200000" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		$pltsecdump \
+		"plt-main-ibt-now" \
+	    ] \
+	    [list \
+		"Build plt-main with PIE and -z ibtplt -z now" \
+		"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie \
+		 -Wl,-z,ibtplt,-z,now,-z,noseparate-code \
+		 -Wl,-z,max-page-size=0x200000" \
+		"-fPIC -Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		$pltsecdump \
+		"plt-main-pie-ibt-now" \
+	    ] \
+	    [list \
+		"Build libibtplt-lib.so with -z ibtplt" \
+		"-shared -Wl,-z,ibtplt,-z,noseparate-code \
+		 -Wl,-z,max-page-size=0x200000" \
+		"-fPIC -Wa,-mx86-used-note=yes" \
+		{ plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
+		$pltdump \
+		"libibtplt-lib.so" \
+	    ] \
+	    [list \
+		"Build libibtplt--now-lib.so with -z ibtplt -z now" \
+		"-shared -Wl,-z,ibtplt,-z,now,-z,noseparate-code \
+		 -Wl,-z,max-page-size=0x200000" \
+		"-fPIC -Wa,-mx86-used-note=yes" \
+		{ plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
+		$pltdump \
+		"libibtplt-now-lib.so" \
+	    ] \
+	]
+
+	run_ld_link_exec_tests [list \
+	    [list \
+		"Run plt-main with -z ibtplt" \
+		"-Wl,--no-as-needed,-z,ibtplt tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-ibt" \
+		"plt-main.out" \
+	    ] \
+	    [list \
+		"Run plt-main with PIE and -z ibtplt" \
+		"-Wl,--no-as-needed,-z,ibtplt -pie tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-pie-ibt" \
+		"plt-main.out" \
+		"-fPIC" \
+	    ] \
+	    [list \
+		"Run plt-main with -z ibtplt -z now" \
+		"-Wl,--no-as-needed,-z,ibtplt,-z,now tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-ibt-now" \
+		"plt-main.out" \
+	    ] \
+	    [list \
+		"Run plt-main with PIE and -z ibtplt -z now" \
+		"-Wl,--no-as-needed,-z,ibtplt,-z,now -pie tmpdir/plt-main1.o \
+		 tmpdir/plt-main2.o tmpdir/plt-main3.o \
+		 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-pie-ibt-now" \
+		"plt-main.out" \
+		"-fPIC" \
+	    ] \
+	    [list \
+		"Run plt-main with libibtplt-lib.so -z ibtplt" \
+		"-Wl,--no-as-needed,-z,ibtplt tmpdir/libibtplt-lib.so \
+		 tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-ibt-lib" \
+		"plt-main.out" \
+	    ] \
+	    [list \
+		"Run plt-main with libibtplt-lib.so -z ibtplt -z now" \
+		"-Wl,--no-as-needed,-z,ibtplt,-z,now \
+		 tmpdir/libibtplt-now-lib.so tmpdir/libplt-lib.so" \
+		"-Wa,-mx86-used-note=yes" \
+		{ plt-main5.c } \
+		"plt-main-ibt-now-lib" \
+		"plt-main.out" \
+	    ] \
+	]
+
+	if { [check_ifunc_attribute_available] } {
+	    run_ld_link_exec_tests [list \
+		[list \
+		    "Run pr21481a" \
+		    "$NOPIE_LDFLAGS -Wl,-z,ibtplt" \
+		    "-Wa,-mx86-used-note=yes" \
+		    { pr21481a.c pr21481b.S } \
+		    "pr21481a" \
+		    "pass.out" \
+		     "$NOPIE_CFLAGS" \
+		] \
+		[list \
+		    "Run pr21481b" \
+		    "$NOPIE_LDFLAGS -Wl,-z,ibtplt,-z,now" \
+		    "-Wa,-mx86-used-note=yes" \
+		    { pr21481a.c pr21481b.S } \
+		    "pr21481b" \
+		    "pass.out" \
+		    "$NOPIE_CFLAGS" \
+		] \
+	    ]
+	}
+    }
+
+    undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
+    undefined_weak "-fPIE" ""
+    undefined_weak "-fPIE" "-pie"
+    undefined_weak "-fPIE" "-Wl,-z,nodynamic-undefined-weak"
+    undefined_weak "-fPIE" "-pie -Wl,-z,nodynamic-undefined-weak"
+}
+
+if { ![istarget "x86_64-*-linux*"]} {
+    set ASFLAGS "$saved_ASFLAGS"
+    return
+}
+
+run_ld_link_tests [list \
+    [list \
+	"basic PLT generation (-z now)" \
+	"-z now -melf_x86_64 --hash-style=sysv tmpdir/libpltlib.so \
+	 -z noseparate-code -z max-page-size=0x200000" \
+	"" \
+	"--64" \
+	{plt2.s} \
+	{{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
+	"plt2" \
+    ] \
+    [list \
+	"Build pr21626.so" \
+	"-shared -melf_x86_64" \
+	"" \
+	"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
+	{property-x86-3.s} \
+	"" \
+	"pr21626.so" \
+    ] \
+    [list \
+	"Build pr21626" \
+	"-melf_x86_64 tmpdir/pr21626.so" \
+	"" \
+	"--64 -mx86-used-note=yes" \
+	{start.s foo.s} \
+	"" \
+	"pr21626" \
+    ] \
+]
+
+# Linux only tests
+if { "$LD_CLASS" == "64bit" } then {
+    # This test needs 64-bit linker.
+    run_dump_test "pr17618"
+}
+run_dump_test "pltgot-1"
+run_dump_test "pltgot-2"
+run_dump_test "pr20830a"
+run_dump_test "pr20830b"
+run_dump_test "pr21038a"
+run_dump_test "pr21038b"
+run_dump_test "pr21038c"
+run_dump_test "pr20830a-now"
+run_dump_test "pr20830b-now"
+run_dump_test "pr21038a-now"
+run_dump_test "pr21038b-now"
+run_dump_test "pr21038c-now"
+run_dump_test "ibt-plt-1"
+run_dump_test "ibt-plt-1-x32"
+run_dump_test "ibt-plt-2a"
+run_dump_test "ibt-plt-2b"
+run_dump_test "ibt-plt-2c"
+run_dump_test "ibt-plt-2d"
+run_dump_test "ibt-plt-2a-x32"
+run_dump_test "ibt-plt-2b-x32"
+run_dump_test "ibt-plt-2c-x32"
+run_dump_test "ibt-plt-2d-x32"
+run_dump_test "ibt-plt-3a"
+run_dump_test "ibt-plt-3b"
+run_dump_test "ibt-plt-3c"
+run_dump_test "ibt-plt-3d"
+run_dump_test "ibt-plt-3a-x32"
+run_dump_test "ibt-plt-3b-x32"
+run_dump_test "ibt-plt-3c-x32"
+run_dump_test "ibt-plt-3d-x32"
+
+set ASFLAGS "$saved_ASFLAGS"