aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog14
-rw-r--r--ld/testsuite/ld-i386/i386.exp51
-rw-r--r--ld/testsuite/ld-i386/pr21997-1a.S35
-rw-r--r--ld/testsuite/ld-i386/pr21997-1b.c16
-rw-r--r--ld/testsuite/ld-i386/pr21997-1c.S51
-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
11 files changed, 290 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 5efcbd3..06b8c25 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,17 @@
+2017-08-26 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/21997
+ * testsuite/ld-i386/i386.exp: Run PR ld/21997 tests.
+ * testsuite/ld-x86-64/x86-64.exp: Likewise.
+ * testsuite/ld-i386/pr21997-1a.S: New file.
+ * testsuite/ld-i386/pr21997-1b.c: Likewise.
+ * testsuite/ld-i386/pr21997-1c.S: Likewise.
+ * testsuite/ld-x86-64/pr21997-1a.S: Likewise.
+ * testsuite/ld-x86-64/pr21997-1a.err: Likewise.
+ * testsuite/ld-x86-64/pr21997-1b.c: Likewise.
+ * testsuite/ld-x86-64/pr21997-1b.err: Likewise.
+ * testsuite/ld-x86-64/pr21997-1c.c: Likewise.
+
2017-08-24 H.J. Lu <hongjiu.lu@intel.com>
* testsuite/ld-elf/pr21903c.d: Remove '\' before --.
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index c813a80..bd15610 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -1254,6 +1254,14 @@ if { [isnative]
{} \
"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 \
@@ -1309,6 +1317,49 @@ if { [isnative]
"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] } {
diff --git a/ld/testsuite/ld-i386/pr21997-1a.S b/ld/testsuite/ld-i386/pr21997-1a.S
new file mode 100644
index 0000000..aea17f8
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr21997-1a.S
@@ -0,0 +1,35 @@
+ .text
+ .p2align 4,,15
+ .globl get_protected
+ .type get_protected, @function
+get_protected:
+ call __x86.get_pc_thunk.ax
+ addl $_GLOBAL_OFFSET_TABLE_, %eax
+ movl protected@GOTOFF(%eax), %eax
+ ret
+ .size get_protected, .-get_protected
+ .p2align 4,,15
+ .globl get_protected_p
+ .type get_protected_p, @function
+get_protected_p:
+ call __x86.get_pc_thunk.ax
+ addl $_GLOBAL_OFFSET_TABLE_, %eax
+ leal protected@GOTOFF(%eax), %eax
+ 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 .text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
+ .globl __x86.get_pc_thunk.ax
+ .hidden __x86.get_pc_thunk.ax
+ .type __x86.get_pc_thunk.ax, @function
+__x86.get_pc_thunk.ax:
+ movl (%esp), %eax
+ ret
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-i386/pr21997-1b.c b/ld/testsuite/ld-i386/pr21997-1b.c
new file mode 100644
index 0000000..576362e
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr21997-1b.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+extern int protected;
+extern int get_protected (void);
+extern int* get_protected_p (void);
+
+int
+main ()
+{
+
+ if (protected == get_protected ()
+ && &protected == get_protected_p ())
+ printf ("PASS\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-i386/pr21997-1c.S b/ld/testsuite/ld-i386/pr21997-1c.S
new file mode 100644
index 0000000..8534877
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr21997-1c.S
@@ -0,0 +1,51 @@
+ .section .rodata.str1.1,"aMS",@progbits,1
+.LC0:
+ .string "PASS"
+ .section .text.startup,"ax",@progbits
+ .p2align 4,,15
+ .globl main
+ .type main, @function
+main:
+ leal 4(%esp), %ecx
+ andl $-16, %esp
+ pushl -4(%ecx)
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %esi
+ pushl %ebx
+ pushl %ecx
+ call __x86.get_pc_thunk.bx
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+ subl $12, %esp
+ call get_protected@PLT
+ movl protected@GOT(%ebx), %esi
+ cmpl (%esi), %eax
+ je .L7
+.L3:
+ leal -12(%ebp), %esp
+ xorl %eax, %eax
+ popl %ecx
+ popl %ebx
+ popl %esi
+ popl %ebp
+ leal -4(%ecx), %esp
+ ret
+.L7:
+ call get_protected_p@PLT
+ cmpl %esi, %eax
+ jne .L3
+ leal .LC0@GOTOFF(%ebx), %eax
+ subl $12, %esp
+ pushl %eax
+ call puts@PLT
+ addl $16, %esp
+ jmp .L3
+ .size main, .-main
+ .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, @function
+__x86.get_pc_thunk.bx:
+ movl (%esp), %ebx
+ ret
+ .section .note.GNU-stack,"",@progbits
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.