aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-powerpc
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-01-27 23:40:05 +1030
committerAlan Modra <amodra@gmail.com>2015-01-28 18:30:54 +1030
commitdbd1e97e32057af2841e5150daa2e2d4cb046a3b (patch)
treead21bab1f655d821724de5eab738bd4016aff80d /ld/testsuite/ld-powerpc
parent3f8107ab38095bb3db840f9f14a0fd339f55e06e (diff)
downloadgdb-dbd1e97e32057af2841e5150daa2e2d4cb046a3b.zip
gdb-dbd1e97e32057af2841e5150daa2e2d4cb046a3b.tar.gz
gdb-dbd1e97e32057af2841e5150daa2e2d4cb046a3b.tar.bz2
PowerPC64 changes for xlc
The changes to reorder sections for better relro protection on powerpc64, 3e2b0f31, 23283c1b, and 5ad18f16, run into a problem with xlc. xlc -qdatalocal puts global variables into .toc, which means that .toc must be writable. The simplest way to accomplish this is to edit the linker script to remove .toc sections from .got on detecting xlc object files. bfd/ * elf64-ppc.h (struct ppc64_elf_params): Add "object_in_toc". * elf64-ppc.c (ppc64_elf_add_symbol_hook): Assume that global symbols in .toc indicate xlc compiled code that might require a rw .toc. ld/ * emulparams/elf64ppc.sh (INITIAL_READWRITE_SECTIONS): Define. * emultempl/ppc64elf.em (params): Init new field. (ppc_after_open): New function. (LDEMUL_AFTER_OPEN): Define. * ldlang.c (lang_final): Whitespace fix. ld/testsuite/ * ld-powerpc/tocvar.d, * ld-powerpc/tocvar.s: New test. * ld-powerpc/tocnovar.d, * ld-powerpc/tocnovar.s: New test. * ld-powerpc/powerpc.exp: Run tocvar and tocnovar.
Diffstat (limited to 'ld/testsuite/ld-powerpc')
-rw-r--r--ld/testsuite/ld-powerpc/powerpc.exp2
-rw-r--r--ld/testsuite/ld-powerpc/tocnovar.d14
-rw-r--r--ld/testsuite/ld-powerpc/tocnovar.s16
-rw-r--r--ld/testsuite/ld-powerpc/tocvar.d14
-rw-r--r--ld/testsuite/ld-powerpc/tocvar.s17
5 files changed, 63 insertions, 0 deletions
diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index 11f1e4f..81cc310 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -320,3 +320,5 @@ run_dump_test "attr-gnu-12-11"
run_dump_test "attr-gnu-12-21"
run_dump_test "vle-multiseg-6"
+run_dump_test "tocvar"
+run_dump_test "tocnovar"
diff --git a/ld/testsuite/ld-powerpc/tocnovar.d b/ld/testsuite/ld-powerpc/tocnovar.d
new file mode 100644
index 0000000..d1fd258
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tocnovar.d
@@ -0,0 +1,14 @@
+#source: tocnovar.s
+#as: -a64
+#ld: -melf64ppc -z relro
+#readelf: -l --wide
+#target: powerpc64*-*-*
+
+#...
+ +LOAD .*
+ +LOAD .*
+ +GNU_RELRO .*
+#...
+ +00 +\.text
+ +01 +\.opd \.got
+ +02 +\.opd \.got
diff --git a/ld/testsuite/ld-powerpc/tocnovar.s b/ld/testsuite/ld-powerpc/tocnovar.s
new file mode 100644
index 0000000..8045d14
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tocnovar.s
@@ -0,0 +1,16 @@
+ .section .opd,"aw",@progbits
+ .global _start
+ .type _start,@function
+_start:
+ .quad .L_start, .TOC.@tocbase, 0
+
+ .text
+.L_start:
+ lwz 3,x@toc(2)
+ b _start
+ .size _start,.-.L_start
+
+ .section .toc,"aw",@progbits
+ .type x,@object
+x: .long 0
+ .size x,.-x
diff --git a/ld/testsuite/ld-powerpc/tocvar.d b/ld/testsuite/ld-powerpc/tocvar.d
new file mode 100644
index 0000000..62bc998
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tocvar.d
@@ -0,0 +1,14 @@
+#source: tocvar.s
+#as: -a64
+#ld: -melf64ppc -z relro
+#readelf: -l --wide
+#target: powerpc64*-*-*
+
+#...
+ +LOAD .*
+ +LOAD .*
+ +GNU_RELRO .*
+#...
+ +00 +\.text
+ +01 +\.opd \.toc
+ +02 +\.opd
diff --git a/ld/testsuite/ld-powerpc/tocvar.s b/ld/testsuite/ld-powerpc/tocvar.s
new file mode 100644
index 0000000..d4ebbbe
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tocvar.s
@@ -0,0 +1,17 @@
+ .section .opd,"aw",@progbits
+ .global _start
+ .type _start,@function
+_start:
+ .quad .L_start, .TOC.@tocbase, 0
+
+ .text
+.L_start:
+ lwz 3,x@toc(2)
+ b _start
+ .size _start,.-.L_start
+
+ .section .toc,"aw",@progbits
+ .global x
+ .type x,@object
+x: .long 0
+ .size x,.-x