LAKITU: grub: Strip .interp from diskboot
boot.img and diskboot.img both need to be smaller than 512 bytes. Clang
inserts a .interp section into these binaries, which brings the binary
size over 512 bytes. Let's strip the .interp section since it is not
needed and breaks grub-install.
We cannot remove the .interp section from all build targets of type
"image" in grub, because some images are very much not
position-independent. In particular, the LZMA decompressor relies on the
symbol "L_decompressor_end" referencing the end of the LZMA decompressor
image in memory. If we remove the .interp section after linking, the
value for "L_decompressor_end" that was filled in everywhere in the
program by the linker will be invalid, because the "L_decompressor_end"
value initially accounted for the .interp section. In this case, we can
leave the .interp section in to keep the program correct. The LZMA
decompressor also has no 512 byte requirement, so we don't need to
remove .interp from it.
After we land the new ChromeOS version in COS, I'll follow up with
ChromeOS on how best to upstream this fix. It might make sense to update
clang/lld to not insert .interp if -nostdlib is provided.
TEST=local BE run
Reviewed-by: Robert Kolchmeyer <firstname.lastname@example.org>
Tested-by: Robert Kolchmeyer <email@example.com>
3 files changed