public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/boot: Discard .interp sections
@ 2026-04-07 23:39 Nam Le
  2026-04-08  9:52 ` Borislav Petkov
  0 siblings, 1 reply; 11+ messages in thread
From: Nam Le @ 2026-04-07 23:39 UTC (permalink / raw)
  To: tglx, mingo; +Cc: linux-kernel, x86, Nam Le

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-04-08 17:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07 23:39 [PATCH] x86/boot: Discard .interp sections Nam Le
2026-04-08  9:52 ` Borislav Petkov
2026-04-08  9:58   ` Segher Boessenkool
2026-04-08 10:09     ` Borislav Petkov
2026-04-08 12:01       ` Nam Le
2026-04-08 12:49         ` Borislav Petkov
2026-04-08 13:30           ` Nam Le
2026-04-08 15:21             ` Borislav Petkov
2026-04-08 15:57               ` Nam Le
2026-04-08 17:20                 ` Borislav Petkov
2026-04-08 12:09       ` Michael Matz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox