From patchwork Thu Aug 10 23:33:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yanzhang.wang--- via Libc-alpha" X-Patchwork-Id: 73975 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F68B3858025 for ; Thu, 10 Aug 2023 23:35:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F68B3858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691710527; bh=vcMXrMrMLhoSfFCCQ6ABGK9RZuS9Z3B9nrqce1wCU+Q=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=LOSYIBosjScjD9V91cpwc08JhjorjyAxzXzav6zPPZe8uUkDPOwtZ5fcanSYya8fy sIRVmKBnnZHeRIcDbTXfR8RqZQ2xjVE0yIwPLpqPas2r4xu0ns1vXCTS7rFV2m/bwh sAmIuMbJcYzn/0mtupA5JiRQGOmbfO4mopJE6jjg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by sourceware.org (Postfix) with ESMTPS id 17D253858D20 for ; Thu, 10 Aug 2023 23:35:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 17D253858D20 X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="402516740" X-IronPort-AV: E=Sophos;i="6.01,163,1684825200"; d="scan'208";a="402516740" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2023 16:34:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="709329634" X-IronPort-AV: E=Sophos;i="6.01,163,1684825200"; d="scan'208";a="709329634" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga006.jf.intel.com with ESMTP; 10 Aug 2023 16:34:34 -0700 Received: from yanzhang-dev.sh.intel.com (yanzhang-dev.sh.intel.com [10.239.159.126]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 3C927100519E; Fri, 11 Aug 2023 07:34:33 +0800 (CST) To: libc-alpha@sourceware.org Cc: yanzhang.wang@intel.com Subject: [PATCH] RISC-V: Enable static-pie. Date: Fri, 11 Aug 2023 07:33:48 +0800 Message-ID: <20230810233348.1214955-1-yanzhang.wang@intel.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: "yanzhang.wang--- via Libc-alpha" Reply-To: yanzhang.wang@intel.com Errors-To: libc-alpha-bounces+patchwork=sourceware.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 | 2 ++ sysdeps/riscv/configure.ac | 3 +++ sysdeps/riscv/dl-machine.h | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure index 2372225a26..340163779f 100644 --- a/sysdeps/riscv/configure +++ b/sysdeps/riscv/configure @@ -29,3 +29,5 @@ fi $as_echo "$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