[llvm-dev] Linking Linux kernel with LLD
George Rimar via llvm-dev
llvm-dev at lists.llvm.org
Thu Feb 2 06:27:31 PST 2017
> I still didn't do anything with "Setup too big!" problem, just commented out the assert.
>
So I investigated this today.
(It is about https://github.com/torvalds/linux/blob/master/arch/x86/boot/setup.ld#L52)
Script ends with:
.bss :
{
__bss_start = .;
*(.bss)
__bss_end = .;
}
. = ALIGN(16);
_end = .;
/DISCARD/ : { *(.note*) }
. = ASSERT(_end <= 0x8000, "Setup too big!");
And what LLD do here. It makes command list to be:
Place .bss, Place non-allocated orphans, Assign _end.
So places command "_end = " after commands for orphan sections.
There are plenty of them: debug_*, .comment, .shstrtab, .symtab, .strtab.
And _end value is set to not what expected finally.
Fix on script side can be very easy, just add one more line before "/DISCARD/":
.debug_info : { *(.debug_info) }
That way LLD will attach that non-allocated orphans after .debug_info section.
And _end will be calculated earlier and be correct.
I just had a quick look about how to fix that. We have shouldSkip(const BaseCommand &Cmd) with comment:
// We don't want to go over alignments, since doing so in
// rx_sec : { *(rx_sec) }
// . = ALIGN(0x1000);
// /* The RW PT_LOAD starts here*/
// rw_sec : { *(rw_sec) }
// would mean that the RW PT_LOAD would become unaligned.
I think probably fix could be to allow go over alignments if we placing non-allocatable orphans,
them are placed the last and should not cause such issue to happen.
George.
More information about the llvm-dev
mailing list