Re: [PATCH] x86/boot: Discard .interp sections

From: Borislav Petkov

Date: Wed Apr 08 2026 - 05:52:54 EST


On Wed, Apr 08, 2026 at 12:39:57AM +0100, Nam Le wrote:
> 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)
> }
>
> /*

Sounds to me like you're shooting yourself in the foot on purpose:

--dynamic-linker=value
Specify the dynamic linker to be used for a dynamically linked executable.
This is recorded in an ELF segment of type PT_INTERP.

So don't do that then.

:-)

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette