From patchwork Fri Sep 23 11:16:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1681518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=sGdWiWWd; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MYqPM2m0yz1yqH for ; Fri, 23 Sep 2022 21:17:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C99A8385734D for ; Fri, 23 Sep 2022 11:17:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C99A8385734D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663931844; bh=Nz8/BQoVfXTsw5PYDssCpf0wtL8r586uvwJrADJQWqo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=sGdWiWWdGskd6t92bgXuP7y26hzK3Mk3IfvEYT8mu2LMn5JLfufLYCwdlH9ytuKyr ZCXJOCCLFieh4q9lAQMmXC2UtjTJ3ACZixIJMwghB1D0oFk6DNcZHLrjXdb8GvupjU +DMV9ZOdZ325XmKwPRiZGJxxpyW4WTnltqQFWXEE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id D83233858C52 for ; Fri, 23 Sep 2022 11:17:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D83233858C52 Received: from xry111-x57s1.. (unknown [IPv6:240e:358:11af:2800: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 3F16065EB4; Fri, 23 Sep 2022 07:16:56 -0400 (EDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 0/1] LoongArch: Add static PIE support Date: Fri, 23 Sep 2022 19:16:46 +0800 Message-Id: <20220923111647.48303-1-xry111@xry111.site> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FROM_SUSPICIOUS_NTLD, FROM_SUSPICIOUS_NTLD_FP, KAM_SHORT, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP, T_PDS_OTHER_BAD_TLD autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Cc: caiyinyu , Chenghua Xu , liuzhensong , Lulu Cheng , Wang Xuerui Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Static PIE allows us to extend the ASLR to cover static executables, this patch adds static PIE support for LoongArch. Changes from v1 to v2: check the relocation of linker output for -static-pie to see if it really works, instead of checking GCC version. Change from RFC to v1: no change, just remove "RFC" because the GCC [1] and Binutils [2][3] patches are already merged. [1]: https://gcc.gnu.org/r13-2728 [2]: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ae2e4d4 Summary of test results (with GCC trunk and Binutils trunk): 4592 PASS 22 UNSUPPORTED 12 XFAIL 6 XPASS Use "sln" as an example to show it works: $ file elf/sln elf/sln: ELF 64-bit LSB pie executable, LoongArch, version 1 (SYSV), static-pie linked, for GNU/Linux 5.19.0, with debug_info, not stripped $ touch a $ elf/sln a b $ readlink b a Xi Ruoyao (1): LoongArch: Add static PIE support sysdeps/loongarch/configure | 37 ++++++++++++++++++++++++++++++++++ sysdeps/loongarch/configure.ac | 14 +++++++++++++ sysdeps/loongarch/start.S | 14 ++++++++++--- 3 files changed, 62 insertions(+), 3 deletions(-)