summaryrefslogtreecommitdiff
path: root/tools/elf2efi.lds
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2023-02-27 16:54:48 +0100
committerJan Janssen <medhefgo@web.de>2023-03-10 11:41:08 +0100
commit2afeaf1675a6a68636be493a9461e72ce067db19 (patch)
tree671ea8c8c90db518a516f00e19da08b4a43b046d /tools/elf2efi.lds
parentdfca5587cf2032f9ad06041b93b0da5cb39b9989 (diff)
downloadsystemd-2afeaf1675a6a68636be493a9461e72ce067db19.tar.gz
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
Diffstat (limited to 'tools/elf2efi.lds')
-rw-r--r--tools/elf2efi.lds49
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/elf2efi.lds b/tools/elf2efi.lds
new file mode 100644
index 0000000000..eed9e279e9
--- /dev/null
+++ b/tools/elf2efi.lds
@@ -0,0 +1,49 @@
+SECTIONS {
+ /* We skip the first page because the space will be occupied by the PE headers after conversion. */
+ . = CONSTANT(MAXPAGESIZE);
+ .text ALIGN(CONSTANT(MAXPAGESIZE)) : {
+ *(.text .text.*)
+ }
+ .rodata ALIGN(CONSTANT(MAXPAGESIZE)) : {
+ *(.rodata .rodata.*)
+ *(.srodata .srodata.*)
+ }
+ .data ALIGN(CONSTANT(MAXPAGESIZE)) : {
+ *(.data .data.*)
+ *(.sdata .sdata.*)
+ *(.got .got.*)
+ *(.got.plt .got.plt.*)
+
+ /* EDK2 says some firmware cannot handle BSS sections properly. */
+ *(.bss .bss.*)
+ *(.sbss .sbss.*)
+ *(COMMON)
+ }
+
+ .sdmagic ALIGN(CONSTANT(MAXPAGESIZE)) : { *(.sdmagic) }
+ .osrel ALIGN(CONSTANT(MAXPAGESIZE)) : { *(.osrel) }
+ .sbat ALIGN(CONSTANT(MAXPAGESIZE)) : { *(.sbat) }
+
+ /* These are used for PE conversion and then discarded. */
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .dynamic : { *(.dynamic) }
+ .rel.dyn : { *(.rel.dyn) }
+ .rela.dyn : { *(.rela.dyn) }
+
+ /* These aren't needed and could be discarded. Just in case that they're useful to the debugger
+ * we keep them, but move them out of the way to keep the PE binary more compact. */
+ .ARM.exidx : { *(.ARM.exidx) }
+ .eh_frame : { *(.eh_frame) }
+ .eh_frame_hdr : { *(.eh_frame_hdr) }
+ .gnu.hash : { *(.gnu.hash) }
+ .hash : { *(.hash) }
+ .note.gnu.build-id : { *(.note.gnu.build-id ) }
+
+ /DISCARD/ : {
+ *(.ARM.attributes)
+ *(.comment)
+ *(.note.*)
+ *(.riscv.attributes)
+ }
+}