aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-elf
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite/ld-elf')
-rw-r--r--ld/testsuite/ld-elf/pr19719a.c12
-rw-r--r--ld/testsuite/ld-elf/pr19719b.c8
-rw-r--r--ld/testsuite/ld-elf/pr19719c.c8
-rw-r--r--ld/testsuite/ld-elf/pr19719d.c5
-rw-r--r--ld/testsuite/ld-elf/shared.exp60
5 files changed, 93 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/pr19719a.c b/ld/testsuite/ld-elf/pr19719a.c
new file mode 100644
index 0000000..72249a5
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr19719a.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+extern int foo (void);
+extern int bar (void);
+
+int
+main (void)
+{
+ if (foo () == bar ())
+ printf ("PASS\n");
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/pr19719b.c b/ld/testsuite/ld-elf/pr19719b.c
new file mode 100644
index 0000000..6ef6268
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr19719b.c
@@ -0,0 +1,8 @@
+extern int __attribute__ ((weak)) fun (void);
+int
+foo (void)
+{
+ if (&fun != 0)
+ return fun ();
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/pr19719c.c b/ld/testsuite/ld-elf/pr19719c.c
new file mode 100644
index 0000000..5c877d9
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr19719c.c
@@ -0,0 +1,8 @@
+extern int __attribute__ ((weak)) fun (void);
+int
+bar (void)
+{
+ if (&fun != 0)
+ return fun ();
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/pr19719d.c b/ld/testsuite/ld-elf/pr19719d.c
new file mode 100644
index 0000000..231eeef
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr19719d.c
@@ -0,0 +1,5 @@
+int
+fun (void)
+{
+ return 20;
+}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index a864430..e615f55 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -582,3 +582,63 @@ if { [istarget *-*-linux*]
] \
]
}
+
+proc mix_pic_and_non_pic {cflags ldflags} {
+ set testname "Mixing PIC and non-PIC"
+ if { ![ string match "" $cflags$ldflags] } {
+ set testname "$testname ($cflags $ldflags)"
+ }
+
+ run_cc_link_tests [list \
+ [list \
+ "Build libpr19719a.so" \
+ "-shared -Wl,-soname,libpr19719.so" \
+ "-fPIC" \
+ { pr19719d.c } \
+ {} \
+ "libpr19719a.so" \
+ ] \
+ [list \
+ "Build libpr19719b.so" \
+ "-shared -Wl,-soname,libpr19719.so" \
+ "-fPIC" \
+ { dummy.c } \
+ {} \
+ "libpr19719b.so" \
+ ] \
+ [list \
+ "Build pr19073b.o" \
+ "-r -nostdlib" \
+ "-fPIC" \
+ { pr19719b.c } \
+ {} \
+ "libpr19719b.o" \
+ ] \
+ ]
+
+ exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so
+
+ run_ld_link_exec_tests [] [list \
+ [list \
+ "Run pr19719" \
+ "$ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so -R tmpdir" \
+ "" \
+ { pr19719a.c pr19719c.c } \
+ "pr19719" \
+ "pass.out" \
+ "$cflags" \
+ ] \
+ ]
+
+ exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so
+
+ set exec_output [run_host_cmd tmpdir/pr19719 ""]
+ if {![string match "PASS" $exec_output]} {
+ fail $testname
+ } else {
+ pass $testname
+ }
+}
+
+mix_pic_and_non_pic "" ""
+mix_pic_and_non_pic "-fPIE" "-pie"