From patchwork Thu Jul 2 14:38:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Turney X-Patchwork-Id: 138339 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EBCAD4B9DB44 for ; Thu, 2 Jul 2026 14:39:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBCAD4B9DB44 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from btprdrgo004.btinternet.com (btprdrgo004.btinternet.com [65.20.50.180]) by sourceware.org (Postfix) with ESMTP id ED0404BA902C for ; Thu, 2 Jul 2026 14:38:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED0404BA902C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dronecode.org.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED0404BA902C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=65.20.50.180 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783003113; cv=none; b=hjIQdmnhuCXXho2HbqYSYoAmuR2tum87KRs9PHqijxnu+NgThP2oZj4JNEsdxWGJX5gubXQ2DwhmjKlQhfIsxRKNPasd++1MBHT+PLaVe9SgUeeX6TV8Uf+LxL5dQ6xyLuVq9OcEO+P93kKQYPAZLnCmMX7oMRCeWfnUC+yX+A8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783003113; c=relaxed/simple; bh=kkhkj4SgRLcUrNBYLuR++a4MlPE9zxbxsPntnCXS0h4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=wBmRkzL+VVDbrKdXZ3w9+ZXYhiMPIw9rzh2wJcH5fn9B0qX2oNmQ8rQE/9OK8arbKzlbnTXvk7YGgjVIFePLpmHxgioAvSXsYROSCSz8vPwaIUj3qnuPs4F0OueYzUVQ4MpYnxsHzp22Khp+dFzMsQ0jpBDhphM70hW/2Wgznvo= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED0404BA902C Authentication-Results: btinternet.com; auth=pass (LOGIN) smtp.auth=jonturney@btinternet.com X-SNCR-Rigid: 69E78B8005D08E69 X-Originating-IP: [62.56.66.111] X-OWM-Source-IP: 62.56.66.111 X-OWM-Env-Sender: jon.turney@dronecode.org.uk X-VadeSecure-score: verdict=clean score=49/300, class=clean X-RazorGate-Vade: dmFkZTFpApZPKQAj1WKyFtFea+peB7V1wBAkh5/yPcwm6xpMlbBF9dKR7ykJkGUNl7uLllFbSi2W6DCMx8drEo3EuAWz7DBjJ3ke373f9Vhuy71lOubgK79mcRSy+j9S9I7gfl/Ea2SCINL9mHtT549xukI8tK+o2Ld7W2ZjkzaSD35wVBpGMnyniy2b1s8CHCqTV5VOi6f2xVuxRK927/h83gf6zRVD4WtXwrRgbtZAT6x7OIimbG1elmUmXzvsorYvfwCFkB/BEKJ4RdAPztiXUmgj+P0bzg02lPjj1paWkgzHq/XC4Rr/eHqmpkObqDVwXRI7/M1+JTtjqf4eRDSQi4XEfJNxdhO4DF/brrzpRVyya8zwTJSB3q2qOUhBM1cmWRFkvuBriKxLoptS3j8Jl/8pQCCwR9ezQcGlcuwzAsVmNXdsZK5y0G+ddVNwuF6wSk5CYVqkF5dcCXw/+Gdlrave9dAwPmQ3hH0mARxAU+d/8h2yd7k+kTGLKxx9cVAfp8cuKqgd0qRvbD73ExgGn+/nywPkxypO9kdBizh5kjjjM1pfQpbcN2BuPGtD3XtvGgR9KxrBqq+nBmhLm4+EZ7cQ40ItJoY0BwbCP3XJEBldyQQ3PKfJrZzZuXAIOInedywFQaBmTa3j4/O8tBTrj94L2dIF8JpN8zYT5D8VWsMQXg X-RazorGate-Vade-Verdict: clean 49 X-RazorGate-Vade-Classification: clean Received: from tambora (62.56.66.111) by btprdrgo004.btinternet.com (authenticated as jonturney@btinternet.com) id 69E78B8005D08E69; Thu, 2 Jul 2026 15:38:27 +0100 From: Jon Turney To: binutils@sourceware.org Cc: Jon Turney , mingw-w64-public@lists.sourceforge.net Subject: [PATCH] ld: pep: Stop emitting reference to the pseudo-relocator function Date: Thu, 2 Jul 2026 15:38:15 +0100 Message-ID: <20260702143816.23422-1-jon.turney@dronecode.org.uk> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_PBL, SPF_HELO_PASS, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org The exported _pei386_runtime_relocator function currently only exists as a non-functional stub in the Cygwin runtime, merely to satisfy this reference synthesized in ld [1]. The function still has contents in the MinGW runtime [2], but is already referenced by being explcitly called at crt startup/dll load. We'd like to drop the (slightly confusing) stub from the Cygwin runtime, especially in possible future architectures (e.g aarch64), where backwards compatibilty concerns don't exist. So, for PE+ targets, stop explicitly emitting a reference to _pei386_runtime_relocator in the linker. (The archeological record is unclear why this functionality exists in ld. Since --enable-runtime-pseudo-reloc-v1 exists for 32-bit PE arches, and out of an abundance of caution, keep emitting it for those targets (i.e. i386) where it conceivably might still be needed or useful with an ancient runtime.) Cc'ed to mingw-w64-public list. [1] https://cygwin.com/cgit/newlib-cygwin/tree/winsup/cygwin/lib/pseudo-reloc-dummy.c [2] https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/crt/pseudo-reloc.c#l479 Signed-off-by: Jon Turney Cc: mingw-w64-public@lists.sourceforge.net --- ld/pe-dll.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ld/pe-dll.c b/ld/pe-dll.c index f43bd14896e..be5722fa8ad 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -170,7 +170,9 @@ static struct bfd_section *edata_s, *reloc_s; static unsigned char *edata_d, *reloc_d; static unsigned char *reloc_d = NULL; static size_t edata_sz, reloc_sz = 0; +#ifndef pe_use_plus static int runtime_pseudo_relocs_created = 0; +#endif static bool runtime_pseudp_reloc_v2_init = false; typedef struct @@ -1773,7 +1775,7 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info) /* This can happen for example when LTO has eliminated all code. */ if (total_relocs == 0) return; - + /* At this point, we have total_relocs relocation addresses in reloc_addresses, which are all suitable for the .reloc section. We must now create the new sections. */ @@ -2798,6 +2800,7 @@ make_runtime_pseudo_reloc (const char *name ATTRIBUTE_UNUSED, return abfd; } +#ifndef pe_use_plus /* .section .rdata .rva __pei386_runtime_relocator */ @@ -2841,6 +2844,7 @@ pe_create_runtime_relocator_reference (bfd *parent) bfd_make_readable (abfd); return abfd; } +#endif void pe_create_import_fixup (arelent *rel, asection *s, bfd_vma addend, char *name, @@ -2894,11 +2898,15 @@ pe_create_import_fixup (arelent *rel, asection *s, bfd_vma addend, char *name, link_info.output_bfd); add_bfd_to_link (b, bfd_get_filename (b), &link_info); + /* We think this is entirely useless, but emit a reference to the + relocator on the i386 target, just in case. */ +#ifndef pe_use_plus if (runtime_pseudo_relocs_created++ == 0) { b = pe_create_runtime_relocator_reference (link_info.output_bfd); add_bfd_to_link (b, bfd_get_filename (b), &link_info); } +#endif } else if (addend != 0)