public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] RISC-V: Protect .got with relro
@ 2023-09-25 10:37 Andreas Schwab
  0 siblings, 0 replies; only message in thread
From: Andreas Schwab @ 2023-09-25 10:37 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7345d05aafde53a48d5a587a6d9c1778db78e0f3

commit 7345d05aafde53a48d5a587a6d9c1778db78e0f3
Author: Andreas Schwab <schwab@suse.de>
Date:   Thu Sep 21 16:49:41 2023 +0200

    RISC-V: Protect .got with relro
    
    Move .got before .data so that it can be protected with -zrelro.  Also
    separate .got.plt from .got if -znow is not in effect; the first two words
    of .got.plt are placed within the relro region.
    
    ld:
            PR ld/30877
            * emulparams/elf32lriscv-defs.sh (DATA_GOT, SEPARATE_GOTPLT):
            Define.
            * emulparams/elf64lriscv-defs.sh (SEPARATE_GOTPLT): Define.
            * testsuite/ld-elf/binutils.exp (binutils_test): Remove riscv*-*-*
            from relro_got expression.

Diff:
---
 ld/emulparams/elf32lriscv-defs.sh | 4 ++++
 ld/emulparams/elf64lriscv-defs.sh | 1 +
 ld/testsuite/ld-elf/binutils.exp  | 1 -
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ld/emulparams/elf32lriscv-defs.sh b/ld/emulparams/elf32lriscv-defs.sh
index b823cedacab..016556168c3 100644
--- a/ld/emulparams/elf32lriscv-defs.sh
+++ b/ld/emulparams/elf32lriscv-defs.sh
@@ -47,3 +47,7 @@ INITIAL_READONLY_SECTIONS="${RELOCATING+${CREATE_SHLIB-${INITIAL_READONLY_SECTIO
 OTHER_END_SYMBOLS="${CREATE_SHLIB-__BSS_END__ = .;
     __global_pointer$ = MIN(__SDATA_BEGIN__ + 0x800,
 		            MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ - 0x800));}"
+
+# Put .got before .data
+DATA_GOT=" "
+SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 8 ? 8 : 0"
diff --git a/ld/emulparams/elf64lriscv-defs.sh b/ld/emulparams/elf64lriscv-defs.sh
index 84a700a5f58..ca15338428f 100644
--- a/ld/emulparams/elf64lriscv-defs.sh
+++ b/ld/emulparams/elf64lriscv-defs.sh
@@ -1,2 +1,3 @@
 source_sh ${srcdir}/emulparams/elf32lriscv-defs.sh
 ELFSIZE=64
+SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 16 ? 16 : 0"
diff --git a/ld/testsuite/ld-elf/binutils.exp b/ld/testsuite/ld-elf/binutils.exp
index 674e8e9a575..b38e29ed6fb 100644
--- a/ld/testsuite/ld-elf/binutils.exp
+++ b/ld/testsuite/ld-elf/binutils.exp
@@ -95,7 +95,6 @@ proc binutils_test { prog_name ld_options test {test_name ""} {readelf_options "
 			      || [istarget "mips*-*-*"] \
 			      || [istarget "nios2*-*-*"] \
 			      || [istarget "or1k-*-*"] \
-			      || [istarget "riscv*-*-*"] \
 			      || [istarget "sh*-*-*"] \
 			      || [istarget "x86_64-*-rdos*"])]
 	# Check if GNU_RELRO segment is generated.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-25 10:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-25 10:37 [binutils-gdb] RISC-V: Protect .got with relro Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).