[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] meson: detect broken clang 17 with -fzero-call-used-regs
From: |
Daniel P . Berrangé |
Subject: |
[PATCH 1/2] meson: detect broken clang 17 with -fzero-call-used-regs |
Date: |
Mon, 4 Mar 2024 14:44:55 +0000 |
Clang 17 will segv if given -fzero-call-used-regs and optimization
is enabled. Since upstream hasn't triaged the bug, distros are
increasingly shipping with broken Clang.
https://github.com/llvm/llvm-project/issues/75168
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277474
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
meson.build | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/meson.build b/meson.build
index 0ef1654e86..762798f2ee 100644
--- a/meson.build
+++ b/meson.build
@@ -555,17 +555,24 @@ endif
# Check further flags that make QEMU more robust against malicious parties
hardening_flags = [
- # Zero out registers used during a function call
- # upon its return. This makes it harder to assemble
- # ROP gadgets into something usable
- '-fzero-call-used-regs=used-gpr',
-
# Initialize all stack variables to zero. This makes
# it harder to take advantage of uninitialized stack
# data to drive exploits
'-ftrivial-auto-var-init=zero',
]
+# Zero out registers used during a function call
+# upon its return. This makes it harder to assemble
+# ROP gadgets into something usable
+#
+# NB: CLang 17 is broken and SEGVs
+# https://github.com/llvm/llvm-project/issues/75168
+if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb();
}',
+ name: '-fzero-call-used-regs=used-gpr',
+ args: ['-O2', '-fzero-call-used-regs=used-gpr'])
+ hardening_flags += '-fzero-call-used-regs=used-gpr'
+endif
+
qemu_common_flags += cc.get_supported_arguments(hardening_flags)
add_global_arguments(qemu_common_flags, native: false, language: all_languages)
--
2.43.0