Repository navigation
Expand file tree
/
Copy pathAndroid.bp
More file actions
93 lines (83 loc) · 3.5 KB
/
Copy pathAndroid.bp
File metadata and controls
93 lines (83 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// libnb -- a native-bridge shim that patches Intel Houdini in memory.
//
// ART dlopen()s the library named in ro.dalvik.vm.native.bridge and resolves
// one symbol from it, "NativeBridgeItf". This module provides that symbol:
// it loads the real translator (libhoudini.so), patches a few bytes of it in
// memory, and forwards every callback.
//
// The module is named "libnb", so it installs as /system/lib64/libnb.so.
//
// See README.md in this directory for what the patches are and why.
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
cc_library_shared {
name: "libnb",
srcs: [
"src/main.cpp",
"src/patch_engine.cpp",
"src/houdini_17_39885_patches.cpp",
],
local_include_dirs: [
"include",
],
// jni.h, for the JNIEnv that NativeBridgeRuntimeCallbacks carries.
header_libs: [
"jni_headers",
],
cflags: [
"-Wall",
"-Werror",
"-Wno-unused-parameter",
// Only NativeBridgeItf may leave this library.
//
// The shim is dlopen()ed into the zygote, and the zygote's namespace
// is the one every app in the system inherits. A statically linked
// libc++ puts ~1600 of its symbols in the dynamic symbol table by
// default, and those symbols would then INTERPOSE on the app's own
// libc++ symbols -- in every app on the device, for a shim that has
// no business exporting anything. -fvisibility=hidden plus
// --exclude-libs,ALL keeps the exported set to the one symbol ART
// asks for (LIBNB_EXPORT in main.cpp forces it back to default
// visibility).
"-fvisibility=hidden",
// The name of the REAL bridge, and the path it is loaded from.
//
// USE_NATIVEBRIDGE may or may not already carry the "lib" prefix:
// main.cpp adds the prefix only when it is missing, so both
// "houdini" and "libhoudini" work.
"-DUSE_NATIVEBRIDGE=\"libhoudini\"",
"-DREAL_BRIDGE_PATH=\"/system/lib64/libhoudini.so\"",
],
ldflags: [
"-Wl,--exclude-libs,ALL",
],
shared_libs: [
"libdl",
"liblog",
// The real translator, as a DT_NEEDED.
//
// This is what makes the EXEC path work: /system/bin/houdini64 (the
// binfmt_misc interpreter for arm64 binaries) links libhoudini.so
// directly and calls its symbols, so it never calls a libnb
// callback. With libnb in houdini64's DT_NEEDED chain and the
// translator in libnb's, the loader brings the translator in
// through libnb, libnb's constructor patches the image it is looking
// at, and houdini64 then calls the patched code. The same chain is
// what ART uses, so there is only ever one copy of the translator in
// the process.
//
// The module comes from the tree that ships the translator:
// https://github.com/SGNight/vendor_intel_proprietary_houdini
// It defines a module named "libhoudini", which is what is named
// here.
"libhoudini",
],
// The shim pulls in no C++ runtime of its own that matters, and a static
// libc++ keeps /system/lib64 from growing a second copy of it.
stl: "c++_static",
// The native bridge is loaded by the 64-bit zygote, so there is no 32-bit
// variant of it to build. The translator is arm64-only too (there is no
// 32-bit ARM path in Houdini), and the host it runs on is x86_64.
compile_multilib: "64",
}