Re: [PATCH] x86/boot: explicitly place .eh_frame after .rodata

From: Nick Desaulniers
Date: Mon Nov 04 2019 - 12:55:02 EST


On Mon, Nov 4, 2019 at 1:03 AM Ilie Halip <ilie.halip@xxxxxxxxx> wrote:
>
> When using GCC as compiler and LLVM's lld as linker, linking
> setup.elf fails:
> LD arch/x86/boot/setup.elf
> ld.lld: error: init sections too big!
>
> This happens because ld.lld has different rules for placing
> orphan sections (i.e. sections not mentioned in a linker script)
> compared to ld.bfd.
>
> Particularly, in this case, the merged .eh_frame section is
> placed before __end_init, which triggers an assert in the script.
>
> Explicitly place this section after .rodata, in accordance with
> ld.bfd's behavior.
>
> Signed-off-by: Ilie Halip <ilie.halip@xxxxxxxxx>
> Link: https://github.com/ClangBuiltLinux/linux/issues/760

Thanks for the patch Ilie! Quoting Fangrui:

"This is related to the orphan placement rule. An orphan section is a
section that is not described by the linker script. The orphan section
placement is not well documented and the rule used by ld.bfd is not
very clear. Being more explicit is the way to go."
https://github.com/ClangBuiltLinux/linux/issues/760#issuecomment-549064237

Looks like Clang doesn't even produce a .eh_frame section.


> ---
> 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 0149e41d42c2..4e02eab11b59 100644
> --- a/arch/x86/boot/setup.ld
> +++ b/arch/x86/boot/setup.ld
> @@ -25,6 +25,7 @@ SECTIONS
>
> . = ALIGN(16);
> .rodata : { *(.rodata*) }
> + .eh_frame : { *(.eh_frame*) }

The wildcard on the end can be left off; we don't need to glob
different sections with the prefix `.eh_frame`. Would you mind
sending a V2 with that removed? (I know .rodata and .data in this
linker script globs, but they may actually be putting data in separate
sections which we want to munge back together; certainly for
-fdata-sections).

>
> .videocards : {
> video_cards = .;
> --
> 2.17.1
>


--
Thanks,
~Nick Desaulniers