efi_loader: Move .dynamic out of .text in EFI
authorSam Edwards <cfsworks@gmail.com>
Sat, 15 Mar 2025 22:18:10 +0000 (15:18 -0700)
committerTom Rini <trini@konsulko.com>
Wed, 2 Apr 2025 20:33:50 +0000 (14:33 -0600)
commit1755071db7d95fa0b95e9f9bedd3785e2abc10cf
tree5f270cea48233ca82440cbae0386ed794b5d2c97
parentf692540b24a7775e43f1d315d3e13a5d3ed21dd4
efi_loader: Move .dynamic out of .text in EFI

EFI applications need to be relocatable. Ordinarily, this is achieved
through a PE-format .reloc section, but since that requires toolchain
tricks to achieve, U-Boot's EFI applications instead embed ELF-flavored
relocation information and use it for self-relocation; thus, the
.dynamic section needs to be preserved.

Before this patch, it was tacked on to the end of .text, but this was
not proper: A .text section is SHT_PROGBITS, while the .dynamic section
is SHT_DYNAMIC. Attempting to combine them like this creates a section
type mismatch. While GNU ld doesn't seem to complain, LLVM's lld
considers this a fatal linking error.

This patch moves .dynamic out to its own section, so that the output ELF
has the correct types. (They're all mashed together when converting to
binary anyway, so this patch causes no change in the final .efi output.)

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
lib/efi_loader/elf_efi.ldsi