This is an archive of the discontinued LLVM Phabricator instance.

make asan work with 7fff8000 offset and prelink
ClosedPublic

Authored by kcc on Feb 14 2013, 11:36 PM.

Details

Reviewers
samsonov
Summary

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.

Diff Detail

Event Timeline

kcc updated this revision to Unknown Object (????).Feb 15 2013, 12:44 AM

fewer calls to MemoryRangeIsAvailable

kcc updated this revision to Unknown Object (????).Feb 15 2013, 2:59 AM
samsonov accepted this revision.Feb 15 2013, 3:21 AM

LGTM (it's a pity we need all this, though).

include/sanitizer/asan_interface.h
40–41

This should probably go to common_interface_defs.h.
I wonder why eugenis@ didn't needed this macro in msan_interface.h...

lib/asan/asan_internal.h
57

And this can go to lib/sanitizer_common/sanitizer_internal_defs.h

lib/asan/asan_mapping.h
192

Put || on the previous line

lib/asan/asan_rtl.cc
425–426

I'd prefer to factor printing the shadow layout in a separate function.

429

&& on the previous line as well (I think it's adviced by clang-format).

455

ditto

lib/asan/lit_tests/Linux/asan_prelink_test.cc
3

Please add a comment clarifying || exit 0 and lacking support in gold.

kcc updated this revision to Unknown Object (????).Feb 15 2013, 3:54 AM

addressed Alexey's comments.

Eugene.Zelenko closed this revision.Oct 5 2016, 3:43 PM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in rL175263.