Skip to content

Commit

Permalink
meson: Test correct efi linker for supported args
Browse files Browse the repository at this point in the history
Fixes: #24241
  • Loading branch information
medhefgo committed Aug 10, 2022
1 parent b342425 commit 6a941db
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/boot/efi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,19 @@ efi_ldflags = [
efi_crt0,
]

possible_link_flags = [
'-Wl,--no-warn-execstack',
'-Wl,--no-warn-rwx-segments',
]
efi_ldflags += cc.get_supported_link_arguments(possible_link_flags)
foreach arg : ['-Wl,--no-warn-execstack',
'-Wl,--no-warn-rwx-segments']
# We need to check the correct linker for supported args. This is what
# cc.has_multi_link_arguments() is for, but it helpfully overrides our
# choice of linker by putting its own -fuse-ld= arg after ours.
if run_command('bash', '-c',
'exec "$@" -x c -o/dev/null <(echo "int main(void){return 0;}")' +
' -fuse-ld=' + efi_ld + ' -Wl,--fatal-warnings ' + arg,
'bash', cc.cmd_array(),
check : false).returncode() == 0
efi_ldflags += arg
endif
endforeach

if efi_arch[1] in ['aarch64', 'arm', 'riscv64']
efi_ldflags += ['-shared']
Expand Down

0 comments on commit 6a941db

Please sign in to comment.