[asan] make asan work with 7fff8000 offset and prelink
authorKostya Serebryany <kcc@google.com>
Fri, 15 Feb 2013 12:00:24 +0000 (12:00 +0000)
committerKostya Serebryany <kcc@google.com>
Fri, 15 Feb 2013 12:00:24 +0000 (12:00 +0000)
commitfd61b6f0c811a831c7b3fdbde4186b3975bbfef2
treee4f0c29155cd86b3145943289e6afa37e0752878
parent54a8602aefbd75e09fa5371f28f3eeb529b6d9f2
[asan] make asan work with 7fff8000 offset and prelink

When prelink is installed in the system, prelink-ed
libraries map between 0x003000000000 and 0x004000000000 thus occupying the shadow Gap,
so we need so split the address space even further, like this:
|| [0x10007fff8000, 0x7fffffffffff] || HighMem    ||
|| [0x02008fff7000, 0x10007fff7fff] || HighShadow ||
|| [0x004000000000, 0x02008fff6fff] || ShadowGap3 ||
|| [0x003000000000, 0x003fffffffff] || MidMem     ||
|| [0x00087fff8000, 0x002fffffffff] || ShadowGap2 ||
|| [0x00067fff8000, 0x00087fff7fff] || MidShadow  ||
|| [0x00008fff7000, 0x00067fff7fff] || ShadowGap  ||
|| [0x00007fff8000, 0x00008fff6fff] || LowShadow  ||
|| [0x000000000000, 0x00007fff7fff] || LowMem     ||

Do it only if necessary.

Also added a bit of profiling code to make sure that the
mapping code is efficient.

Added a lit test to simulate prelink-ed libraries.
Unfortunately, this test does not work with binutils-gold linker.
If gold is the default linker the test silently passes.

Also replaced
__has_feature(address_sanitizer)
with
__has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
in two places.

Patch partially by Jakub Jelinek.

llvm-svn: 175263
compiler-rt/include/sanitizer/asan_interface.h
compiler-rt/include/sanitizer/common_interface_defs.h
compiler-rt/lib/asan/asan_internal.h
compiler-rt/lib/asan/asan_mapping.h
compiler-rt/lib/asan/asan_rtl.cc
compiler-rt/lib/asan/lit_tests/Linux/asan_prelink_test.cc [new file with mode: 0644]
compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h