From 9acc85a62eb76c270724bba15c889d2d05567b6a Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 28 Dec 2016 17:04:15 +1030 Subject: Use dynrelro for symbols in relro sections too PR ld/20995 bfd/ * elflink.c (elf_link_add_object_symbols): Mark relro sections in dynamic objects SEC_READONLY. ld/ * testsuite/ld-elf/pr20995c.s: New test file. * testsuite/ld-elf/pr20995-2so.r: Likewise. * testsuite/ld-elf/elf.exp: Run it. --- ld/ChangeLog | 7 +++++++ ld/testsuite/ld-elf/elf.exp | 12 ++++++++++++ ld/testsuite/ld-elf/pr20995-2so.r | 3 +++ ld/testsuite/ld-elf/pr20995c.s | 13 +++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 ld/testsuite/ld-elf/pr20995-2so.r create mode 100644 ld/testsuite/ld-elf/pr20995c.s (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index 1b8f59a..be179ed 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2016-12-28 Alan Modra + + PR ld/20995 + * testsuite/ld-elf/pr20995c.s: New test file. + * testsuite/ld-elf/pr20995-2so.r: Likewise. + * testsuite/ld-elf/elf.exp: Run it. + 2016-12-26 Alan Modra PR ld/20995 diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index 9b1fbeb..47f1383 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -134,6 +134,12 @@ if { [check_shared_lib_support] } then { "-shared" "" "" {pr20995b.s} {} "pr20995.so"} } + setup_xfail "tic6x-*-*" + run_ld_link_tests { + {"Build pr20995-2.so" + "-shared -z relro" "" "" + {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"} + } # These targets don't copy dynamic variables into .bss. setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" run_ld_link_tests { @@ -141,6 +147,12 @@ if { [check_shared_lib_support] } then { "" "tmpdir/pr20995.so" "" {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"} } + setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" + run_ld_link_tests { + {"pr20995-2" + "" "tmpdir/pr20995-2.so" "" + {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"} + } } set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]] diff --git a/ld/testsuite/ld-elf/pr20995-2so.r b/ld/testsuite/ld-elf/pr20995-2so.r new file mode 100644 index 0000000..3cd4c27 --- /dev/null +++ b/ld/testsuite/ld-elf/pr20995-2so.r @@ -0,0 +1,3 @@ +#... + GNU_RELRO .* +#pass diff --git a/ld/testsuite/ld-elf/pr20995c.s b/ld/testsuite/ld-elf/pr20995c.s new file mode 100644 index 0000000..ccca92d --- /dev/null +++ b/ld/testsuite/ld-elf/pr20995c.s @@ -0,0 +1,13 @@ + .data + .type rw,%object + .globl rw +rw: + .dc.a 0 + .size rw, . - rw + + .section .data.rel.ro,"aw",%progbits + .type ro,%object + .globl ro +ro: + .dc.a 0 + .size ro, . - ro -- cgit v1.1