From patchwork Sun Oct 23 09:34:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 7967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1542963wrr; Sun, 23 Oct 2022 02:35:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GX2cx/LTUstCrJ+fCDHMwn3poKMO/GH2kHMnc2861NiTLR8L5vBLnjGngMqKI1l3eDl91 X-Received: by 2002:a05:6402:b6b:b0:461:b9b2:6d58 with SMTP id cb11-20020a0564020b6b00b00461b9b26d58mr851301edb.186.1666517741461; Sun, 23 Oct 2022 02:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666517741; cv=none; d=google.com; s=arc-20160816; b=hk/pjyzcsGdwYcnRkpt5kwaV2qRgZLiAtqeX5dKnQZ4d4N8PBAINXGBc1z6H8IxPQV 2EMNydjbOD7TEEwabDMsbzKRGWVR0P381lSXSqfsGKAMEiJqTR1LcQuNJUheUN99DORx AaI1tIr1lr5gq/LZZ9vzyxvwsrEp6Cm8GioqlQA4OKIJ6ygAXRHtI7a6oVXDKNRGDaS5 fSOG5JGxXm91OSk/tMb5DRg4FxYGotMq/FgNoUtmG5BmGWPyIFFH4k0eOkVjiqR4S/My +AfXQAo6RC34g+AyCMUfsvp4D+BXIMPgvvvxLhmMSqkH0eqAVuF5aFlRrx1lYgduwLbE 72/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :user-agent:organization:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=l2SNgWKCWUDJgJwbACASdum/uhz9bDzXvcXD0P7rOIo=; b=H2nLu1D1m5q1gKVuPCUQEeg8l4vM4QxKqszTy1QNE5PjyC97b1xnKkSxPgu/5DG1NE 7Qnqi4yPBsx0qmCQRvW8lEkgRXK98mPjaMw3mpwUjeHeA5CStDDKZHPNji/xIqQSaYzP 18FFnSZNJqHGiPbum3HK9DXIpKGgOCEdL2cLcMgnDVTjFHdkmycQbRMU4hroobLBvsPq LglKYl/yVT19EmTpc8musV0+DH44Ne6G4DIkYP/BjuR4x1VJTZvyqPwzZwM5CR4FdaBo yRAsPXPJOz4cQ24IATXvwKbHDrsjV7M4e+nhvG1gqskgAXKQGfTE5YeL+lk96mJ6iEJj Tg1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rqYsMPf9; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f7-20020a056402354700b004573107a5basi26936406edd.352.2022.10.23.02.35.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 02:35:41 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rqYsMPf9; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 411143858285 for ; Sun, 23 Oct 2022 09:35:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 411143858285 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666517740; bh=l2SNgWKCWUDJgJwbACASdum/uhz9bDzXvcXD0P7rOIo=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=rqYsMPf99LCQCGabQAZMySsi/exzErtQJqvunel+KTtQ2T+pJkraI+9WDsY2tqdxX 5wEvw8wn+EB4qdTHIcNR9jcDZ9kztZ2zmSbi7US6y01Y0MjnT8s29VPrayCGZkmx2r 7NQwB1VUsnr7q4hFHXXWtehCE/i1fSA+y6Kvv+uc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from fencepost.gnu.org (fencepost.gnu.org [IPv6:2001:470:142:3::e]) by sourceware.org (Postfix) with ESMTPS id BB6FE3858D1E for ; Sun, 23 Oct 2022 09:34:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BB6FE3858D1E Received: from [2a01:cb19:956:1b00:de41:a9ff:fe47:ec49] (helo=begin) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omXNg-0003vg-2w; Sun, 23 Oct 2022 05:34:56 -0400 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1omXNe-002spy-12; Sun, 23 Oct 2022 11:34:54 +0200 Date: Sun, 23 Oct 2022 11:34:54 +0200 To: gcc-patches@gcc.gnu.org Subject: [PATCH]: Fix static-pie on Hurd target Message-ID: <20221023093454.7et6anfgzksfssxg@begin> Mail-Followup-To: gcc-patches@gcc.gnu.org, bug-hurd@gnu.org, xry111@xry111.site References: <20220829003040.kfgr7epzzyavbsjm@begin> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220829003040.kfgr7epzzyavbsjm@begin> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Samuel Thibault via Gcc-patches From: Samuel Thibault Reply-To: Samuel Thibault Cc: bug-hurd@gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747470507182905392?= X-GMAIL-MSGID: =?utf-8?q?1747470507182905392?= When linking with -static-pie, we need to use rcrt0.o (and grcrt0.o for -pg). Also, set static:crt0.o before pie:Scrt1.o, otherwise -static -pie fails to link with Scrt1.o due to missing _DYNAMIC symbol. Also, -static-pie needs crtbeginS.o (otherwise it contains a relocation in read-only .text). And eventually, when HAVE_LD_PIE is not defined, there is no reason to include the pie case gcc/ChangeLog * gcc/config/i386/gnu.h (STARTFILE_SPEC): Add static-pie cases and fix -static -pie case. --- gcc/config/i386/gnu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/config/i386/gnu.h b/gcc/config/i386/gnu.h index fb8d69a97d8..7d7bfa7da7b 100644 --- a/gcc/config/i386/gnu.h +++ b/gcc/config/i386/gnu.h @@ -27,12 +27,12 @@ along with GCC. If not, see . #undef STARTFILE_SPEC #if defined HAVE_LD_PIE #define STARTFILE_SPEC \ - "%{!shared: %{pg|p|profile:%{static:gcrt0.o%s;:gcrt1.o%s};pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}} \ - crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" + "%{!shared: %{pg|p|profile:%{static-pie:grcrt0.o%s;static:gcrt0.o%s;:gcrt1.o%s};static-pie:rcrt0.o%s;static:crt0.o%s;pie:Scrt1.o%s;:crt1.o%s}} \ + crti.o%s %{static:crtbeginT.o%s;shared|pie|static-pie:crtbeginS.o%s;:crtbegin.o%s}" #else #define STARTFILE_SPEC \ "%{!shared: %{pg|p|profile:%{static:gcrt0.o%s;:gcrt1.o%s};static:crt0.o%s;:crt1.o%s}} \ - crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" + crti.o%s %{static:crtbeginT.o%s;shared:crtbeginS.o%s;:crtbegin.o%s}" #endif #ifdef TARGET_LIBC_PROVIDES_SSP