[Bug sanitizer/80114] asan-stack=1 with -fsanitize-address-use-after-scope and stack arrays multiplies code size

arnd at linaro dot org gcc-bugzilla@gcc.gnu.org
Mon Mar 20 19:43:00 GMT 2017


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.


More information about the Gcc-bugs mailing list