From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id AA9863858CDA for ; Mon, 25 Sep 2023 08:19:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA9863858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id DE0591F74D; Mon, 25 Sep 2023 08:19:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1695629997; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=/Ed9Upq7MzF8Z2ZxDbZpy/nkMyTxd+xvrYV7hIQL2P8=; b=ap42mKkUveLpV3oqhfB9fO2vq0drN5GAQvLYaYPf5Dg0kkbogp2cNy5j78kdO8hA2Gdei0 1uBtMpwMz2H5CHPiOMIpuefAnWxXMY5bpibPxMGOI/0FXkhNTeBRc1buvgIUP2gcegwko5 3RzSuqflyGAVPc9nqGoB9Fm3LHXEsmg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1695629997; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=/Ed9Upq7MzF8Z2ZxDbZpy/nkMyTxd+xvrYV7hIQL2P8=; b=ASBB95xeV6SJG6G4z26OUEfnH9mKUNslbJblSURZb/qzjbTLNL4iAc4ZNS6Tezvcd+w+4W 1Wsdyttbnk0BEICQ== Received: from hawking.nue2.suse.org (unknown [10.168.4.11]) by relay2.suse.de (Postfix) with ESMTP id BC8AE2C142; Mon, 25 Sep 2023 08:19:57 +0000 (UTC) Received: by hawking.nue2.suse.org (Postfix, from userid 17005) id C3C744A03CD; Mon, 25 Sep 2023 10:19:57 +0200 (CEST) From: Andreas Schwab To: binutils@sourceware.org Subject: [PATCH] RISC-V: Protect .got with relro CC: nelson@rivosinc.com, palmer@dabbelt.com X-Yow: With YOU, I can be MYSELF.. We don't NEED Dan Rather.. Date: Mon, 25 Sep 2023 10:19:57 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- ld/emulparams/elf32lriscv-defs.sh | 4 ++++ ld/emulparams/elf64lriscv-defs.sh | 1 + 2 files changed, 5 insertions(+) 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" -- 2.42.0 -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."