From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=l2SNgWKCWUDJgJwbACASdum/uhz9bDzXvcXD0P7rOIo=; b=KlySetl+VjDDN3Qirkt6 3hIwZQOdHaAQxFS5DPkUecX8Ez4ZJkEOnn7+bF6D4A8TLoQpGWqXqFeoVfmGQ/9oQIVFB89+ANgNT Nrw8Jt/EK6gJROVmXw5m4XoLCbux0yx6UcU0Iw3wkc8rJsuETctL5JCZY63JRXvY8N082D6jWAJ40 kXmV2NzcjMfF66i/T6pc2H/af5W8wo4zPMyZWK3/QLz9PpNr0q+3d7NjD0JK5Z3MvD36A3ymDTBrF GjLd91nS5PB6a5Qg7kSrB9RviWmQbAbbi9kBVHXxauRj+UBwzl0AqooPldZB4huLFVxqaXGD1tBxz LXPRp6pPOPAidA==; 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 From: Samuel Thibault To: gcc-patches@gcc.gnu.org Cc: bug-hurd@gnu.org, xry111@xry111.site 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-Type: text/plain; charset=us-ascii 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 List-Id: 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