aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-11-30 19:46:17 +1030
committerAlan Modra <amodra@gmail.com>2017-12-01 17:23:56 +1030
commit63c1f59d665542359de4737e3e48033c588f44dc (patch)
tree4a7cd6ca5ba13f6b413d608c5968f57eede6f0e8 /ld
parent254cefe35f012977d567af0bbad2a8091d90e22b (diff)
downloadfsf-binutils-gdb-63c1f59d665542359de4737e3e48033c588f44dc.zip
fsf-binutils-gdb-63c1f59d665542359de4737e3e48033c588f44dc.tar.gz
fsf-binutils-gdb-63c1f59d665542359de4737e3e48033c588f44dc.tar.bz2
readonly_dynrelocs
In early October, HJ Lu added support for a number of targets to "Dump dynamic relocation in read-only section with minfo". This extends that support to more targets, displays the symbol involved, and splits the existing function that sets TEXTREL into a "readonly_dynrelocs" and "maybe_set_textrel" function. I'll need "readonly_dynrelocs" if I ever get around to fixing "pr22374 function pointer initialization" fails. am33_2.0, arc, bfin, hppa64, mn10300, and nios2 fail to mark a binary needing text relocations with DT_TEXTREL. That's not good. xtensa also fails to do so but complains about "dangerous relocation: dynamic relocation in read-only section" so I reckon that is fine and have marked the test as an xfail. The other targets need maintainer attention. Curiously, the map file dump wasn't added for x86, so the map test currently fail on x86. It also fails on alpha, am33_2.0, arc, bfin, hppa64, ia64, m68k, mips, mn10300, nios2, score and vax. cris complains with "tmpdir/textrel.o, section .rodata: relocation R_CRIS_32 should not be used in a shared object; recompile with -fPIC" so I've marked it as an xfail. bfd/ * elf32-hppa.c (maybe_set_textrel): Print symbol for map file output. * elf32-ppc.c (maybe_set_textrel): Likewise. * elf64-ppc.c (maybe_set_textrel): Likewise. * elf32-arm.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing.. (elf32_arm_readonly_dynrelocs): ..this. * elf32-lm32.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-m32r.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-metag.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-nds32.c: Delete unnecessary forward declarations. (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-or1k.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-s390.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-sh.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf32-tic6x.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing.. (elf32_tic6x_readonly_dynrelocs): ..this. * elf32-tilepro.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elf64-s390.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elfnn-aarch64.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing.. (aarch64_readonly_readonly_dynrelocs): ..this. * elfnn-riscv.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elfxx-sparc.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. * elfxx-tilegx.c (readonly_dynrelocs): New function. (maybe_set_textrel): New function, replacing old version of.. (readonly_dynrelocs): ..this. ld/ * testsuite/ld-elf/shared.exp: Run new textrel tests. * testsuite/ld-elf/textrel.map: New file. * testsuite/ld-elf/textrel.rd: New file. * testsuite/ld-elf/textrel.s: New file. * testsuite/ld-elf/textrel.warn: New file.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog8
-rw-r--r--ld/testsuite/ld-elf/shared.exp25
-rw-r--r--ld/testsuite/ld-elf/textrel.map3
-rw-r--r--ld/testsuite/ld-elf/textrel.rd3
-rw-r--r--ld/testsuite/ld-elf/textrel.s5
-rw-r--r--ld/testsuite/ld-elf/textrel.warn3
6 files changed, 47 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 51d50d1..0729d21 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2017-12-01 Alan Modra <amodra@gmail.com>
+
+ * testsuite/ld-elf/shared.exp: Run new textrel tests.
+ * testsuite/ld-elf/textrel.map: New file.
+ * testsuite/ld-elf/textrel.rd: New file.
+ * testsuite/ld-elf/textrel.s: New file.
+ * testsuite/ld-elf/textrel.warn: New file.
+
2017-11-30 Alan Modra <amodra@gmail.com>
PR 22471
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 99c34be..cc145b4 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -83,6 +83,31 @@ run_ld_link_tests [list \
] \
]
+run_ld_link_tests [list \
+ [list \
+ "DT_TEXTREL in shared lib" \
+ "$LFLAGS -shared --warn-shared-textrel" \
+ "" \
+ "$AFLAGS_PIC" \
+ {textrel.s} \
+ {{ld textrel.warn} \
+ {readelf {-d --wide} textrel.rd}} \
+ "textrel.so" \
+ ] \
+] "xtensa-*-*"
+
+run_ld_link_tests [list \
+ [list \
+ "DT_TEXTREL map file warning" \
+ "$LFLAGS -shared -M" \
+ "" \
+ "$AFLAGS_PIC" \
+ {textrel.s} \
+ {{ld textrel.map}} \
+ "textrel.so" \
+ ] \
+] "cris*-*-*"
+
# PR ld/20828 check for correct dynamic symbol table entries where:
# - symbols have been defined with a linker script,
# - the same symbols have been seen in shared library used in the link,
diff --git a/ld/testsuite/ld-elf/textrel.map b/ld/testsuite/ld-elf/textrel.map
new file mode 100644
index 0000000..fa33113
--- /dev/null
+++ b/ld/testsuite/ld-elf/textrel.map
@@ -0,0 +1,3 @@
+#...
+.*dynamic relocation .* read-only section.*
+#pass
diff --git a/ld/testsuite/ld-elf/textrel.rd b/ld/testsuite/ld-elf/textrel.rd
new file mode 100644
index 0000000..cc270df
--- /dev/null
+++ b/ld/testsuite/ld-elf/textrel.rd
@@ -0,0 +1,3 @@
+#...
+.*\(TEXTREL\).*
+#pass
diff --git a/ld/testsuite/ld-elf/textrel.s b/ld/testsuite/ld-elf/textrel.s
new file mode 100644
index 0000000..b4bfb58
--- /dev/null
+++ b/ld/testsuite/ld-elf/textrel.s
@@ -0,0 +1,5 @@
+ .section .rodata,"a",%progbits
+ .global pfoo, foo
+pfoo:
+ .dc.a foo
+foo:
diff --git a/ld/testsuite/ld-elf/textrel.warn b/ld/testsuite/ld-elf/textrel.warn
new file mode 100644
index 0000000..51d9ca8
--- /dev/null
+++ b/ld/testsuite/ld-elf/textrel.warn
@@ -0,0 +1,3 @@
+#...
+.*warning:.*DT_TEXTREL.*
+#pass