[compiler-rt] r202037 - [asan] Add a test for interceptors in shared libraries.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed Feb 26 01:03:29 PST 2014
Why? Libraries in $ORIGIN should always take precedence in tests. One
need to check whether this will work on Mac, or what alternatives are
available there.
On Wed, Feb 26, 2014 at 12:52 PM, Alexey Samsonov <samsonov at google.com> wrote:
> IMO that would be an overkill. Maybe, we can use another %-like substitution
> for that, or work around the problem.
>
>
> On Wed, Feb 26, 2014 at 12:43 PM, Evgeniy Stepanov
> <eugeni.stepanov at gmail.com> wrote:
>>
>> How about adding RPATH setting to %clang_asan depending on the platform?
>>
>> On Wed, Feb 26, 2014 at 11:51 AM, Alexey Samsonov <samsonov at google.com>
>> wrote:
>> > FYI, now this test fails on Mac with:
>> >
>> > ld: unknown option: -R
>> >
>> >
>> > On Tue, Feb 25, 2014 at 7:32 PM, Evgeniy Stepanov
>> > <eugeni.stepanov at gmail.com> wrote:
>> >>
>> >> Indeed, everything seems to work fine without soname.
>> >> Fixed in r202156.
>> >>
>> >> On Tue, Feb 25, 2014 at 6:59 PM, Alexander Potapenko
>> >> <glider at google.com>
>> >> wrote:
>> >> > I think we do want a similar test on Mac. Maybe just omit the
>> >> > --soname
>> >> > flag?
>> >> >
>> >> > On Tue, Feb 25, 2014 at 6:31 PM, Alexey Samsonov
>> >> > <samsonov at google.com>
>> >> > wrote:
>> >> >> Should this test be Linux-specific? It fails on Mac with:
>> >> >> ld: unknown option: --soname
>> >> >>
>> >> >>
>> >> >> On Mon, Feb 24, 2014 at 6:31 PM, Evgeniy Stepanov
>> >> >> <eugeni.stepanov at gmail.com> wrote:
>> >> >>>
>> >> >>> Author: eugenis
>> >> >>> Date: Mon Feb 24 08:31:28 2014
>> >> >>> New Revision: 202037
>> >> >>>
>> >> >>> URL: http://llvm.org/viewvc/llvm-project?rev=202037&view=rev
>> >> >>> Log:
>> >> >>> [asan] Add a test for interceptors in shared libraries.
>> >> >>>
>> >> >>> Added:
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc
>> >> >>> (with props)
>> >> >>> Modified:
>> >> >>>
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/asan-symbolize-sanity-test.cc
>> >> >>>
>> >> >>> Modified:
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc
>> >> >>> URL:
>> >> >>>
>> >> >>>
>> >> >>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc?rev=202037&r1=202036&r2=202037&view=diff
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> ==============================================================================
>> >> >>> ---
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc
>> >> >>> (original)
>> >> >>> +++
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc
>> >> >>> Mon Feb 24 08:31:28 2014
>> >> >>> @@ -11,6 +11,7 @@
>> >> >>> //
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> //===----------------------------------------------------------------------===//
>> >> >>> #include <stdio.h>
>> >> >>> +#include <string.h>
>> >> >>>
>> >> >>> int pad[10];
>> >> >>> int GLOB[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
>> >> >>> @@ -24,3 +25,8 @@ extern "C"
>> >> >>> void inc2(int *a, int index) {
>> >> >>> a[index]++;
>> >> >>> }
>> >> >>> +
>> >> >>> +extern "C"
>> >> >>> +void my_memset(void *p, size_t sz) {
>> >> >>> + memset(p, 0, sz);
>> >> >>> +}
>> >> >>>
>> >> >>> Modified:
>> >> >>> compiler-rt/trunk/test/asan/TestCases/asan-symbolize-sanity-test.cc
>> >> >>> URL:
>> >> >>>
>> >> >>>
>> >> >>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/asan-symbolize-sanity-test.cc?rev=202037&r1=202036&r2=202037&view=diff
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> ==============================================================================
>> >> >>> ---
>> >> >>> compiler-rt/trunk/test/asan/TestCases/asan-symbolize-sanity-test.cc
>> >> >>> (original)
>> >> >>> +++
>> >> >>> compiler-rt/trunk/test/asan/TestCases/asan-symbolize-sanity-test.cc
>> >> >>> Mon Feb 24 08:31:28 2014
>> >> >>> @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) {
>> >> >>> inc2(array, -1); // BOOM
>> >> >>> // CHECK: ERROR: AddressSanitizer: heap-buffer-overflow
>> >> >>> // CHECK: READ of size 4 at 0x{{.*}}
>> >> >>> - // CHECK: #0 {{.*}} in inc2 {{.*}}shared-lib-test-so.cc:25
>> >> >>> + // CHECK: #0 {{.*}} in inc2 {{.*}}shared-lib-test-so.cc:26
>> >> >>> // CHECK: #1 {{.*}} in main
>> >> >>> {{.*}}asan-symbolize-sanity-test.cc:[[@LINE-4]]
>> >> >>> // CHECK: allocated by thread T{{.*}} here:
>> >> >>> // CHECK: #{{.*}} in {{(wrap_|__interceptor_)?}}malloc
>> >> >>>
>> >> >>> Added:
>> >> >>>
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc
>> >> >>> URL:
>> >> >>>
>> >> >>>
>> >> >>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc?rev=202037&view=auto
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> ==============================================================================
>> >> >>> ---
>> >> >>>
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc
>> >> >>> (added)
>> >> >>> +++
>> >> >>>
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc Mon
>> >> >>> Feb 24 08:31:28 2014
>> >> >>> @@ -0,0 +1,21 @@
>> >> >>> +// Check that memset() call from a shared library gets
>> >> >>> intercepted.
>> >> >>> +
>> >> >>> +// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc \
>> >> >>> +// RUN: -shared -o %T/libinterception-in-shared-lib-test.so \
>> >> >>> +// RUN: -fPIC
>> >> >>> -Wl,--soname,libinterception-in-shared-lib-test.so
>> >> >>> +// RUN: %clangxx_asan -O0 %s -o %t -Wl,-R,\$ORIGIN -L%T
>> >> >>> -linterception-in-shared-lib-test && \
>> >> >>> +// RUN: not %t 2>&1 | FileCheck %s
>> >> >>> +
>> >> >>> +#include <stdio.h>
>> >> >>> +#include <string.h>
>> >> >>> +
>> >> >>> +extern "C" void my_memset(void *p, size_t sz);
>> >> >>> +
>> >> >>> +int main(int argc, char *argv[]) {
>> >> >>> + char buf[10];
>> >> >>> + my_memset(buf, 11);
>> >> >>> + // CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-overflow}}
>> >> >>> + // CHECK: {{WRITE of size 11 at 0x.* thread T0}}
>> >> >>> + // CHECK: {{ #0 0x.* in my_memset
>> >> >>> .*shared-lib-test-so.cc:31}}
>> >> >>> + return 0;
>> >> >>> +}
>> >> >>>
>> >> >>> Propchange:
>> >> >>>
>> >> >>>
>> >> >>> compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> ------------------------------------------------------------------------------
>> >> >>> svn:eol-style = LF
>> >> >>>
>> >> >>>
>> >> >>> _______________________________________________
>> >> >>> llvm-commits mailing list
>> >> >>> llvm-commits at cs.uiuc.edu
>> >> >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Alexey Samsonov, MSK
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Alexander Potapenko
>> >> > Software Engineer
>> >> > Google Moscow
>> >
>> >
>> >
>> >
>> > --
>> > Alexey Samsonov, MSK
>
>
>
>
> --
> Alexey Samsonov, MSK
More information about the llvm-commits
mailing list