]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Stop linking against libefi.a 26110/head
authorJan Janssen <medhefgo@web.de>
Sun, 5 Jun 2022 15:35:03 +0000 (17:35 +0200)
committerJan Janssen <medhefgo@web.de>
Fri, 20 Jan 2023 20:02:16 +0000 (21:02 +0100)
libefi.a just provided the c helper API that was slowly removed. As we
do not depend on anything provided by it anymore, it is safe to drop
now.

Since the ST/BS/RT pointers are very convenient and needed everywhere,
they are retained and initialized by us.

src/boot/efi/boot.c
src/boot/efi/efi-string.c
src/boot/efi/meson.build
src/boot/efi/secure-boot.c
src/boot/efi/stub.c
src/boot/efi/util.h

index 8d0d547a898d149ab188e7f5552c9d2475310a24..f3d009bee8504dbb5eaffef4e61e41e0fa4625eb 100644 (file)
@@ -2748,3 +2748,8 @@ out:
 }
 
 DEFINE_EFI_MAIN_FUNCTION(run, "systemd-boot", /*wait_for_debugger=*/false);
+
+/* Fedora has a heavily patched gnu-efi that supports elf constructors. It calls into _entry instead. */
+EFI_STATUS _entry(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table) {
+        return efi_main(image, system_table);
+}
index 860dfc00b2c0bce3ad31316da370ebb9440a366c..22923d60f62bf4541ed867c07a2f7d88a57650bc 100644 (file)
@@ -901,7 +901,7 @@ _used_ int memcmp(const void *p1, const void *p2, size_t n) {
         return 0;
 }
 
-_used_ _weak_ void *memcpy(void * restrict dest, const void * restrict src, size_t n) {
+_used_ void *memcpy(void * restrict dest, const void * restrict src, size_t n) {
         if (!dest || !src || n == 0)
                 return dest;
 
@@ -928,7 +928,7 @@ _used_ _weak_ void *memcpy(void * restrict dest, const void * restrict src, size
         return dest;
 }
 
-_used_ _weak_ void *memset(void *p, int c, size_t n) {
+_used_ void *memset(void *p, int c, size_t n) {
         if (!p || n == 0)
                 return p;
 
index eaa50e0e69798c4f01dc0097d22b15a6e1b371f3..d5a8f14788ec95c89898166474ec1a82bb2c6904 100644 (file)
@@ -295,23 +295,6 @@ if efi_arch[1] == 'arm'
         efi_ldflags += ['-Wl,--no-wchar-size-warning']
 endif
 
-if run_command('grep', '-q', '__CTOR_LIST__', efi_lds, check: false).returncode() == 0
-        # fedora has a patched gnu-efi that adds support for ELF constructors.
-        # If ld is called by gcc something about these symbols breaks, resulting
-        # in sd-boot freezing when gnu-efi runs the constructors. Force defining
-        # them seems to work around this.
-        efi_ldflags += [
-                '-Wl,--defsym=_init_array=0',
-                '-Wl,--defsym=_init_array_end=0',
-                '-Wl,--defsym=_fini_array=0',
-                '-Wl,--defsym=_fini_array_end=0',
-                '-Wl,--defsym=__CTOR_LIST__=0',
-                '-Wl,--defsym=__CTOR_END__=0',
-                '-Wl,--defsym=__DTOR_LIST__=0',
-                '-Wl,--defsym=__DTOR_END__=0',
-        ]
-endif
-
 if cc.get_id() == 'clang' and cc.version().split('.')[0].to_int() <= 10
         # clang <= 10 doesn't pass -T to the linker and then even complains about it being unused
         efi_ldflags += ['-Wl,-T,' + efi_lds, '-Wno-unused-command-line-argument']
@@ -445,7 +428,6 @@ foreach tuple : [['systemd-boot@0@.@1@', systemd_boot_objects, false, 'systemd-b
                            efi_cflags,
                            efi_ldflags,
                            '@INPUT@',
-                           '-lefi',
                            '-lgnuefi',
                            '-lgcc'],
                 install : tuple[2],
index 952e92923e7639ffb5325ab65a0797255394449d..c8a3957b1e18fe5a0455f652203e41c7c10d0631 100644 (file)
@@ -124,7 +124,7 @@ EFI_STATUS secure_boot_enroll_at(EFI_FILE *root_dir, const char16_t *path) {
 
 out_deallocate:
         for (size_t i = 0; i < ELEMENTSOF(sb_vars); i++)
-                FreePool(sb_vars[i].buffer);
+                free(sb_vars[i].buffer);
 
         return err;
 }
index e2b5b6f53705706cf531d89383204a3388373546..1dfc702acda6db1c799025e29d3ebd5c411a93a6 100644 (file)
@@ -418,3 +418,8 @@ static EFI_STATUS run(EFI_HANDLE image) {
 }
 
 DEFINE_EFI_MAIN_FUNCTION(run, "systemd-stub", /*wait_for_debugger=*/false);
+
+/* See comment in boot.c. */
+EFI_STATUS _entry(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table) {
+        return efi_main(image, system_table);
+}
index 51cc3cc6b40233247b74af4e51808a50869d8cb7..0658eae98ec35e4acfc1c58a3737b6e644185413 100644 (file)
@@ -180,8 +180,13 @@ void hexdump(const char16_t *prefix, const void *data, size_t size);
 #endif
 
 #define DEFINE_EFI_MAIN_FUNCTION(func, identity, wait_for_debugger)             \
+        EFI_SYSTEM_TABLE *ST;                                                   \
+        EFI_BOOT_SERVICES *BS;                                                  \
+        EFI_RUNTIME_SERVICES *RT;                                               \
         EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table) { \
-                InitializeLib(image, system_table);                             \
+                ST = system_table;                                              \
+                BS = system_table->BootServices;                                \
+                RT = system_table->RuntimeServices;                             \
                 notify_debugger((identity), (wait_for_debugger));               \
                 EFI_STATUS err = func(image);                                   \
                 log_wait();                                                     \