[compiler-rt] r273741 - [asan] Improve global-registration.c test
Ryan Govostes via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 24 15:39:23 PDT 2016
Author: rgov
Date: Fri Jun 24 17:39:23 2016
New Revision: 273741
URL: http://llvm.org/viewvc/llvm-project?rev=273741&view=rev
Log:
[asan] Improve global-registration.c test
Removes use of GNU language extensions from the test, and hopefully fixes the
link order on Linux.
Modified:
compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c
Modified: compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c?rev=273741&r1=273740&r2=273741&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/global-registration.c Fri Jun 24 17:39:23 2016
@@ -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
More information about the llvm-commits
mailing list