xref: /aosp_15_r20/bionic/tests/libs/dlopen_b.cpp (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1*8d67ca89SAndroid Build Coastguard Worker #include <dlfcn.h>
2*8d67ca89SAndroid Build Coastguard Worker 
3*8d67ca89SAndroid Build Coastguard Worker // Work around for http://b/20049306, which isn't going to be fixed.
4*8d67ca89SAndroid Build Coastguard Worker int defeat_sibling_call_optimization = 0;
5*8d67ca89SAndroid Build Coastguard Worker 
dlopen_b()6*8d67ca89SAndroid Build Coastguard Worker extern "C" void* dlopen_b() {
7*8d67ca89SAndroid Build Coastguard Worker   // This is supposed to succeed because this library has DT_RUNPATH
8*8d67ca89SAndroid Build Coastguard Worker   // for libtest_dt_runpath_x.so which should be taken into account
9*8d67ca89SAndroid Build Coastguard Worker   // by dlopen.
10*8d67ca89SAndroid Build Coastguard Worker   void *handle = dlopen("libtest_dt_runpath_x.so", RTLD_NOW);
11*8d67ca89SAndroid Build Coastguard Worker   if (handle != nullptr) {
12*8d67ca89SAndroid Build Coastguard Worker     defeat_sibling_call_optimization++;
13*8d67ca89SAndroid Build Coastguard Worker     return handle;
14*8d67ca89SAndroid Build Coastguard Worker   }
15*8d67ca89SAndroid Build Coastguard Worker   return nullptr;
16*8d67ca89SAndroid Build Coastguard Worker }
17