diff options
author | Ryan Govostes <rzg@apple.com> | 2016-06-24 22:39:23 +0000 |
---|---|---|
committer | Ryan Govostes <rzg@apple.com> | 2016-06-24 22:39:23 +0000 |
commit | 4fce1d768c9523dc177a7cdc4bff8a8ee7d78dc1 (patch) | |
tree | 8296172d0aeb2e9c1b3a562441df0c92a22b328d | |
parent | 55482b2ea1923a47d82dc71a03dba469d92088fe (diff) |
[asan] Improve global-registration.c test
Removes use of GNU language extensions from the test, and hopefully fixes the
link order on Linux.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@273741 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/asan/TestCases/Posix/global-registration.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/test/asan/TestCases/Posix/global-registration.c b/test/asan/TestCases/Posix/global-registration.c index fb1e1ca6d..d1f55fdd5 100644 --- a/test/asan/TestCases/Posix/global-registration.c +++ b/test/asan/TestCases/Posix/global-registration.c @@ -8,7 +8,7 @@ // RUN: %clang_asan -c -o %t-one.o -DMAIN_FILE %s // RUN: %clang_asan -c -o %t-two.o -DSECONDARY_FILE %s // RUN: %clang_asan -o %t %t-one.o %t-two.o -// RUN: %clang_asan -o %t-dynamic.so -shared -fPIC %libdl -DSHARED_LIBRARY_FILE %s +// RUN: %clang_asan -o %t-dynamic.so -shared -fPIC -DSHARED_LIBRARY_FILE %s %libdl // RUN: not %run %t 1 2>&1 | FileCheck --check-prefix ASAN-CHECK-1 %s // RUN: not %run %t 2 2>&1 | FileCheck --check-prefix ASAN-CHECK-2 %s // RUN: not %run %t 3 2>&1 | FileCheck --check-prefix ASAN-CHECK-3 %s @@ -18,9 +18,11 @@ #include <dlfcn.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> +extern char buffer1[1]; extern char buffer2[1]; -char buffer1[1] = { }; +char buffer1[1] = { 0 }; int main(int argc, char *argv[]) { int n = atoi(argv[1]); @@ -31,8 +33,9 @@ int main(int argc, char *argv[]) { buffer2[argc] = 0; // ASAN-CHECK-2: {{0x.* is located 1 bytes .* 'buffer2'}} } else if (n == 3) { - char *libpath; - asprintf(&libpath, "%s-dynamic.so", argv[0]); + char *libsuffix = "-dynamic.so"; + char *libpath = malloc(strlen(argv[0]) + strlen(libsuffix) + 1); + sprintf(libpath, "%s%s", argv[0], libsuffix); void *handle = dlopen(libpath, RTLD_NOW); if (!handle) { @@ -55,10 +58,12 @@ int main(int argc, char *argv[]) { #elif SECONDARY_FILE -char buffer2[1] = { }; +extern char buffer2[1]; +char buffer2[1] = { 0 }; #elif SHARED_LIBRARY_FILE -char buffer3[1] = { }; +extern char buffer3[1]; +char buffer3[1] = { 0 }; #endif |