This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]