1 /* 2 * Copyright (C) 2017 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 17 #include <dlfcn.h> 18 #include <errno.h> 19 #include <stdio.h> 20 #if __has_include(<sys/auxv.h>) 21 #include <sys/auxv.h> 22 #endif 23 #include <unistd.h> 24 25 extern int get_value_from_lib(); 26 main()27int main() { 28 bool skip_vdso_check = false; 29 #if __has_include(<sys/auxv.h>) 30 if (getauxval(AT_SYSINFO_EHDR) == 0) { 31 skip_vdso_check = true; 32 } 33 #endif 34 35 if (!skip_vdso_check) { 36 const char* vdso_name = "linux-vdso.so.1"; 37 #if defined(__i386__) 38 vdso_name = "linux-gate.so.1"; 39 #endif 40 void* handle = dlopen(vdso_name, RTLD_NOW); 41 if (handle == nullptr) { 42 printf("%s", dlerror()); 43 return 1; 44 } 45 dlclose(handle); 46 } 47 48 printf("%d", get_value_from_lib()); 49 return 0; 50 } 51