xref: /aosp_15_r20/bionic/tests/libs/dlopen_nodelete_1.cpp (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1*8d67ca89SAndroid Build Coastguard Worker /*
2*8d67ca89SAndroid Build Coastguard Worker  * Copyright (C) 2014 The Android Open Source Project
3*8d67ca89SAndroid Build Coastguard Worker  *
4*8d67ca89SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*8d67ca89SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*8d67ca89SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*8d67ca89SAndroid Build Coastguard Worker  *
8*8d67ca89SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*8d67ca89SAndroid Build Coastguard Worker  *
10*8d67ca89SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*8d67ca89SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*8d67ca89SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*8d67ca89SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*8d67ca89SAndroid Build Coastguard Worker  * limitations under the License.
15*8d67ca89SAndroid Build Coastguard Worker  */
16*8d67ca89SAndroid Build Coastguard Worker 
17*8d67ca89SAndroid Build Coastguard Worker #include <stdint.h>
18*8d67ca89SAndroid Build Coastguard Worker #include <stdlib.h>
19*8d67ca89SAndroid Build Coastguard Worker 
20*8d67ca89SAndroid Build Coastguard Worker uint32_t dlopen_nodelete_1_taxicab_number = 1729;
21*8d67ca89SAndroid Build Coastguard Worker static bool* unload_flag_ptr = nullptr;
22*8d67ca89SAndroid Build Coastguard Worker 
dlopen_nodelete_1_set_unload_flag_ptr(bool * ptr)23*8d67ca89SAndroid Build Coastguard Worker extern "C" void dlopen_nodelete_1_set_unload_flag_ptr(bool* ptr) {
24*8d67ca89SAndroid Build Coastguard Worker   unload_flag_ptr = ptr;
25*8d67ca89SAndroid Build Coastguard Worker }
26*8d67ca89SAndroid Build Coastguard Worker 
unload_guard()27*8d67ca89SAndroid Build Coastguard Worker static void __attribute__((destructor)) unload_guard() {
28*8d67ca89SAndroid Build Coastguard Worker   if (unload_flag_ptr != nullptr) {
29*8d67ca89SAndroid Build Coastguard Worker     *unload_flag_ptr = true;
30*8d67ca89SAndroid Build Coastguard Worker   }
31*8d67ca89SAndroid Build Coastguard Worker }
32