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