1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16#include <dlfcn.h> 17#include <stdio.h> 18 19extern int test_dlsym_symbol; 20 21int test_dlsym_symbol = -1; 22 23extern "C" int* lookup_dlsym_symbol_using_RTLD_DEFAULT() { 24 dlerror(); 25 int* result = static_cast<int*>(dlsym(RTLD_DEFAULT, "test_dlsym_symbol")); 26 // TODO: remove this once b/20049306 is fixed 27 if (result == nullptr) { 28 printf("Cannot find the answer\n"); 29 } 30 return result; 31} 32 33extern "C" int* lookup_dlsym_symbol2_using_RTLD_DEFAULT() { 34 dlerror(); 35 int* result = static_cast<int*>(dlsym(RTLD_DEFAULT, "test_dlsym_symbol2")); 36 // TODO: remove this once b/20049306 is fixed 37 if (result == nullptr) { 38 printf("Cannot find the answer\n"); 39 } 40 return result; 41} 42 43extern "C" int* lookup_dlsym_symbol_using_RTLD_NEXT() { 44 dlerror(); 45 int* result = static_cast<int*>(dlsym(RTLD_NEXT, "test_dlsym_symbol")); 46 // TODO: remove this once b/20049306 is fixed 47 if (result == nullptr) { 48 printf("Cannot find the answer\n"); 49 } 50 return result; 51} 52 53