Commit graph

14 commits

Author SHA1 Message Date
Mike Yuan ced3e6bc0e elf2efi: remove outdated comment mentioning linker script
Follow-up for 142f0c61a3
2023-12-10 12:50:14 +00:00
Jan Janssen 823bf39a49 elf2efi: Add GNU_RELRO support 2023-09-29 17:05:11 +02:00
Jan Janssen 898e9edc46 elf2efi: Add --copy-sections option
This makes the special PE sections available again in our output EFI
images.

Since the compiler provides no way to mark a section as not allocated,
we use GNU assembler syntax to emit the sections instead. This ensures
the section data isn't emitted twice as load segments will only contain
allocating input sections.
2023-09-29 16:56:30 +02:00
Jan Janssen 7d6fd7f099 elf2efi: Add next_section_address helper 2023-09-29 16:56:30 +02:00
Jan Janssen 5713c50d84 elf2efi: Check ELF image base if possible 2023-09-29 16:56:30 +02:00
Jan Janssen 142f0c61a3 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.
2023-09-29 16:56:30 +02:00
Mike Yuan 1365355d14 elf2efi: fix a typo 2023-09-21 19:16:11 +02:00
Frantisek Sumsal 79f902eb09 Add .pylintrc to globally suppress warnings we don't really care about
Also, drop the respective disable directives from existing files.
2023-08-10 18:13:29 +02:00
Jan Janssen ee91e06a58 elf2efi: Fix header size calculation
The PE header size calculation failed to take the PE magic and coff
header size into account, which will lead to header truncation if we are
writing only 5 sections.
2023-07-30 21:31:38 +02:00
Daan De Meyer 09444a2e76 elf2efi: Make compatible with python 3.6 again
CentOS 8 ships python 3.6 so let's try and stay compatible with that
since the only feature we're using that requires python 3.9 is the
streamlined type annotations which are trivial to convert back to
the older stuff to stay compatible with python 3.6.
2023-07-14 14:41:19 +02:00
Luca Boccassi e18e3c4305 elf2efi: add parameter to increase reserved space for headers
When building a minimal empty addon it would not have enough
space to append sections. Add an option that will later be
used to reserve enough space.
2023-05-24 11:06:36 +01:00
Jan Janssen ab7d54b9dd elf2efi: Do not emit an empty relocation section
At least shim will choke on an empty relocation section when loading the
binary. Note that the binary is still considered relocatable (just with
no base relocations to apply) as we do not set the
IMAGE_FILE_RELOCS_STRIPPED DLL characteristic.
2023-05-23 22:47:28 +01:00
Jan Janssen 31ffb6b183 boot: Add RISCV32 and LoongArch support
This is completely untested, but should work in theory, as it's just
adding a couple defines according to the specs.
2023-03-10 11:41:08 +01:00
Jan Janssen 2afeaf1675 boot: Bring back bootloader builds
This adds back sd-boot builds by using meson compile targets directly.
We can do this now, because userspace binaries use the special
dependency that allows us to easily separate flags, so that we don't
pass anything to EFI builds that shouldn't be passed.

Additionally, we pass a bunch of flags to hopefully disable/override any
distro provided flags that should not be used for EFI binaries.

Fixes: #12275
2023-03-10 11:41:08 +01:00