[PATCH] x86/boot: Discard .interp sections
From: Nam Le
Date: Tue Apr 07 2026 - 19:40:12 EST
With the --dynamic-linker flag added, either manually or via a
toolchain wrapper, the ld.lld linker generates a .interp section at
address 0x1f1 which is normally reserved for the hdr, causing an
assertion error to occur:
. = ASSERT(hdr == 0x1f1, "The setup header has the wrong offset!");
This does not happen with other linkers like ld.bfd.
We can see the difference by inspecting the generated .elf file:
ld.lld:
Section Headers:
[Nr] Name Type Addr Off Size
[ 1] .bstext PROGBITS 00000000 001000 0001ef
[ 2] .interp PROGBITS 000001ef 0011ef 000053
[ 3] .header PROGBITS 00000242 001242 00007d
ld.bfd:
Section Headers:
[Nr] Name Type Addr Off Size
[ 1] .bstext PROGBITS 00000000 001000 0001ef
[ 2] .header PROGBITS 000001ef 0011ef 00007d
[ 3] .entrytext PROGBITS 0000026c 00126c 000069
Adding .interp to the DISCARD section ensures it's not included in
the final .elf file.
Signed-off-by: Nam Le <lehoangnamtep@xxxxxxxxx>
---
arch/x86/boot/setup.ld | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/boot/setup.ld b/arch/x86/boot/setup.ld
index e1d594a60204..daffd876e94d 100644
--- a/arch/x86/boot/setup.ld
+++ b/arch/x86/boot/setup.ld
@@ -61,6 +61,7 @@ SECTIONS
/DISCARD/ : {
*(.note*)
+ *(.interp)
}
/*
--
2.53.0