bolt/deps/llvm-18.1.8/compiler-rt/test/msan/dlopen_executable.cpp

18 lines
470 B
C++
Raw Normal View History

2025-02-14 19:21:04 +01:00
// RUN: %clangxx_msan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
#include <assert.h>
#include <dlfcn.h>
#include <stdlib.h>
static int my_global;
int main(void) {
int *uninit = (int*)malloc(sizeof(int));
my_global = *uninit;
void *p = dlopen(0, RTLD_NOW);
assert(p && "failed to get handle to executable");
return my_global;
// CHECK: MemorySanitizer: use-of-uninitialized-value
// CHECK: #0 {{.*}} in main{{.*}}dlopen_executable.cpp:[[@LINE-2]]
}