]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - ld/testsuite/ld-elf/shared.exp
elf: Add GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-elf / shared.exp
index 014937175fc9985574016ff6cdeec8ce08ed9bb5..d00358e47ef595b9cdf6f87b2613f29fedbf3b99 100644 (file)
@@ -1,5 +1,5 @@
 # Expect script for various ELF tests.
-#   Copyright (C) 2006-2020 Free Software Foundation, Inc.
+#   Copyright (C) 2006-2021 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -71,7 +71,7 @@ if { [istarget "mips*vr4100*-*-elf*"] \
 }
 
 if [is_underscore_target] {
-    set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1"
+    append ASFLAGS " --defsym UNDERSCORE=1"
 }
 
 run_ld_link_tests [list \
@@ -93,15 +93,6 @@ run_ld_link_tests [list \
        {} \
        "pr22471b.so" \
     ] \
-    [list \
-       "Build pr22471" \
-       "$LFLAGS -rpath-link ." \
-       "tmpdir/pr22471b.so" \
-       "" \
-       {pr22471b.s} \
-       {} \
-       "pr22471" \
-    ] \
     [list \
        "Build pr22649-1.so" \
        "$LFLAGS -shared" \
@@ -113,6 +104,18 @@ run_ld_link_tests [list \
     ] \
 ]
 
+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}}
@@ -177,7 +180,7 @@ run_ld_link_tests [list \
          {readelf {-d --wide} textrel.rd}} \
        "textrel.so" \
     ] \
-] "xtensa-*-*"
+] 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
@@ -194,7 +197,7 @@ run_ld_link_tests [list \
         {{ld textrel.map}} \
        "textrel.so" \
     ] \
-] "cris*-*-*" "mips*-*-*"
+] bfin-*-* cris*-*-* frv-*-* lm32-*-* mips*-*-*
 
 # PR ld/20828 check for correct dynamic symbol table entries where:
 # - symbols have been defined with a linker script,
@@ -464,6 +467,8 @@ run_ld_link_tests [list \
 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" \
@@ -613,6 +618,10 @@ set build_tests {
   {"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"}
@@ -749,15 +758,6 @@ set build_tests {
   {"Build needed3"
    "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" ""
    {dummy.c} {} "needed3"}
-  {"Build libpr2404a.so"
-   "-shared" "-fPIC"
-   {pr2404a.c} {} "libpr2404a.so"}
-  {"Build libpr2404n.so"
-   "-shared -Wl,-z,now" "-fPIC"
-   {pr2404a.c} {} "libpr2404n.so"}
-  {"Build libpr2404b.a"
-   "" ""
-   {pr2404b.c} {} "libpr2404b.a"}
   {"Build rdynamic-1"
    "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections"
    {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
@@ -792,6 +792,84 @@ set build_tests {
    "-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" \
+    ] \
+]
+
 # pr19073.s uses .set, which has a different meaning on alpha.
 if { ![istarget alpha-*-*] } {
     append build_tests {
@@ -822,6 +900,9 @@ append build_tests {
   {"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
@@ -856,7 +937,8 @@ run_cc_link_tests [list \
        "-shared -Wl,--no-as-needed tmpdir/pr26302a.so" \
        "-fPIC" \
        {pr26302b.c} \
-       {{nm {-u} pr26302.nd} \
+       {{readelf {-sW} pr26302.rd} \
+        {nm {-u} pr26302.nd} \
         {nm {-u -D} pr26302.nd} \
         {nm {-u -D --with-symbol-versions} pr26302.nd}} \
        "pr26302b.so" \
@@ -872,7 +954,7 @@ run_ld_link_tests [list \
        { pr22269-1.c } \
        {{readelf -rW pr22269-1.rd}} \
        "pr22269-1" \
-       "-fPIE -O2" \
+       "-fPIE -O2 $NOSANITIZE_CFLAGS" \
     ] \
 ]
 
@@ -950,6 +1032,9 @@ set run_tests [list \
     [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"] \
@@ -1005,11 +1090,16 @@ set run_tests [list \
      "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
      {relmain.c} "relmain" "relmain.out" ] \
     [list "Run pr2404" \
-     "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \
-     {dummy.c} "pr2404" "pr2404.out" ] \
+     "$NOSANITIZE_CFLAGS -Wl,--no-as-needed \
+      tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
+     "" \
+     {dummy.c} "pr2404" "pr2404.out" \
+     "$NOSANITIZE_CFLAGS" ] \
     [list "Run pr2404n" \
-     "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \
-     {dummy.c} "pr2404n" "pr2404.out" ] \
+     "$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" ] \
@@ -1019,6 +1109,18 @@ set run_tests [list \
     [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.
@@ -1077,7 +1179,11 @@ set dlopen_run_tests [list \
 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"
+  append CFLAGS " $NOSANITIZE_CFLAGS"
   run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*"
+  set CFLAGS "$old_CFLAGS"
 }
 
 # Check --no-add-needed and --no-copy-dt-needed-entries
@@ -1125,14 +1231,29 @@ set build_cxx_tests {
   {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
    "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
    {dl3.cc} {} "libdl3c.so" "c++"}
-  {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new"
-   "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC -ansi"
-   {del.cc new.cc} {} "libnew1a.so" "c++"}
-  {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new"
-   "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi"
-   {del.cc new.cc} {} "libnew1b.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" ""
@@ -1144,14 +1265,31 @@ set run_cxx_tests {
     {"Run with libdl3c.so"
      "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
      {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
-    {"Run with libnew1a.so"
-     "-Wl,--no-as-needed tmpdir/libnew1a.so" ""
-     {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"}
-    {"Run with libnew1b.so"
-     "-Wl,--no-as-needed tmpdir/libnew1b.so" ""
-     {dl5.cc} "dl5b" "dl5.out" "-ansi" "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
 
@@ -1162,7 +1300,7 @@ if { [istarget *-*-linux*]
        [list \
            "Build libpr2404b.a with PIE" \
            "" \
-           "-fPIE" \
+           "-fPIE $NOSANITIZE_CFLAGS" \
            { pr2404b.c } \
            {} \
            "libpr2404b.a" \
@@ -1248,21 +1386,21 @@ if { [istarget *-*-linux*]
        ] \
        [list \
            "Run pr2404 with PIE" \
-           "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
+           "-pie $NOSANITIZE_CFLAGS -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
            "" \
            { dummy.c } \
            "pr2404pie" \
            "pr2404.out" \
-           "-fPIE" \
+           "-fPIE $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Run pr2404 with PIE (-z now)" \
-           "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
+           "-pie $NOSANITIZE_CFLAGS -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
            "" \
            { dummy.c } \
            "pr2404pien" \
            "pr2404.out" \
-           "-fPIE" \
+           "-fPIE $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Run pr18718" \
@@ -1484,6 +1622,9 @@ 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*"]
@@ -1498,7 +1639,7 @@ if { ([istarget "*-*-linux*"]
            { pr23162a.c } \
            "" \
            "libpr23162a.so" \
-           "-fPIC -O2" \
+           "-fPIC -O2 $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Build pr23162a" \
@@ -1508,7 +1649,7 @@ if { ([istarget "*-*-linux*"]
            { pr23162b.c } \
            {{readelf {-rW} pr23162.rd}} \
            "pr23162a" \
-           "-fPIC -O0" \
+           "-fPIC -O0 $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Build libpr23162b.so" \
@@ -1518,7 +1659,7 @@ if { ([istarget "*-*-linux*"]
            { pr23162a.c } \
            "" \
            "libpr23162b.so" \
-           "-fPIC -O2" \
+           "-fPIC -O2 $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Build pr23162b" \
@@ -1528,7 +1669,7 @@ if { ([istarget "*-*-linux*"]
            { pr23162b.c } \
            {{readelf {-rW} pr23162.rd}} \
            "pr23162b" \
-           "-fPIC -O0" \
+           "-fPIC -O0 $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Build libpr23161a.so" \
@@ -1538,7 +1679,7 @@ if { ([istarget "*-*-linux*"]
            { pr23161a.c } \
            {{readelf {--dyn-syms -rW} pr23161a.rd}} \
            "libpr23161a.so" \
-           "-fPIC -O2 $NOSANTIZE_CFLAGS" \
+           "-fPIC -O2 $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Build pr23161a" \
@@ -1548,7 +1689,7 @@ if { ([istarget "*-*-linux*"]
            { pr23161b.c } \
            {{readelf {--dyn-syms -rW} pr23161b.rd}} \
            "pr23161a" \
-           "-fPIC -O0 $NOSANTIZE_CFLAGS" \
+           "-fPIC -O0 $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Build libpr23161b.so" \
@@ -1558,7 +1699,7 @@ if { ([istarget "*-*-linux*"]
            { pr23161a.c } \
            {{readelf {--dyn-syms -rW} pr23161a.rd}} \
            "libpr23161b.so" \
-           "-fPIC -O2 $NOSANTIZE_CFLAGS" \
+           "-fPIC -O2 $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Build pr23161b" \
@@ -1568,7 +1709,7 @@ if { ([istarget "*-*-linux*"]
            { pr23161b.c } \
            {{readelf {--dyn-syms -rW} pr23161b.rd}} \
            "pr23161b" \
-           "-fPIC -O0 $NOSANTIZE_CFLAGS" \
+           "-fPIC -O0 $NOSANITIZE_CFLAGS" \
        ] \
     ]
 }
@@ -1584,7 +1725,7 @@ if { [istarget "i?86-*-*"]
            { pr23161c.c } \
            {{readelf {--dyn-syms -rW} pr23161c.rd}} \
            "libpr23161c.so" \
-           "-fPIC -O2 $NOSANTIZE_CFLAGS" \
+           "-fPIC -O2 $NOSANITIZE_CFLAGS" \
        ] \
        [list \
            "Build pr23161c" \
@@ -1594,7 +1735,7 @@ if { [istarget "i?86-*-*"]
            { pr23161b.c } \
            {{readelf {--dyn-syms -rW} pr23161d.rd}} \
            "pr23161c" \
-           "-fPIC -O0 $NOSANTIZE_CFLAGS" \
+           "-fPIC -O0 $NOSANITIZE_CFLAGS" \
        ] \
     ]
 }