Disallow copy relocation against protected data symbol
[deliverable/binutils-gdb.git] / ld / testsuite / ld-i386 / i386.exp
index d30dc767036978f1c0e22e622425d8e85cfda355..bd1561024c5c6976cff35f5a6752bffa25a83273 100644 (file)
 
 if {[istarget "i?86-*-vxworks"]} {
     set i386tests {
-       {"VxWorks shared library test 1" "-shared -Tvxworks1.ld" ""
+       {"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 -q --force-dynamic" ""
+        "tmpdir/libvxworks1.so -Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
         "" {vxworks1.s}
         {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
         "vxworks1"}
        {"VxWorks executable test 2 (dynamic)" \
-        "-Tvxworks1.ld -q --force-dynamic" ""
+        "-Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
         "" {vxworks2.s}
         {{readelf --segments vxworks2.sd}}
         "vxworks2"}
        {"VxWorks executable test 2 (static)"
-        "-Tvxworks1.ld" ""
+        "-Tvxworks1.ld --hash-style=sysv" ""
         "" {vxworks2.s}
         {{readelf --segments vxworks2-static.sd}}
         "vxworks2"}
@@ -128,20 +129,20 @@ set i386tests {
      "-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" ""
+     "-shared -melf_i386 --no-ld-generated-unwind-info --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" ""
+     "-shared -melf_i386 --no-ld-generated-unwind-info --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" ""
+     "-shared -melf_i386 --no-ld-generated-unwind-info --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}}
@@ -149,31 +150,31 @@ set i386tests {
     {"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" ""
+     "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info --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" ""
+     "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info --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" ""
+     "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info --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 -fno-pic -shared"
-     "-shared -melf_i386 --no-ld-generated-unwind-info" ""
+     "-shared -melf_i386 --no-ld-generated-unwind-info --hash-style=sysv" ""
      "--32" {tlsnopic1.s tlsnopic2.s}
      {{readelf -Ssrl tlsnopic.rd} {objdump -drj.text tlsnopic.dd}
       {objdump -sj.got tlsnopic.sd}} "libtlsnopic.so"}
     {"TLS with global dynamic and descriptors"
-     "-shared -melf_i386 --no-ld-generated-unwind-info" ""
+     "-shared -melf_i386 --no-ld-generated-unwind-info --hash-style=sysv" ""
      "--32" {tlsgdesc.s}
      {{readelf -Ssrl tlsgdesc.rd} {objdump -drj.text tlsgdesc.dd}}
       "libtlsgdesc.so"}
@@ -307,6 +308,7 @@ 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"
@@ -427,6 +429,17 @@ 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 "pie1"
+run_dump_test "pie1-nacl"
+run_dump_test "pr21884"
+run_dump_test "pr21884-nacl"
 
 if { !([istarget "i?86-*-linux*"]
        || [istarget "i?86-*-gnu*"]
@@ -455,8 +468,8 @@ proc undefined_weak {cflags ldflags} {
        set testname "$testname ($cflags $ldflags)"
     }
 
-    if { [ regexp "\-fPIE" $cflags]
-        && ![ regexp "\-z nodynamic-undefined-weak" $ldflags] } {
+    if { [string match "*-fPIE*" $cflags]
+        && ![string match "*-z nodynamic-undefined-weak*" $ldflags] } {
        set weak_symbol "Weak defined"
     } else {
        set weak_symbol "Weak undefined"
@@ -725,7 +738,7 @@ if { [isnative]
        ] \
        [list \
            "Build gotpc1" \
-           "-Wl,--as-needed tmpdir/gotpc1.o tmpdir/got1d.so" \
+           "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/gotpc1.o tmpdir/got1d.so" \
            "" \
            { dummy.s } \
            {{objdump {-dw} got1.dd}} \
@@ -979,15 +992,16 @@ if { [isnative]
        ] \
        [list \
            "Run pr19031" \
-           "tmpdir/pr19031.so" \
+           "$NOPIE_LDFLAGS tmpdir/pr19031.so" \
            "" \
            { pr19031b.S pr19031c.c } \
            "pr19031" \
            "pr19031.out" \
+           "$NOPIE_CFLAGS" \
        ] \
        [list \
            "Run got1" \
-           "tmpdir/got1d.so" \
+           "$NOPIE_LDFLAGS tmpdir/got1d.so" \
            "" \
            { got1a.S got1b.c got1c.c } \
            "got1" \
@@ -1100,14 +1114,14 @@ if { [isnative]
        ] \
     ]
 
-    undefined_weak "" ""
-    undefined_weak "-fPIE" ""
+    undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
+    undefined_weak "-fPIE" "$NOPIE_LDFLAGS"
     undefined_weak "-fPIE" "-pie"
-    undefined_weak "-fPIE" "-z nodynamic-undefined-weak"
+    undefined_weak "-fPIE" "-z nodynamic-undefined-weak $NOPIE_LDFLAGS"
     undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
 }
 
-global NOPIE_LDFLAGS
+global NOPIE_CFLAGS NOPIE_LDFLAGS
 
 # Must be native with the C compiler and working IFUNC support,
 if { [isnative]
@@ -1227,6 +1241,142 @@ if { [isnative]
     }
 }
 
+# Must be native with the C compiler.
+if { [isnative]
+     && [istarget "i?86-*-*"]
+     && [which $CC] != 0 } {
+    run_cc_link_tests [list \
+       [list \
+           "Build pr22001-1.so" \
+           "-shared" \
+           "" \
+           { pr22001-1a.c } \
+           {} \
+           "pr22001-1.so" \
+       ] \
+       [list \
+           "Build pr21997-1.so" \
+           "-shared" \
+           "" \
+           { property-stack.S property-no-copy.S pr21997-1a.S } \
+           {} \
+           "pr21997-1.so" \
+       ] \
+    ]
+
+    run_ld_link_exec_tests [list \
+       [list \
+           "Run weakundef1 without PIE" \
+           "$NOPIE_LDFLAGS" \
+           "" \
+           { weakundef1.c } \
+           "weakundef1pie" \
+           "pass.out" \
+           "$NOPIE_CFLAGS" \
+       ] \
+       [list \
+           "Run pr22001-1" \
+           "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+           "" \
+           { 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" \
+           "" \
+           { 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" \
+           "" \
+           { 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" \
+           "" \
+           { 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" \
+           "" \
+           { pr22001-1b.c } \
+           "pr22001-1-pic-2" \
+           "pass.out" \
+           "-fPIC" \
+       ] \
+       [list \
+           "Run pr21997-1" \
+           "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+           "" \
+           { 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" \
+           "" \
+           { 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" \
+           "" \
+           { 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" \
+           "" \
+           { pr21997-1c.S } \
+           "pr21997-1-pie-1" \
+           "pass.out" \
+       ] \
+       [list \
+           "Run pr21997-1 (PIE 2)" \
+           "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+           "" \
+           { pr21997-1c.S } \
+           "pr21997-1-pie-2" \
+           "pass.out" \
+       ] \
+    ]
+
+    if { [at_least_gcc_version 5 0] } {
+       run_ld_link_exec_tests [list \
+           [list \
+               "Run weakundef1 with PIE" \
+               "-pie" \
+               "" \
+               { weakundef1.c } \
+               "weakundef1pie" \
+               "pass.out" \
+               "-fPIE" \
+           ] \
+       ]
+    }
+}
+
 if { !([istarget "i?86-*-linux*"]
        || [istarget "x86_64-*-linux*"]) } {
     return
@@ -1235,7 +1385,7 @@ if { !([istarget "i?86-*-linux*"]
 run_ld_link_tests [list \
     [list \
        "basic PLT generation (non-PIC, -z now)" \
-       "-z now -melf_i386 tmpdir/libpltlib.so" \
+       "-z now -melf_i386 --hash-style=sysv tmpdir/libpltlib.so" \
        "" \
        "--32" \
        {plt2.s} \
This page took 0.026979 seconds and 4 git commands to generate.