aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-x86-64
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite/ld-x86-64')
-rw-r--r--ld/testsuite/ld-x86-64/pr21997-1a.S24
-rw-r--r--ld/testsuite/ld-x86-64/pr21997-1a.err2
-rw-r--r--ld/testsuite/ld-x86-64/pr21997-1b.c13
-rw-r--r--ld/testsuite/ld-x86-64/pr21997-1b.err2
-rw-r--r--ld/testsuite/ld-x86-64/pr21997-1c.c13
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp69
6 files changed, 123 insertions, 0 deletions
diff --git a/ld/testsuite/ld-x86-64/pr21997-1a.S b/ld/testsuite/ld-x86-64/pr21997-1a.S
new file mode 100644
index 0000000..cab99a9
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr21997-1a.S
@@ -0,0 +1,24 @@
+ .text
+ .p2align 4,,15
+ .globl get_protected
+ .type get_protected, @function
+get_protected:
+ movl protected(%rip), %eax
+ ret
+ .size get_protected, .-get_protected
+ .p2align 4,,15
+ .globl get_protected_p
+ .type get_protected_p, @function
+get_protected_p:
+ leaq protected(%rip), %rax
+ ret
+ .size get_protected_p, .-get_protected_p
+ .protected protected
+ .globl protected
+ .data
+ .align 4
+ .type protected, @object
+ .size protected, 4
+protected:
+ .long 1
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/pr21997-1a.err b/ld/testsuite/ld-x86-64/pr21997-1a.err
new file mode 100644
index 0000000..5d663a3
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr21997-1a.err
@@ -0,0 +1,2 @@
+.*relocation R_X86_64_PC32 against protected symbol `protected' can not be used when making a P(D|I)E object; recompile with -fPIC
+#...
diff --git a/ld/testsuite/ld-x86-64/pr21997-1b.c b/ld/testsuite/ld-x86-64/pr21997-1b.c
new file mode 100644
index 0000000..ffed117
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr21997-1b.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+extern int protected;
+extern int get_protected (void);
+
+int
+main ()
+{
+ if (protected == get_protected ())
+ printf ("PASS\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-x86-64/pr21997-1b.err b/ld/testsuite/ld-x86-64/pr21997-1b.err
new file mode 100644
index 0000000..365de67
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr21997-1b.err
@@ -0,0 +1,2 @@
+.*relocation R_X86_64_32S against protected symbol `protected' can not be used when making a P(D|I)E object; recompile with -fPIC
+#...
diff --git a/ld/testsuite/ld-x86-64/pr21997-1c.c b/ld/testsuite/ld-x86-64/pr21997-1c.c
new file mode 100644
index 0000000..6d7b9dc
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr21997-1c.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+extern int protected;
+extern int* get_protected_p (void);
+
+int
+main ()
+{
+ if (&protected == get_protected_p ())
+ printf ("PASS\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 45e93b2..0e018c5 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -1056,6 +1056,22 @@ if { [isnative] && [which $CC] != 0 } {
{{error_output "pr22001-1a.err"}} \
"pr22001-1a" \
] \
+ [list \
+ "Build pr21997-1.so" \
+ "-shared" \
+ "" \
+ { property-stack.S property-no-copy.S pr21997-1a.S } \
+ {} \
+ "pr21997-1.so" \
+ ] \
+ [list \
+ "Build pr21997-1a" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "$NOPIE_CFLAGS" \
+ { pr21997-1b.c } \
+ {{error_output "pr21997-1a.err"}} \
+ "pr21997-1a" \
+ ] \
]
if {[istarget "x86_64-*-linux*-gnux32"]} {
@@ -1069,6 +1085,15 @@ if { [isnative] && [which $CC] != 0 } {
"pass.out" \
"$NOPIE_CFLAGS" \
] \
+ [list \
+ "Run pr21997-1b" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "" \
+ { pr21997-1c.c } \
+ "pr21997-1b" \
+ "pass.out" \
+ "$NOPIE_CFLAGS" \
+ ] \
]
} else {
run_cc_link_tests [list \
@@ -1080,6 +1105,14 @@ if { [isnative] && [which $CC] != 0 } {
{{error_output "pr22001-1b.err"}} \
"pr22001-1b" \
] \
+ [list \
+ "Build pr21997-1b" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "$NOPIE_CFLAGS" \
+ { pr21997-1c.c } \
+ {{error_output "pr21997-1b.err"}} \
+ "pr21997-1b" \
+ ] \
]
}
@@ -1293,6 +1326,42 @@ if { [isnative] && [which $CC] != 0 } {
"pass.out" \
"-fPIC" \
] \
+ [list \
+ "Run pr21997-1a (PIC 1)" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "" \
+ { 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" \
+ "" \
+ { 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" \
+ "" \
+ { 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" \
+ "" \
+ { pr21997-1c.c } \
+ "pr21997-1b-pic-2" \
+ "pass.out" \
+ "-fPIC" \
+ ] \
]
# Run-time tests which require working ifunc attribute support.