get_option('b_ndebug') == 'if-release' and get_option('buildtype') in ['plain', 'release'])
efi_cflags += ['-DNDEBUG']
endif
+if get_option('b_lto')
+ efi_cflags += ['-flto']
+endif
foreach arg : get_option('c_args')
- if arg in ['-Werror', '-g', '-ggdb', '-O1', '-O2', '-O3', '-Og', '-Os', '-DNDEBUG']
+ if arg in ['-Werror', '-g', '-ggdb', '-O1', '-O2', '-O3', '-Og', '-Os', '-DNDEBUG', '-flto', '-fno-lto']
message('Using "@0@" from c_args for EFI compiler'.format(arg))
efi_cflags += arg
endif
'-fuse-ld=' + get_option('efi-ld'),
'-L', efi_libdir,
'-nostdlib',
- '-shared',
'-T', efi_lds,
'-Wl,--build-id=sha1',
'-Wl,--fatal-warnings',
efi_crt0,
]
if efi_arch[1] in ['aarch64', 'arm', 'riscv64']
+ efi_ldflags += ['-shared', '-fwhole-program']
# Aarch64, ARM32 and 64bit RISC-V don't have an EFI capable objcopy.
# Use 'binary' instead, and add required symbols manually.
efi_ldflags += ['-Wl,--defsym=EFI_SUBSYSTEM=0xa']
efi_format = ['-O', 'binary']
else
+ efi_ldflags += ['-pie']
+ if get_option('efi-ld') == 'bfd'
+ efi_ldflags += '-Wl,--no-dynamic-linker'
+ endif
efi_format = ['--target=efi-app-@0@'.format(efi_arch[1])]
endif
tuple[0],
input : tuple[2],
output : tuple[0],
- command : [efi_cc, '-o', '@OUTPUT@', efi_ldflags, tuple[2], '-lefi', '-lgnuefi', '-lgcc'],
+ command : [efi_cc, '-o', '@OUTPUT@', efi_ldflags, efi_cflags, tuple[2], '-lefi', '-lgnuefi', '-lgcc'],
install : tuple[3],
install_dir : bootlibdir)
input : so,
output : tuple[1],
command : [objcopy,
+ '-j', '.bss*',
'-j', '.data',
'-j', '.dynamic',
'-j', '.dynsym',