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: 149552 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp875285vqo; Sat, 7 Oct 2023 04:34:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEErlgOItxJqLj/42MMghOw8JJoPgAJm60shArahl2Bdu7Mnu9Vy5Gk26EBnd47B96QznEl X-Received: by 2002:a17:906:100e:b0:99d:fd27:b38d with SMTP id 14-20020a170906100e00b0099dfd27b38dmr8934454ejm.70.1696678446355; Sat, 07 Oct 2023 04:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696678446; cv=none; d=google.com; s=arc-20160816; b=jo/LQwWkzP3xZbqB88vsHQY+A4oq6Bbvd3xnoiNWFzcJfIARPgBi+v9+WCunzWpmr2 NoY5V/u7psVO+oGZwgVGSbPNVWzLl+VhTlmuhHdFHqI8t6HxILrIBpodzptw4+RVJ+XP pIcIuSj9NtT73YYE+emQoI8Ep2Y/8ofvpD+HfvK8nGu9oX8uzWrhWKKU6iaXkk3NatnP ULZBUS80uZHFLjdRznNk005Lv5xAyh00ejqgTv1OM8bWUXoXQne2/mKU2sD5PY7q/QtN F62O37ht6S20j4g0jUgs6THAdQGzJ7DqO8oEQZENDsNEvA6AKGtbm8psVKmEWWHIpUPs dqtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=h7wcJUAygRWA85hKrRkeDSVEQpFDxdin/R3U0HEhPxo=; fh=jNlGlhO7zwRtRPuq9GqioOUHJrr2IOOTm9CGUBYUWK0=; b=OETN+Zjg77yzlP84DlzC9Ux9fk4bf8ousAim5S4xWLE1a4WDPwZPqLpFH3ogL2GU9i vZqcew3xmLlO7I96v+4i+nWTZWhXcsPhzFLWl30ytb/4LrcB/eTyp0e0xVZm3BrsJ9e0 K/+kIrs2pjvOftl0ufnKi7Z2ODagO0/s8mDk1HnYMdTEnVKXx4zrXC/CJ4Zl2HZGITlb jQmHUERtBuozaOFluIpvNTMo7UOnvtNx9sTmBgEohZUiJ5MZu3Vz/0zhF6cWXsb2/Y4H fAZMvE+0eyq4EReLisXfWC01pb0oCo9rDtgldrNW5uw3qGvIsy2n9km5tszBqKPcA4Rj gDSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Hme3cFUm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o5-20020a1709062e8500b0099cb1e742e7si2436877eji.224.2023.10.07.04.34.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 04:34:06 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Hme3cFUm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A9E5385CC8A for ; Sat, 7 Oct 2023 11:33:39 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779096298742152051 X-GMAIL-MSGID: 1779096298742152051 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 "/ " \