This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] LD/testsuite: Conditionalize the placement of `.got' in GNU_RELRO
- From: Maciej W.Rozycki <macro at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 18 Jul 2017 16:24:44 -0000
- Subject: [binutils-gdb] LD/testsuite: Conditionalize the placement of `.got' in GNU_RELRO
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=927960f053ec6e361236964c3780d2acd5de4084
commit 927960f053ec6e361236964c3780d2acd5de4084
Author: Maciej W. Rozycki <macro@imgtec.com>
Date: Tue Jul 18 17:20:30 2017 +0100
LD/testsuite: Conditionalize the placement of `.got' in GNU_RELRO
Complement commit d345186d0535 ("Check if GNU_RELRO segment is is
generated") and exclude the presence of a `.got' section from implying
the creation of a GNU_RELRO segment for targets which place the section
along with small data, and therefore as it stands cannot have the
section assigned to GNU_RELRO. This is because we currently only
support a single GNU_RELRO segment and we place it at the beginning of
regular data which is then separated from small data by read-write data.
Currently the list of such targets consists of Alpha, Linux HPPA, NetBSD
HPPA, OpenBSD HPPA, Meta, MIPS, Nios II, OpenRISC 1000, RISC-V, SH and
X86-64, as determined by examining default linker scripts produced in a
`--enable-targets=all' build for those that have DATA_SEGMENT_RELRO_END
set and `.got' placed beyond. These targets do not set NO_SMALL_DATA or
DATA_GOT in their respective files in ld/emulparams/*, hovever checking
for the absence of these settings on its own is not very feasible due to
the structure of these files and the lack of support for GNU_RELRO by
some targets in the first place.
Add a separate control for `.got.plt' which does get placed in GNU_RELRO
on MIPS targets even though `.got' does not.
ld/
* testsuite/ld-elf/binutils.exp (binutils_test): Make the
expectation for `.got' in GNU_RELRO segment target-specific.
Handle `.got.plt' separately.
Diff:
---
ld/ChangeLog | 6 ++++++
ld/testsuite/ld-elf/binutils.exp | 19 ++++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 7af1ddc..ea648a9 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,6 +1,12 @@
2017-07-18 Maciej W. Rozycki <macro@imgtec.com>
* testsuite/ld-elf/binutils.exp (binutils_test): Make the
+ expectation for `.got' in GNU_RELRO segment target-specific.
+ Handle `.got.plt' separately.
+
+2017-07-18 Maciej W. Rozycki <macro@imgtec.com>
+
+ * testsuite/ld-elf/binutils.exp (binutils_test): Make the
expectation for `.dynamic' in GNU_RELRO segment target-specific.
2017-07-18 Nick Clifton <nickc@redhat.com>
diff --git a/ld/testsuite/ld-elf/binutils.exp b/ld/testsuite/ld-elf/binutils.exp
index 687749d..fcd0d96 100644
--- a/ld/testsuite/ld-elf/binutils.exp
+++ b/ld/testsuite/ld-elf/binutils.exp
@@ -86,13 +86,30 @@ proc binutils_test { prog_name ld_options test {test_name ""} {readelf_options "
set relro_dynamic [expr !([istarget "hppa64*-*-*"] \
|| ([istarget "mips*-*-*"] \
&& ![istarget "*-*-vxworks*"]))]
+ # These targets have `.got' in regular data even though they do
+ # not have `.got' there.
+ set relro_gotplt [expr [istarget "mips*-*-*"]]
+ # These targets do not set NO_SMALL_DATA or DATA_GOT and therefore
+ # have `.got' in (read-write) small data rather than regular data.
+ set relro_got [expr !([istarget "alpha*-*-*"] \
+ || [istarget "hppa*-*-linux-*"] \
+ || [istarget "hppa*-*-netbsd*"] \
+ || [istarget "hppa*-*-openbsd*"] \
+ || [istarget "metag-*-*"] \
+ || [istarget "mips*-*-*"] \
+ || [istarget "nios2*-*-*"] \
+ || [istarget "or1k-*-*"] \
+ || [istarget "riscv*-*-*"] \
+ || [istarget "sh*-*-*"] \
+ || [istarget "x86_64-*-rdos*"])]
# Check if GNU_RELRO segment is generated.
set got [remote_exec host "grep GNU_RELRO tmpdir/$test.exp"]
if { ![string match "*GNU_RELRO*" $got] } then {
set got [remote_exec host "cat tmpdir/$test.exp"]
if { [string match "*.data.rel.ro*" $got]
|| ($relro_dynamic && [string match "*.dynamic*" $got])
- || [string match "*.got*" $got]
+ || ($relro_gotplt && [string match "*.got.plt*" $got])
+ || ($relro_got && [string match "*.got*" $got])
|| [string match "*.eh_frame*" $got]
|| [string match "*.gcc_except_table*" $got]
|| [string match "*.exception_ranges*" $got]