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: 59320 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 1A5AB3858C62 for ; Sun, 23 Oct 2022 09:35:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A5AB3858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666517726; 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=MVd7iVfeCQ3B4Mx3Bo5iyQ4rSHO5lX3Ph1R0pUsQ69gnfbvm4pNdqLsOmusBMuX4w +Zr+SLySnFkaDN6ffeD1ycoGsKbfNt+fQ4u25YYz80UBiLPKF7ZHSL1fS5ye0dZAPH OsAO0ayzN7V/fe37u7QJhjh7f5jhVIbk/wTIAEdY= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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