Skip to content

Commit 84ba0d2

Browse files
medhefgobluca
authored andcommitted
meson: Pass all -static-pie args to linker
Fixes: #29381 (cherry picked from commit a8b53f4)
1 parent 413849e commit 84ba0d2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/boot/efi/meson.build

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,14 @@ efi_c_ld_args = [
161161
'-Wl,--entry=efi_main',
162162
'-Wl,--fatal-warnings',
163163

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

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

0 commit comments

Comments
 (0)