mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
boot: Stop linking against libefi.a
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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(); \
|
||||
|
||||
Reference in New Issue
Block a user