[compiler-rt] r208780 - [ASan tests] Get rid of SharedLibs/
Alexey Samsonov
samsonov at google.com
Wed May 14 10:49:46 PDT 2014
Thanks!
On Wed, May 14, 2014 at 7:41 AM, Timur Iskhodzhanov <timurrrr at google.com>wrote:
> Author: timurrrr
> Date: Wed May 14 09:41:38 2014
> New Revision: 208780
>
> URL: http://llvm.org/viewvc/llvm-project?rev=208780&view=rev
> Log:
> [ASan tests] Get rid of SharedLibs/
>
> Removed:
> compiler-rt/trunk/test/asan/TestCases/SharedLibs/
> Modified:
>
> compiler-rt/trunk/test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc
>
> compiler-rt/trunk/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc
> compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc
> compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc
> compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc
> compiler-rt/trunk/test/asan/TestCases/asan-symbolize-sanity-test.cc
> compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc
>
> Modified:
> compiler-rt/trunk/test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc?rev=208780&r1=208779&r2=208780&view=diff
>
> ==============================================================================
> ---
> compiler-rt/trunk/test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc
> (original)
> +++
> compiler-rt/trunk/test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc
> Wed May 14 09:41:38 2014
> @@ -3,12 +3,14 @@
> // https://code.google.com/p/address-sanitizer/issues/detail?id=159
>
> // RUN: %clangxx_asan %s -o %t
> -// RUN: %clangxx %p/../SharedLibs/darwin-dummy-shared-lib-so.cc \
> +// RUN: %clangxx -DSHARED_LIB %s \
> // RUN: -dynamiclib -o darwin-dummy-shared-lib-so.dylib
>
> // FIXME: the following command line may hang in the case of a regression.
> // RUN: DYLD_INSERT_LIBRARIES=darwin-dummy-shared-lib-so.dylib \
> // RUN: %run %t 2>&1 | FileCheck %s || exit 1
> +
> +#if !defined(SHARED_LIB)
> #include <stdio.h>
> #include <stdlib.h>
>
> @@ -18,3 +20,6 @@ int main() {
> // CHECK: {{DYLD_INSERT_LIBRARIES=.*darwin-dummy-shared-lib-so.dylib.*}}
> return 0;
> }
> +#else // SHARED_LIB
> +void foo() {}
> +#endif // SHARED_LIB
>
> Modified:
> compiler-rt/trunk/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc?rev=208780&r1=208779&r2=208780&view=diff
>
> ==============================================================================
> ---
> compiler-rt/trunk/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc
> (original)
> +++
> compiler-rt/trunk/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc
> Wed May 14 09:41:38 2014
> @@ -3,7 +3,7 @@
>
> // RUN: %clangxx_asan %s -o %t
> // RUN: %clangxx %p/../Helpers/echo-env.cc -o %T/echo-env
> -// RUN: %clangxx %p/../SharedLibs/darwin-dummy-shared-lib-so.cc \
> +// RUN: %clangxx -DSHARED_LIB %s \
> // RUN: -dynamiclib -o %t-darwin-dummy-shared-lib-so.dylib
>
> // Make sure DYLD_INSERT_LIBRARIES doesn't contain the runtime library
> before
> @@ -12,9 +12,14 @@
> // RUN: %run %t %T/echo-env >/dev/null 2>&1
> // RUN: DYLD_INSERT_LIBRARIES=%t-darwin-dummy-shared-lib-so.dylib \
> // RUN: %run %t %T/echo-env 2>&1 | FileCheck %s || exit 1
> +
> +#if !defined(SHARED_LIB)
> #include <unistd.h>
> int main(int argc, char *argv[]) {
> execl(argv[1], argv[1], "DYLD_INSERT_LIBRARIES", NULL);
> // CHECK: {{DYLD_INSERT_LIBRARIES =
> .*darwin-dummy-shared-lib-so.dylib.*}}
> return 0;
> }
> +#else // SHARED_LIB
> +void foo() {}
> +#endif // SHARED_LIB
>
> Modified: compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc?rev=208780&r1=208779&r2=208780&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc
> (original)
> +++ compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc Wed
> May 14 09:41:38 2014
> @@ -3,9 +3,9 @@
>
> // Assume we're on Darwin and try to pass -U to the linker. If this flag
> is
> // unsupported, don't use it.
> -// RUN: %clangxx_asan -O0 %p/../SharedLibs/init-order-dlopen-so.cc \
> +// RUN: %clangxx_asan -O0 -DSHARED_LIB %s \
> // RUN: -fPIC -shared -o %t-so.so -Wl,-U,_inc_global || \
> -// RUN: %clangxx_asan -O0 %p/../SharedLibs/init-order-dlopen-so.cc \
> +// RUN: %clangxx_asan -O0 -DSHARED_LIB %s \
> // RUN: -fPIC -shared -o %t-so.so
> // If the linker doesn't support --export-dynamic (which is ELF-specific),
> // try to link without that option.
> @@ -13,6 +13,7 @@
> // RUN: %clangxx_asan -O0 %s -lpthread -ldl -o %t -Wl,--export-dynamic ||
> \
> // RUN: %clangxx_asan -O0 %s -lpthread -ldl -o %t
> // RUN: ASAN_OPTIONS=strict_init_order=true %run %t 2>&1 | FileCheck %s
> +#if !defined(SHARED_LIB)
> #include <dlfcn.h>
> #include <pthread.h>
> #include <stdio.h>
> @@ -55,3 +56,17 @@ int main(int argc, char *argv[]) {
> // CHECK: PASSED
> return 0;
> }
> +#else // SHARED_LIB
> +#include <stdio.h>
> +#include <unistd.h>
> +
> +extern "C" void inc_global();
> +
> +int slow_init() {
> + sleep(1);
> + inc_global();
> + return 42;
> +}
> +
> +int slowly_init_glob = slow_init();
> +#endif // SHARED_LIB
>
> Modified: compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc?rev=208780&r1=208779&r2=208780&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc
> (original)
> +++ compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc Wed May
> 14 09:41:38 2014
> @@ -1,12 +1,13 @@
> -// RUN: %clangxx_asan -O0 %p/../SharedLibs/shared-lib-test-so.cc -fPIC
> -shared -o %t-so.so
> +// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx_asan -O0 %s -ldl -o %t && not %run %t 2>&1 | FileCheck %s
> -// RUN: %clangxx_asan -O1 %p/../SharedLibs/shared-lib-test-so.cc -fPIC
> -shared -o %t-so.so
> +// RUN: %clangxx_asan -O1 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx_asan -O1 %s -ldl -o %t && not %run %t 2>&1 | FileCheck %s
> -// RUN: %clangxx_asan -O2 %p/../SharedLibs/shared-lib-test-so.cc -fPIC
> -shared -o %t-so.so
> +// RUN: %clangxx_asan -O2 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx_asan -O2 %s -ldl -o %t && not %run %t 2>&1 | FileCheck %s
> -// RUN: %clangxx_asan -O3 %p/../SharedLibs/shared-lib-test-so.cc -fPIC
> -shared -o %t-so.so
> +// RUN: %clangxx_asan -O3 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx_asan -O3 %s -ldl -o %t && not %run %t 2>&1 | FileCheck %s
>
> +#if !defined(SHARED_LIB)
> #include <dlfcn.h>
> #include <stdio.h>
> #include <string.h>
> @@ -36,3 +37,20 @@ int main(int argc, char *argv[]) {
> // CHECK: {{ #1 0x.* in main .*shared-lib-test.cc:}}[[@LINE-4]]
> return 0;
> }
> +#else // SHARED_LIBS
> +#include <stdio.h>
> +#include <string.h>
> +
> +int pad[10];
> +int GLOB[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
> +
> +extern "C"
> +void inc(int index) {
> + GLOB[index]++;
> +}
> +
> +extern "C"
> +void inc2(int *a, int index) {
> + a[index]++;
> +}
> +#endif // SHARED_LIBS
>
> Modified: compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc?rev=208780&r1=208779&r2=208780&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc
> (original)
> +++ compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc Wed
> May 14 09:41:38 2014
> @@ -2,11 +2,12 @@
> // Main executable is uninstrumented, but linked to ASan runtime. The
> shared
> // library is instrumented. Memory errors before dlopen are not detected.
>
> -// RUN: %clangxx_asan -O0 %p/../SharedLibs/start-deactivated-so.cc -fPIC
> -shared -o %t-so.so
> +// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx -O0 %s -c -o %t.o
> // RUN: %clangxx_asan -O0 %t.o -ldl -o %t
> // RUN: ASAN_OPTIONS=start_deactivated=1 not %run %t 2>&1 | FileCheck %s
>
> +#if !defined(SHARED_LIB)
> #include <dlfcn.h>
> #include <stdio.h>
> #include <stdlib.h>
> @@ -55,3 +56,12 @@ int main(int argc, char *argv[]) {
>
> return 0;
> }
> +#else // SHARED_LIB
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +extern "C" void do_another_bad_thing() {
> + char *volatile p = (char *)malloc(100);
> + printf("%hhx\n", p[105]);
> +}
> +#endif // SHARED_LIB
>
> 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=208780&r1=208779&r2=208780&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
> Wed May 14 09:41:38 2014
> @@ -1,9 +1,11 @@
> // Check that asan_symbolize.py script works (for binaries, ASan RTL and
> // shared object files.
>
> -// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc -fPIC
> -shared -o %t-so.so
> +// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx_asan -O0 %s -ldl -o %t
> // RUN: ASAN_OPTIONS=symbolize=0 not %run %t 2>&1 | %asan_symbolize |
> FileCheck %s
> +
> +#if !defined(SHARED_LIB)
> #include <dlfcn.h>
> #include <stdio.h>
> #include <stdlib.h>
> @@ -30,10 +32,27 @@ 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:26
> + // CHECK: #0 {{.*}} in inc2 {{.*}}asan-symbolize-sanity-test.cc:56
> // CHECK: #1 {{.*}} in main
> {{.*}}asan-symbolize-sanity-test.cc:[[@LINE-4]]
> // CHECK: allocated by thread T{{.*}} here:
> // CHECK: #{{.*}} in {{(wrap_|__interceptor_)?}}malloc
> // CHECK: #{{.*}} in main
> {{.*}}asan-symbolize-sanity-test.cc:[[@LINE-9]]
> return 0;
> }
> +#else // SHARED_LIBS
> +#include <stdio.h>
> +#include <string.h>
> +
> +int pad[10];
> +int GLOB[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
> +
> +extern "C"
> +void inc(int index) {
> + GLOB[index]++;
> +}
> +
> +extern "C"
> +void inc2(int *a, int index) {
> + a[index]++;
> +}
> +#endif // SHARED_LIBS
>
> Modified: compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc?rev=208780&r1=208779&r2=208780&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc (original)
> +++ compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc Wed May 14
> 09:41:38 2014
> @@ -14,15 +14,16 @@
> // It works on i368/x86_64 Linux, but not necessary anywhere else.
> // REQUIRES: x86_64-supported-target,i386-supported-target
>
> -// RUN: %clangxx_asan -O0 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared
> -o %t-so.so
> +// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx_asan -O0 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
> -// RUN: %clangxx_asan -O1 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared
> -o %t-so.so
> +// RUN: %clangxx_asan -O1 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx_asan -O1 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
> -// RUN: %clangxx_asan -O2 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared
> -o %t-so.so
> +// RUN: %clangxx_asan -O2 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx_asan -O2 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
> -// RUN: %clangxx_asan -O3 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared
> -o %t-so.so
> +// RUN: %clangxx_asan -O3 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
> // RUN: %clangxx_asan -O3 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
>
> +#if !defined(SHARED_LIB)
> #include <assert.h>
> #include <dlfcn.h>
> #include <stdio.h>
> @@ -75,3 +76,24 @@ int main(int argc, char *argv[]) {
> // CHECK: PASS
> return 0;
> }
> +#else // SHARED_LIB
> +#include <stdio.h>
> +
> +static int pad1;
> +static int static_var;
> +static int pad2;
> +
> +extern "C"
> +int *get_address_of_static_var() {
> + return &static_var;
> +}
> +
> +__attribute__((constructor))
> +void at_dlopen() {
> + printf("%s: I am being dlopened\n", __FILE__);
> +}
> +__attribute__((destructor))
> +void at_dlclose() {
> + printf("%s: I am being dlclosed\n", __FILE__);
> +}
> +#endif // SHARED_LIB
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Alexey Samsonov, Mountain View, CA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140514/1a585d46/attachment.html>
More information about the llvm-commits
mailing list