| Message ID | 20260622033926.220317-1-peter0x44@disroot.org |
|---|---|
| Headers |
Return-Path: <binutils-bounces~patchwork=sourceware.org@sourceware.org> 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 F2B934BA23EC for <patchwork@sourceware.org>; Mon, 22 Jun 2026 03:40:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F2B934BA23EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1782099632; bh=fd6F1gg1A9EFq+ForSH7oAQebGwomR7e2ghB25mXQ2Q=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=wc0EIJ5aimylVIg3XPLGQmVyFcW4pLKvIf7LV6PGaJn7bXdwnYMxm20Y5uKTPGUPS vZ+uzFDqB4V4s5c3uaCJbJGPt4vOe6zNosL6GzxH3IhMeE7zdVRyb6GdVUOxFs2DpC sY18JtoyO8Ocu/fPQ4kXfw5SVQRdNE5/8Lvd3cAk= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by sourceware.org (Postfix) with ESMTPS id 7184B4BA2E0C for <binutils@sourceware.org>; Mon, 22 Jun 2026 03:39:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7184B4BA2E0C ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7184B4BA2E0C ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782099596; cv=none; b=NDday07yqW/SgmoLvVzcHkK+BsQMubBC/p8mBNmuWH5XFB38dNF9AHkPmROD18rRCqDIJ4PWeoQmfDCf9rHQj4UBXGa9lCoEeNzksTxQWY8pTHSTdInR4MDB60wKMZq1ccR9AqyIxAQhqnQRuf4WyKPZ5ky45JdfLauko+oRXLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782099596; c=relaxed/simple; bh=t67BHQCr45t46t6Tx5pVi3vkTxIroM/mrfizB+hKFxo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RSoCCMfeYHNH0raH4K7YPw8+jTWYFEGnsHJx3qHCmcO9cIP8jE6vmsf4ENXEMICTW3qVnrRvoFo9+yld3AvlWB/M6yw9NNpYqLqZWcaiDjaPSL91Wy6DcISyr70mduxCUn6r/p7FGdqyjhpcynbq+pqWEmokxvMTIxleWqu6dhA= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=disroot.org header.i=@disroot.org header.a=rsa-sha256 header.s=mail header.b=bDuU9uxr DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7184B4BA2E0C Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id DACE327561; Mon, 22 Jun 2026 05:39:54 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id nlvkJhtLuYku; Mon, 22 Jun 2026 05:39:54 +0200 (CEST) To: binutils@sourceware.org Cc: amodra@gmail.com, jbeulich@suse.com, martin@martin.st, Peter Damianov <peter0x44@disroot.org> Subject: [PATCH v2 0/3] PE-COFF weak external fixes Date: Sun, 21 Jun 2026 23:39:23 -0400 Message-ID: <20260622033926.220317-1-peter0x44@disroot.org> In-Reply-To: <20260530191522.57144-1-peter0x44@disroot.org> References: <20260530191522.57144-1-peter0x44@disroot.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, 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 <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> From: Peter Damianov via Binutils <binutils@sourceware.org> Reply-To: Peter Damianov <peter0x44@disroot.org> Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org |
| Series | PE-COFF weak external fixes | |
Message
Peter0x44
June 22, 2026, 3:39 a.m. UTC
This is v2 of the PE-COFF weak external fixes. The series fixes two
weak external resolution bugs in the BFD linker and adds tests covering
the weak/strong interaction matrix.
Changes from v1:
* Drop unnecessary casts from bfd_hash_allocate results.
* Make the null-fallback handling in patch 2 more explicit: a COFF
weak declaration uses the null symbol as its fallback, which appears
in the hash table as a defined absolute symbol with value zero. The
updated code now treats that case as unresolved on both the old and
incoming fallback sides.
Alan reported two test failures with Ubuntu's x86_64-w64-mingw32 cross
compiler. I reproduced that as a testsuite setup issue rather than a
linker regression: that compiler is configured with --with-ld=/usr/bin/
x86_64-w64-mingw32-ld and ignores the testsuite's -B path, so the new
tests were being linked with the installed linker instead of the just
built one.
For my GitHub Actions coverage I worked around that by replacing the
disposable runner's hardwired MinGW ld/as entry points with symlinks to
the just-built tools before running the DejaGnu tests:
https://github.com/Peter0x44/binutils-gdb/blob/30db88d4da5db6b3ddcfc745a8438ce8d1f600fe/.github/workflows/ld-pe-tests.yml#L126-L133
A successful run using that workaround is here:
https://github.com/Peter0x44/binutils-gdb/actions/runs/27926498479/job/82629812736
Peter Damianov (3):
PE-COFF: Fix weak external symbol resolution when strong undef is seen
first
PE-COFF: Prefer weak external with defined fallback over null fallback
ld/testsuite: Add comprehensive PE COFF weak external tests
bfd/cofflink.c | 137 ++++++++++++++++--
ld/testsuite/ld-pe/pe-compile.exp | 88 +++++++++++
.../ld-pe/weak-ext-add1-weak-chained.c | 13 ++
ld/testsuite/ld-pe/weak-ext-add2.c | 8 +
ld/testsuite/ld-pe/weak-ext-dummy.c | 5 +
ld/testsuite/ld-pe/weak-ext-expected1.c | 1 +
.../ld-pe/weak-ext-expected3-add1-weak.c | 9 ++
ld/testsuite/ld-pe/weak-ext-expected3.c | 1 +
ld/testsuite/ld-pe/weak-ext-expected5.c | 1 +
ld/testsuite/ld-pe/weak-ext-main-weak-def.c | 26 ++++
ld/testsuite/ld-pe/weak-ext-main-weak.c | 22 +++
ld/testsuite/ld-pe/weak-ext-main.c | 21 +++
12 files changed, 319 insertions(+), 13 deletions(-)
create mode 100644 ld/testsuite/ld-pe/weak-ext-add1-weak-chained.c
create mode 100644 ld/testsuite/ld-pe/weak-ext-add2.c
create mode 100644 ld/testsuite/ld-pe/weak-ext-dummy.c
create mode 100644 ld/testsuite/ld-pe/weak-ext-expected1.c
create mode 100644 ld/testsuite/ld-pe/weak-ext-expected3-add1-weak.c
create mode 100644 ld/testsuite/ld-pe/weak-ext-expected3.c
create mode 100644 ld/testsuite/ld-pe/weak-ext-expected5.c
create mode 100644 ld/testsuite/ld-pe/weak-ext-main-weak-def.c
create mode 100644 ld/testsuite/ld-pe/weak-ext-main-weak.c
create mode 100644 ld/testsuite/ld-pe/weak-ext-main.c