This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/80114] asan-stack=1 with -fsanitize-address-use-after-scope and stack arrays multiplies code size
- From: "arnd at linaro dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 20 Mar 2017 19:43:02 +0000
- Subject: [Bug sanitizer/80114] asan-stack=1 with -fsanitize-address-use-after-scope and stack arrays multiplies code size
- Auto-submitted: auto-generated
- References: <bug-80114-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80114
--- Comment #8 from Arnd Bergmann <arnd at linaro dot org> ---
Looking at the kernel code again, I came up with an alternative that avoids the
large stack size and produces good executable code in all configurations I
found with the file that showed up a -Wframe-larger-than= warning for me, with
slightly larger .rodata and .data sections
-#define _PICK(__index, ...) (((const u32 []){ __VA_ARGS__ })[__index])
+#define _PICK(__index, ...) ({static const u32 __arr[] = { __VA_ARGS__ };
__arr[__index];})
Unfortunately this requires a constant argument set, and a number of other
files contain callers with non-constant arguments. We'd have to see if those
can be changed to use constant arguments instead.