comparison projects/compiler-rt/test/cfi/cross-dso/util/cfi_stubs.h @ 131:f476a9ba4795

http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
author mir3636
date Fri, 16 Feb 2018 21:02:11 +0900
parents
children
comparison
equal deleted inserted replaced
130:cc94f0a83282 131:f476a9ba4795
1 // This is a hack to access CFI interface that Android has in libdl.so on
2 // device, but not in the NDK.
3 #include <dlfcn.h>
4 #include <stdint.h>
5 #include <stdlib.h>
6
7 typedef void (*cfi_slowpath_ty)(uint64_t, void *);
8 typedef void (*cfi_slowpath_diag_ty)(uint64_t, void *, void *);
9
10 static cfi_slowpath_ty cfi_slowpath;
11 static cfi_slowpath_diag_ty cfi_slowpath_diag;
12
13 __attribute__((constructor(0), no_sanitize("cfi"))) static void init() {
14 cfi_slowpath = (cfi_slowpath_ty)dlsym(RTLD_NEXT, "__cfi_slowpath");
15 cfi_slowpath_diag =
16 (cfi_slowpath_diag_ty)dlsym(RTLD_NEXT, "__cfi_slowpath_diag");
17 if (!cfi_slowpath || !cfi_slowpath_diag) abort();
18 }
19
20 extern "C" {
21 __attribute__((visibility("hidden"), no_sanitize("cfi"))) void __cfi_slowpath(
22 uint64_t Type, void *Addr) {
23 cfi_slowpath(Type, Addr);
24 }
25
26 __attribute__((visibility("hidden"), no_sanitize("cfi"))) void
27 __cfi_slowpath_diag(uint64_t Type, void *Addr, void *Diag) {
28 cfi_slowpath_diag(Type, Addr, Diag);
29 }
30 }