Disallow copy relocation against protected data symbol
[deliverable/binutils-gdb.git] / ld / testsuite / ld-i386 / i386.exp
index 3c5de021b2b576b81d0011798aa3ca47029c18ff..bd1561024c5c6976cff35f5a6752bffa25a83273 100644 (file)
@@ -468,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"
@@ -1245,6 +1245,25 @@ if { [isnative]
 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" \
@@ -1255,7 +1274,94 @@ if { [isnative]
            "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 \
This page took 0.025232 seconds and 4 git commands to generate.