From patchwork Tue Aug 15 01:44:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: develop--- via Libc-alpha X-Patchwork-Id: 1821235 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=server2.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=XdtizUL9; dkim-atps=neutral Received: from server2.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 4RPvGr1Qljz1yf9 for ; Tue, 15 Aug 2023 11:45:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB3963858032 for ; Tue, 15 Aug 2023 01:45:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB3963858032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692063920; bh=CSnp4DnzQBWyP0pKheMNLuUvJ/dSkOEQgZwPaNTleOg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=XdtizUL9vYcc8tbq7I2A/v/XS2mbcnfLS/8n3tuCyFYYLD7cNw5CvbXlJmVs0S/kC vYlpdGEiRmxmL+b2DXUlJfbfbBs9N+mzIRI06YnXO9QFFHeVraeFbnFcoyGvAjjZeJ VUOl6lkXTjdF7lawcd+umq9a90u8IAEeYhVx8sQ4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id A0C333858C62 for ; Tue, 15 Aug 2023 01:45:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A0C333858C62 X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="458535468" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="458535468" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2023 18:45:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="736733658" X-IronPort-AV: E=Sophos;i="6.01,173,1684825200"; d="scan'208";a="736733658" Received: from shvmail02.sh.intel.com ([10.239.244.9]) by fmsmga007.fm.intel.com with ESMTP; 14 Aug 2023 18:45:02 -0700 Received: from yanzhang-dev.sh.intel.com (yanzhang-dev.sh.intel.com [10.239.159.126]) by shvmail02.sh.intel.com (Postfix) with ESMTP id 8114C10054EC; Tue, 15 Aug 2023 09:45:01 +0800 (CST) To: libc-alpha@sourceware.org Cc: carlos@redhat.com, palmer@dabbelt.com, yanzhang.wang@intel.com Subject: [PATCH v2] RISC-V: Enable static-pie. Date: Tue, 15 Aug 2023 09:44:34 +0800 Message-ID: <20230815014434.1902446-1-yanzhang.wang@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810233348.1214955-1-yanzhang.wang@intel.com> References: <20230810233348.1214955-1-yanzhang.wang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, 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 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: "yanzhang.wang--- via Libc-alpha" From: develop--- via Libc-alpha Reply-To: yanzhang.wang@intel.com Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" From: Yanzhang Wang This patch referents the commit 374cef3 to add static-pie support. And because the dummy link map is used when relocating ourselves, so need not to set __global_pointer$ at this time. --- sysdeps/riscv/configure | 1 + sysdeps/riscv/configure.ac | 3 +++ sysdeps/riscv/dl-machine.h | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure index acd1f5e743..ecaf8e2a0b 100644 --- a/sysdeps/riscv/configure +++ b/sysdeps/riscv/configure @@ -31,3 +31,4 @@ printf "%s\n" "$libc_cv_riscv_r_align" >&6; } config_vars="$config_vars riscv-r-align = $libc_cv_riscv_r_align" +$as_echo "#define SUPPORT_STATIC_PIE 1" >>confdefs.h diff --git a/sysdeps/riscv/configure.ac b/sysdeps/riscv/configure.ac index dbcc216689..36da2b5396 100644 --- a/sysdeps/riscv/configure.ac +++ b/sysdeps/riscv/configure.ac @@ -16,3 +16,6 @@ EOF fi rm -rf conftest.*]) LIBC_CONFIG_VAR([riscv-r-align], [$libc_cv_riscv_r_align]) + +dnl Static PIE is supported. +AC_DEFINE(SUPPORT_STATIC_PIE) diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h index c0c9bd93ad..ad875c0828 100644 --- a/sysdeps/riscv/dl-machine.h +++ b/sysdeps/riscv/dl-machine.h @@ -323,7 +323,7 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], gotplt[1] = (ElfW(Addr)) l; } - if (l->l_type == lt_executable) + if (l->l_type == lt_executable && l->l_scope != NULL) { /* The __global_pointer$ may not be defined by the linker if the $gp register does not be used to access the global variable