From patchwork Sat Oct 7 11:32:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yanzhang" X-Patchwork-Id: 1844719 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Hme3cFUm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S2jq258vNz1yq7 for ; Sat, 7 Oct 2023 22:33:29 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5264038560B6 for ; Sat, 7 Oct 2023 11:33:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id 1E537385B51F for ; Sat, 7 Oct 2023 11:33:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E537385B51F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696678394; x=1728214394; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+yWUbHeut8cjHLIYaTZlN/EUX4UNU7Gh34qseFgWXq4=; b=Hme3cFUmD8ON4VH9fCldohoYAzxfedc8KTDZVBEvBZMg0fkxw2HMZhXK FToU8dDUnQkQ5ZqT2+bVrFJhwOMUOAxt4hLfDJfpjWVrgL3XVjyUD/aMN JNIDN3scxrDpktBTwoZVEXWzqIAxzMHIAKLVfVnBKu1OcTsPTQfSP5hYt O7C+jIurOvzu/0hbtCq+7d4N7AyJx67/H9e+r+NOxfHJqAEV1MzSJPzdp UmHloMs4zBWpGxu3i+eVNMFLe1jtahHS/XzURGPyow+I3KptVYkHQRV8Y 4hN+nCBbRPm69xQA8780C3td2Lf0AcN8CsinAvJhhQIw6M2GmiQCKWUNz Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="363270019" X-IronPort-AV: E=Sophos;i="6.03,205,1694761200"; d="scan'208";a="363270019" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2023 04:33:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="818331537" X-IronPort-AV: E=Sophos;i="6.03,205,1694761200"; d="scan'208";a="818331537" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga008.fm.intel.com with ESMTP; 07 Oct 2023 04:33:10 -0700 Received: from yanzhang-dev.sh.intel.com (yanzhang-dev.sh.intel.com [10.239.159.141]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 03CF710056EF; Sat, 7 Oct 2023 19:33:10 +0800 (CST) From: yanzhang.wang@intel.com To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@sifive.com, pan2.li@intel.com, yanzhang.wang@intel.com Subject: [PATCH] RISC-V: add static-pie support Date: Sat, 7 Oct 2023 19:32:25 +0800 Message-ID: <20231007113225.3196037-1-yanzhang.wang@intel.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org From: Yanzhang Wang We only need to pass options to the linker when static-pie is passed. There's another patch to enable static-pie in glibc. And we need to enable in GCC first. gcc/ChangeLog: * config/riscv/linux.h: Pass the static-pie specific options to the linker. Signed-off-by: Yanzhang Wang --- Have tested with glibc enabled and no regression of gcc found. gcc/config/riscv/linux.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h index 7323ff30f70..8901671ddf6 100644 --- a/gcc/config/riscv/linux.h +++ b/gcc/config/riscv/linux.h @@ -55,9 +55,10 @@ along with GCC; see the file COPYING3. If not see %{shared} \ %{!shared: \ %{!static: \ - %{rdynamic:-export-dynamic} \ - -dynamic-linker " GNU_USER_DYNAMIC_LINKER "} \ - %{static:-static}}" + %{!static-pie: \ + %{rdynamic:-export-dynamic} \ + -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \ + %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" #define STARTFILE_PREFIX_SPEC \ "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \