From patchwork Fri Apr 5 23:42:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 88122 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 D53733858C41 for ; Fri, 5 Apr 2024 23:43:19 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 435633858D1E for ; Fri, 5 Apr 2024 23:43:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 435633858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 435633858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712360581; cv=none; b=FOmT2H5nhKD6BWKmqc0W3qhLUdMce51xdkB8jcjCiYepOPU+HHCXUq10Tbzz3nJJjJRueXOCGoy+xuRP5yrDnS0HuLihIvKRHw6G+oaaXHaiBwXkSz+AsD6u023RaUm/1TG57QVv36QbwdqGT5s6oZfAFOdDSm5vw0W+TrL0ujQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712360581; c=relaxed/simple; bh=KK7/N6i7o928Wxk9GP+a1fL64tdYR0ujLl0TrMb68yg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lre4H8OZraeuQwC3UcIapD5Ek+H1f/qN28ac5KRaY/rOgw7NE1UFfjmpRbDejEK2hddFfa9W7jYK6d1u9jQP5ZhIqs4Ig3THOc3lnp6b3MD35mRUZ9mIcTBm9PnaGaQtBZNHU1155I7ZUnU9kHC2UCfJUwmA9+Qj+nXjVeCgqn0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6eced6fd98aso2220800b3a.0 for ; Fri, 05 Apr 2024 16:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712360579; x=1712965379; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=ZKUtlkGKdcRmCppyLbC8uevCXmVl4UdfOiKc/G/0U3k=; b=PwLdiVAbyf6C1trs0d9wnnfh7zseIDeiILDM7Qvcv36F3slfKDoK2qY11iQvQ1ohYb vRuYW69Wx/mhWR/UC7RyfsNOcxpr9W0HDMdu/TkprtE1JZpslKijfLxUrwB1mBmnAkiI ltqrzMCE3SCopAVt3VqN8Jygkg90JzEy1I87HX8zzsdj2uT39zAz5hcvE8f9t0ylyvmf /6oGX7sAyCLBrQk7X01LqyiimUjif5gar0MtCQy6JzI67/mrx/FfupK8tJ4CvlFV5I8W fMMJVHqXMofaB3h60L2gdzVQ+9WlV4ynVFILE7GMCh1fT6yt9xLfapgzcgONpWhafyOc ytFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712360579; x=1712965379; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZKUtlkGKdcRmCppyLbC8uevCXmVl4UdfOiKc/G/0U3k=; b=QuvxHR+Bp/XxMHeHfrg3VkQnXQryJfASGM3Ywj7j4Y6HRVm5vCReupKQB6YMJETv00 2hJLjCyt/on8aaTjuYE6Ra4+1nBEs25iS1Yo3/s9+i2a9a016I5L/YaPeWCtHm2UbYzL B40XuDFl2lrttNvzxWOOeaYaptc8bPxzAdUdczBYQfka+W33L/UWgUbSG9x+xSN4pENc J1t0vTHB+XGd0BVP2O0oNnXJgnTIQyqufVpCZZCA0XMzsGr2/nMZPziNTLQiV6a37PiC 5j+aVaAKZCA7uXPcjcUG0DBmn5p8yat8uJ3OVIJh0wswo3MKAQZuGs3yGMFyaqfSRbaH 7Vag== X-Gm-Message-State: AOJu0Yyu/mp5Z1Erm81pwDZAjwtfWut6yYDAqmdndsVOq96KAI6TUV08 Q/ToiLMKAVzrtUXV9nFm05K3oBytgim6boFte5SV/C0cI3+Lz9YPprABBqLy X-Google-Smtp-Source: AGHT+IFXt72Y3c/3yegTzitKj6yn1g1Dy2UWBYVBgrVr0FtsK6Svg82QLz85QryV9nNIoEGGdlVuGQ== X-Received: by 2002:aa7:8893:0:b0:6e5:faca:3683 with SMTP id z19-20020aa78893000000b006e5faca3683mr3569626pfe.26.1712360578826; Fri, 05 Apr 2024 16:42:58 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.56.169.48]) by smtp.gmail.com with ESMTPSA id i18-20020a056a00005200b006ecfd2ad989sm2083759pfk.169.2024.04.05.16.42.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 16:42:58 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 14B5D7400AC for ; Fri, 5 Apr 2024 16:42:57 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH] Use crtbeginT.o and crtend.o for non-PIE static executables Date: Fri, 5 Apr 2024 16:42:57 -0700 Message-ID: <20240405234257.2040273-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3018.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org When static PIE is enabled by default, we shouldn't use crtbeginS.o and crtendS.o for non-PIE static executables. Check $($(@F)-no-pie) to use crtbeginT.o and crtend.o to create non-PIE static executables. Reviewed-by: Sunil K Pandey --- Makeconfig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makeconfig b/Makeconfig index 85e00cef94..e583765712 100644 --- a/Makeconfig +++ b/Makeconfig @@ -705,13 +705,15 @@ endif +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o` +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o` # Variants of the two previous definitions for statically linking programs. +static-prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o` +static-postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` ifeq (yes,$(enable-static-pie)) # Static PIE must use PIE variants. -+prectorT = $(+prectorS) -+postctorT = $(+postctorS) ++prectorT = $(if $($(@F)-no-pie),$(static-prector),$(+prectorS)) ++postctorT = $(if $($(@F)-no-pie),$(static-postctor),$(+postctorS)) else -+prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o` -+postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` ++prectorT = $(static-prector) ++postctorT =$(static-postctor) endif csu-objpfx = $(common-objpfx)csu/ elf-objpfx = $(common-objpfx)elf/