Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ASAN (-fsanitize=address) for xtensa target #9

Open
paulreimer opened this issue Dec 2, 2017 · 2 comments
Open

Support ASAN (-fsanitize=address) for xtensa target #9

paulreimer opened this issue Dec 2, 2017 · 2 comments

Comments

@paulreimer
Copy link

Not sure what is involved, but I know that ASAN support on x86 is amazing for finding tricky bugs, and I'd love to run it on my ESP32 debug builds.

I'm not sure what is involved in adding it for a new target. The current state seems to be a compiler warning (after adding -fsanitize=address to CXXFLAGS):

warning: -fsanitize=address not supported for this target
@paulreimer
Copy link
Author

@jcmvbkbc noted this caveat (and helpful link!)

Also compiling with ASAN results in higher memory requirements: according to https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm it requires 1/8 of used memory for its shadow map.

jcmvbkbc/crosstool-NG#51 (comment)

@jcmvbkbc
Copy link
Owner

jcmvbkbc commented Dec 4, 2017

So I've added dummy ASAN support to the xtensa gcc: 1ebcd84 It will appear in gcc-7.3 and gcc-8.
Using it I was able to enable KASAN support for xtensa in the linux kernel (see https://github.com/jcmvbkbc/linux-xtensa/commits/xtensa-ssp-kasan for details). One thing that I've noticed with the instrumented code is that it needs at least 4 times more stack space. The kernel image size has grown almost 2x.

It looks like enabling libsanitizer doesn't make much sense for embedded target as this library is oriented to big OSes like linux, *BSD and windows. Instead the ESP can take the kernel approach, invoke gcc with options like -fsanitize=kernel-address -fasan-shadow-offset=<shadow-offset-address> --param asan-stack=1 --param asan-globals=1 --param asan-instrumentation-with-call-threshold=<call-threshold>, implement __asan_load* and __asan_store* hooks that do actual checking, implement replacements for dynamic memory allocation/freeing functions to mark available dynamic memory and implement replacements for mem* and str* functions that do buffer validation.

jcmvbkbc pushed a commit that referenced this issue Jun 18, 2018
PR c++/84269 reports a number of names in the C and C++ standard
libraries for which we don't yet offer #include fix-it hints.

This patch adds them (up to comment #9).

gcc/c-family/ChangeLog:
	PR c++/84269
	* known-headers.cc (get_stdlib_header_for_name): Add various names
	from <assert.h>, <string.h>, and <memory.h>; add more names from
	<stdio.h>.

gcc/cp/ChangeLog:
	PR c++/84269
	* name-lookup.c (get_std_name_hint): Add names from <memory>,
	<tuple>, and <utility>.

gcc/testsuite/ChangeLog:
	PR c++/84269
	* g++.dg/lookup/missing-std-include-6.C: New test.
	* g++.dg/lookup/missing-std-include.C: Add std::pair and
	std::tuple tests.
	* g++.dg/spellcheck-reswords.C: Expect a hint about <cstring>.
	* g++.dg/spellcheck-stdlib.C: Add tests for names in <cstdio>,
	<cstring>, <cassert>, and <cstdlib>.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258966 138bc75d-0d04-0410-961f-82ee72b054a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants