From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id 30ECC3858406 for ; Tue, 13 Sep 2022 15:32:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 30ECC3858406 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1663083170; bh=rUAFw1a6qdunP/7EnEF5OI5yQBmpwAsbFeKHN5WIbPM=; h=From:To:Cc:Subject:Date:From; b=cszOpF+VT9zET3BfOOqL73IzYjSNQwBEBy4XYu6M8H+aG4skpa8tqgS9azkLgOyqL J4vnwcR0DDxRfTSFgThNJC3ash17JDsz9P4qCAWFyL91ZKuRnLZeAjf6zkh1lOg/Sd gNXfG9ZFNvKqE6n2nnRzH+ibkEQJuvWjBKGsPNp8= Received: from xry111-x57s1.. (unknown [IPv6:240e:358:1123:8b00:dc73:854d:832e:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id B669865C27; Tue, 13 Sep 2022 11:32:46 -0400 (EDT) From: Xi Ruoyao To: gcc-patches@gcc.gnu.org Cc: Lulu Cheng , Wang Xuerui , Chenghua Xu , liuzhensong , Xi Ruoyao Subject: [PATCH] LoongArch: Prepare static PIE support Date: Tue, 13 Sep 2022 23:32:37 +0800 Message-Id: <20220913153237.305471-1-xry111@xry111.site> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD,FROM_SUSPICIOUS_NTLD_FP,GIT_PATCH_0,LIKELY_SPAM_FROM,PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Static PIE allows us to extend the ASLR to cover static executables and it's not too difficult to support it. On GCC side, we just pass a group of options to the linker, like other ports with static PIE support. The real implementation of static PIE (rcrt1.o) will be added into Glibc later. gcc/ChangeLog: * config/loongarch/gnu-user.h (GNU_USER_TARGET_LINK_SPEC): For -static-pie, pass -static -pie --no-dynamic-linker -z text to the linker, and do not pass --dynamic-linker. --- gcc/config/loongarch/gnu-user.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/config/loongarch/gnu-user.h b/gcc/config/loongarch/gnu-user.h index 664dc9206ad..c5b1afe530d 100644 --- a/gcc/config/loongarch/gnu-user.h +++ b/gcc/config/loongarch/gnu-user.h @@ -40,8 +40,10 @@ along with GCC; see the file COPYING3. If not see #undef GNU_USER_TARGET_LINK_SPEC #define GNU_USER_TARGET_LINK_SPEC \ "%{G*} %{shared} -m " GNU_USER_LINK_EMULATION \ - "%{!shared: %{static} %{!static: %{rdynamic:-export-dynamic} " \ - "-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}" + "%{!shared: %{static} " \ + "%{!static: %{!static-pie: %{rdynamic:-export-dynamic} " \ + "-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} " \ + "%{static-pie: -static -pie --no-dynamic-linker -z text}}" /* Similar to standard Linux, but adding -ffast-math support. */ -- 2.37.3