]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: Pass all -static-pie args to linker
authorJan Janssen <medhefgo@web.de>
Sun, 1 Oct 2023 07:55:48 +0000 (09:55 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 1 Oct 2023 10:49:51 +0000 (11:49 +0100)
Fixes: #29381
src/boot/efi/meson.build

index d168d2d553de7d4f9108c3d12919c03f06539a33..d5c10258044d4b070bb89eb947806c9f38032e12 100644 (file)
@@ -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',