1 #include <android/dlext.h> 2 #include <dlfcn.h> 3 #include <jni.h> 4 #include <stdlib.h> 5 text_before_start_of_gap()6extern "C" void text_before_start_of_gap() {} 7 char end_of_gap[0x1000]; 8 get_inner()9extern "C" void* get_inner() { 10 android_dlextinfo info = {}; 11 info.flags = ANDROID_DLEXT_RESERVED_ADDRESS; 12 13 char* start_of_gap = 14 reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(text_before_start_of_gap) & ~0xfffull) + 15 0x1000; 16 info.reserved_addr = start_of_gap; 17 info.reserved_size = end_of_gap - start_of_gap; 18 19 void *handle = android_dlopen_ext("libsegment_gap_inner.so", RTLD_NOW, &info); 20 if (!handle) { 21 __builtin_trap(); 22 } 23 24 return dlsym(handle, "inner"); 25 } 26