forked from OSchip/llvm-project
[asan] Improve global-registration.c test
Removes use of GNU language extensions from the test, and hopefully fixes the link order on Linux. llvm-svn: 273741
This commit is contained in:
parent
082cc0e5dd
commit
6f92bd38d8
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue