google / kernel-sanitizers

Linux Kernel Sanitizers, fast bug-detectors for the Linux kernel
https://google.github.io/kernel-sanitizers/
436 stars 87 forks source link

KAsan globals metadata size question #220

Open 0528Mike opened 11 months ago

0528Mike commented 11 months ago

Open asan global=1, and the compiler will generate a descriptor structure of nearly 80 bytes for each global variable. There is a lot of data in the structure that I do not need. Is there any way to remove them, as I am using Kasan on an embedded board and memory resources are scarce

melver commented 11 months ago

If you're using Clang, you can pass try to pass -mllvm -asan-globals=0 as additional CFLAGS to disable globals instrumentation. GCC might have a similar param.

But there is no Kconfig variable to do that.

0528Mike commented 11 months ago

However, this method still cannot solve the problem of the compiler generating a nearly 80 byte metadata for each global variable. Once there are many global variables that I need to protect, this approach will cause my bin file to be very large.