diff options
-rw-r--r-- | compiler-rt/test/asan/TestCases/Posix/global-registration.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler-rt/test/asan/TestCases/Posix/global-registration.c b/compiler-rt/test/asan/TestCases/Posix/global-registration.c index fb1e1ca6d41..d1f55fdd572 100644 --- a/compiler-rt/test/asan/TestCases/Posix/global-registration.c +++ b/compiler-rt/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 |