Pass $NOPIE_CFLAGS to NOCROSSREFS tests
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / shared.exp
index 3b8ab181d1f98144f3493440a34c06ff20aa04e1..7c4e0a2b39bc3b4b194d2cb488c941adee8ae577 100644 (file)
@@ -50,6 +50,8 @@ if [istarget "tic6x-*-*"] {
 # - 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 \
@@ -77,7 +79,92 @@ if { [check_gc_sections_available] } {
            {pr20828.s} \
            {{readelf --dyn-syms pr20828-b.sd} \
             {readelf --dyn-syms pr20828-c.sd}} \
-           "pr20828-2.so"]]
+           "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"]]
+
+    setup_kfail "cris*-*-*" "ld/21233"
+
+    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"]]
+
+    setup_kfail "cris*-*-*" "ld/21233"
+
+    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"]]
+
+    setup_kfail "cris*-*-*" "ld/21233"
+
+    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"]]
 }
 
 # Check to see if the C compiler works
@@ -288,14 +375,17 @@ set build_tests {
   {"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"
-   "-rdynamic -Wl,--gc-sections" "-ffunction-sections"
+   "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections"
    {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
   {"Build dynamic-1"
-   "-Wl,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections"
+   "-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"
@@ -441,6 +531,9 @@ set run_tests [list \
     [list "Run pr2404" \
      "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \
      {dummy.c} "pr2404" "pr2404.out" ] \
+    [list "Run pr2404n" \
+     "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \
+     {dummy.c} "pr2404n" "pr2404.out" ] \
     [list "Run pr18458" \
      "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
      {pr18458c.c} "pr18458" "pass.out" ] \
@@ -545,10 +638,10 @@ set build_cxx_tests {
    "-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"
+   "-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"
+   "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi"
    {del.cc new.cc} {} "libnew1b.so" "c++"}
 }
 
@@ -565,10 +658,10 @@ set run_cxx_tests {
      {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
     {"Run with libnew1a.so"
      "-Wl,--no-as-needed tmpdir/libnew1a.so" ""
-     {dl5.cc} "dl5a" "dl5.out" "" "c++"}
+     {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"}
     {"Run with libnew1b.so"
      "-Wl,--no-as-needed tmpdir/libnew1b.so" ""
-     {dl5.cc} "dl5b" "dl5.out" "" "c++"}
+     {dl5.cc} "dl5b" "dl5.out" "-ansi" "c++"}
 }
 
 run_cc_link_tests $build_cxx_tests
@@ -601,8 +694,25 @@ if { [istarget *-*-linux*]
            {} \
            "libpr19579.so" \
        ] \
+       [list \
+           "Build libpr19579now.so" \
+           "-shared -Wl,-z,now" \
+           "-fPIC" \
+           {pr19579b.c} \
+           {} \
+           "libpr19579.so" \
+       ] \
     ]
     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 -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
@@ -612,6 +722,15 @@ if { [istarget *-*-linux*]
            "pr2404.out" \
            "-fPIE" \
        ] \
+       [list \
+           "Run pr2404 with PIE (-z now)" \
+           "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
+           "" \
+           { dummy.c } \
+           "pr2404pien" \
+           "pr2404.out" \
+           "-fPIE" \
+       ] \
        [list \
            "Run pr18718" \
            "" \
@@ -621,6 +740,15 @@ if { [istarget *-*-linux*]
            "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" \
@@ -639,6 +767,24 @@ if { [istarget *-*-linux*]
            "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)" \
            "" \
@@ -657,6 +803,24 @@ if { [istarget *-*-linux*]
            "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" \
@@ -666,6 +830,15 @@ if { [istarget *-*-linux*]
            "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" \
+       ] \
     ]
 }
 
This page took 0.029369 seconds and 4 git commands to generate.