Skip to content

Commit

Permalink
meson: Pass all -static-pie args to linker
Browse files Browse the repository at this point in the history
Fixes: #29381
  • Loading branch information
medhefgo committed Oct 1, 2023
1 parent cb88da8 commit cecbb16
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/boot/efi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,14 @@ efi_c_ld_args = [
'-Wl,--entry=efi_main',
'-Wl,--fatal-warnings',

# These flags should be passed by -static-pie, but seem to be missing sometimes.
'-Wl,--no-dynamic-linker',
'-z', 'text',
# These flags should be passed by -static-pie, but for whatever reason the flag translation
# is not enabled on all architectures. Not passing `-static` would just allow the linker to
# use dynamic libraries, (which we can't/don't use anyway). But if `-pie` is missing and the
# gcc build does not default to `-pie` we get a regular (no-pie) binary that will be
# rightfully rejected by elf2efi. Note that meson also passes `-pie` to the linker driver,
# but it is overridden by our `-static-pie`. We also need to pass these directly to the
# linker as `-static`+`-pie` seem to get translated differently.
'-Wl,-static,-pie,--no-dynamic-linker,-z,text',

# EFI has 4KiB pages.
'-z', 'common-page-size=4096',
Expand Down

0 comments on commit cecbb16

Please sign in to comment.