https://llvm.org/bugs/show_bug.cgi?id=26989
Bug ID: 26989 Summary: -fsanitize=function doesn't work with dlopen Product: clang Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: LLVM Codegen Assignee: pe...@pcc.me.uk Reporter: vonos...@gmail.com CC: llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk Classification: Unclassified Reproducer: $ cat dlopen-test.cc #include <dlfcn.h> int main() { void *dl_handle = dlopen("dlopen_test.so", RTLD_NOW | RTLD_LOCAL); typedef int (*IncFn)(int); IncFn inc = reinterpret_cast<IncFn>(dlsym(dl_handle, "my_inc")); return (1 != inc(0)); } $ cat dlopen_so.cc extern "C" int my_inc(int a) { return a + 1; } $ ./bin/clang++ -fsanitize=function dlopen_so.cc -shared -o dlopen_test.so -g $ ./bin/clang++ -fsanitize=function dlopen-test.cc -g $ ./a.out dlopen-test.cc:7:16: runtime error: call to function my_inc through pointer to incorrect function type 'int (*)(int)' dlopen_so.cc:1: note: my_inc defined here We have two different versions of RTTI for int (*)(int) (_ZTIFiiE) - one in the main executable, and one in the shared library. Before the indirect call to "my_inc" through function pointer, we verify that the prologue of "my_inc" contains a pointer to _ZTIFiiE in the main executable, but my_inc prologue instead contains pointer to _ZTIFiiE in shared library, which is not merged. This leads to a false positive. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs