Warning: This file is not a C or C++ file. It does not have highlighting.

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
7typedef void (*cfi_slowpath_ty)(uint64_t, void *);
8typedef void (*cfi_slowpath_diag_ty)(uint64_t, void *, void *);
9
10static cfi_slowpath_ty cfi_slowpath;
11static 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
20extern "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}
31

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of compiler-rt/test/cfi/cross-dso/util/cfi_stubs.h