Index | Thread | Search

From:
Jeremie Courreges-Anglas <jca@wxcvbn.org>
Subject:
ld.lld: fix .note.gnu.property edge case
To:
tech@openbsd.org
Date:
Wed, 7 Oct 2026 22:41:11 +0200

Download raw body.

Thread
  • Jeremie Courreges-Anglas:

    ld.lld: fix .note.gnu.property edge case

Some ports using ld -b binary to embed data in object files are
visibly broken on riscv64, eg:

  http://build-failures.rhaalovely.net/riscv64/2026-09-27/databases/postgresql-pllua.log

Turns out the issue is also present on i386/amd64/arm64:

  Displaying notes found in: .note.gnu.property
    Owner                Data size        Description
    GNU                  0x00000010       NT_GNU_PROPERTY_TYPE_0 (property note)
      Properties:    x86 feature: IBT, SHSTK, <unknown flags: 0xfffffffc>

  Displaying notes found in: .note.gnu.property
    Owner                Data size        Description
    GNU                  0x00000010       NT_GNU_PROPERTY_TYPE_0 (property note)
      Properties:    aarch64 feature: BTI, PAC, GCS, <unknown flags: 0xfffffff8>

but there ld.lld has less checks for incompatible features.  The issue
is simple, ctx.arg.andFeatures is initialized to (uint32_t)-1 which
doesn't work well if no ELF files are used as input.

Cheap fix below, ok?


Index: Driver.cpp
===================================================================
RCS file: /cvs/src/gnu/llvm/lld/ELF/Driver.cpp,v
diff -u -p -r1.26 Driver.cpp
--- Driver.cpp	20 Aug 2026 14:39:18 -0000	1.26
+++ Driver.cpp	7 Oct 2026 19:30:12 -0000
@@ -2974,7 +2974,7 @@ static void readSecurityNotes(Ctx &ctx) 
       ctx.arg.emachine != EM_AARCH64 && ctx.arg.emachine != EM_RISCV)
     return;
 
-  ctx.arg.andFeatures = -1;
+  ctx.arg.andFeatures = ctx.objectFiles.empty() ? 0 : -1;
 
   StringRef referenceFileName;
   if (ctx.arg.emachine == EM_AARCH64) {


-- 
jca