llvm-project/compiler-rt/lib/lsan
Rafael Espindola 5e46070516 Avoid aliases to weak aliases in interceptors.
The interceptors had code that after macro expansion ended up looking like

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("memalign")));

That is,
* __interceptor_memalign is a function
* memalign is a weak alias to __interceptor_memalign
* __interceptor___libc_memalign is an alias to memalign

Both gcc and clang produce assembly that look like

__interceptor_memalign:
...
        .weak   memalign
memalign = __interceptor_memalign
        .globl  __interceptor___libc_memalign
__interceptor___libc_memalign = memalign

What it means in the end is that we have 3 symbols pointing to the
same position in the file, one of which is weak:

     8: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor_memalign
     9: 0000000000000000     1 FUNC    WEAK   DEFAULT    1 memalign
    10: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor___libc_memalign

In particular, note that __interceptor___libc_memalign will always
point to __interceptor_memalign, even if we do link in a strong symbol
for memalign. In fact, the above code produces exactly the same binary
as

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("__interceptor_memalign")));

If nothing else, this patch makes it more obvious what is going on.

llvm-svn: 204823
2014-03-26 15:48:59 +00:00
..
CMakeLists.txt [CMake] Add top-level target for each compiler-rt library, and add 'compiler-rt' target encompassing them all. 2014-02-18 09:33:45 +00:00
Makefile.mk [LSan] Add support for building standalone LSan runtime to Make build (compiler-rt part) 2013-08-20 14:49:01 +00:00
lsan.cc [Sanitizer] Always initialize a Symbolizer (even if 'symbolize' is false). 2013-12-17 11:15:39 +00:00
lsan.h [lsan] Unbreak standalone LSan's initialization by making it more like ASan's. 2013-11-25 14:25:36 +00:00
lsan_allocator.cc [lsan] handle 'new T[0]' where T is a type with DTOR; fixes https://code.google.com/p/address-sanitizer/issues/detail?id=257 2014-01-10 10:48:01 +00:00
lsan_allocator.h
lsan_common.cc [libsanitizer] Introduce flag descriptions. 2014-03-20 12:52:52 +00:00
lsan_common.h [lsan] remove LeakSanitizerIsTurnedOffForTheCurrentProcess (this was a bad idea), leave __lsan_is_turned_off 2014-01-15 08:04:21 +00:00
lsan_common_linux.cc LSan: Print warning about dynamic linker only in verbose mode 2014-02-14 15:12:46 +00:00
lsan_interceptors.cc Avoid aliases to weak aliases in interceptors. 2014-03-26 15:48:59 +00:00
lsan_preinit.cc [lsan] Unbreak lsan_testlib.cc. 2013-11-25 15:54:31 +00:00
lsan_thread.cc [lsan] Support ASan's stack-use-after-return mode in LSan. 2013-10-14 14:04:50 +00:00
lsan_thread.h [lsan] Handle fork() correctly. 2013-07-08 12:57:24 +00:00