]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Ensure ARM UEFI binary does not contain FP/SIMD instructions
authorJames T. Lee <james@james.tl>
Sat, 7 Mar 2020 23:05:34 +0000 (18:05 -0500)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 8 Mar 2020 06:21:00 +0000 (15:21 +0900)
ARM toolchains will sometimes optimize otherwise floating-point-free
code with floating point and SIMD instructions.  This was happening with
systemd-bootarm.efi and it was causing U-Boot to crash and reset the
CPU.  U-Boot does not support the ARM VFP floating point coprocessor,
which is an optional piece of hardware anyway [1].

Ensure the compiler does not generate FP/SIMD instructions by supplying
the `-mgeneral-regs-only` option when building for ARM [2].

The other option you often see to solve these problems is
`-msoft-float`, but that changes the ABI and prevents linking with
libgnuefi.

[1] https://lists.denx.de/pipermail/u-boot/2011-February/087736.html
[2] https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mgeneral-regs-only-1

src/boot/efi/meson.build

index c1fe04597bc66819b56e34e88644fd13f261d02e..ed81cefcd5d153878ea0bfcdedb9a55bbd54e5c8 100644 (file)
@@ -155,6 +155,8 @@ if have_gnu_efi
         elif efi_arch == 'ia32'
                 compile_args += ['-mno-sse',
                                  '-mno-mmx']
+        elif efi_arch == 'arm'
+                compile_args += ['-mgeneral-regs-only']
         endif
         if get_option('werror') == true
                 compile_args += ['-Werror']