]> git.ipfire.org Git - thirdparty/systemd.git/commit
elf2efi: Rework ELF section conversion
authorJan Janssen <medhefgo@web.de>
Thu, 28 Sep 2023 14:09:42 +0000 (16:09 +0200)
committerJan Janssen <medhefgo@web.de>
Fri, 29 Sep 2023 14:56:30 +0000 (16:56 +0200)
commit142f0c61a37091e233b80f02375cff1114dab24a
treea37a48728a74dc935cd71af34f054099a0fa185a
parent9551aa707d464335a801719ed72701a79e8106fd
elf2efi: Rework ELF section conversion

The main reason we need to apply a whole lot of logic to the section
conversion logic is because PE sections have to be aligned to the page
size (although, currently not even EDK2 enforces this). The process of
achieving this with a linker script is fraught with errors, they are a
pain to set up correctly and suck in general. They are also not
supported by mold, which requires us to forcibly use bfd, which also
means that linker feature detection is easily at odds as meson has a
differnt idea of what linker is in use.

Instead of forcing a manual ELF segment layout with a linker script we
just let the linker do its thing. We then simply copy/concatenate the
sections while observing proper page boundaries.
Note that we could just copy the ELF load *segments* directly and
achieve the same result. Doing this manually allows us to strip sections
we don't need at runtime like the dynamic linking information (the
elf2efi conversion is effectively the dynamic loader).

Important sections like .sbat that we emit directly from code will
currently *not* be exposed as individual PE sections as they are
contained within the ELF segments. A future commit will fix this.
meson.build
src/boot/efi/log.c
src/boot/efi/meson.build
src/boot/efi/util.c
src/boot/efi/util.h
tools/elf2efi.lds [deleted file]
tools/elf2efi.py