dlfcn.cpp revision 650be4e584eeab3591b9e273bfd6d169eea60853
13b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes/* 23b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * Copyright (C) 2007 The Android Open Source Project 33b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * 43b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 53b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * you may not use this file except in compliance with the License. 63b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * You may obtain a copy of the License at 73b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * 83b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 93b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * 103b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * Unless required by applicable law or agreed to in writing, software 113b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 123b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * See the License for the specific language governing permissions and 143b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes * limitations under the License. 153b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes */ 163b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 175419b9474753d25dff947c7740532f86d130c0beElliott Hughes#include "linker.h" 185419b9474753d25dff947c7740532f86d130c0beElliott Hughes 193b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#include <dlfcn.h> 203b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#include <pthread.h> 213b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#include <stdio.h> 225419b9474753d25dff947c7740532f86d130c0beElliott Hughes#include <stdlib.h> 233b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 245419b9474753d25dff947c7740532f86d130c0beElliott Hughes#include <bionic/pthread_internal.h> 255419b9474753d25dff947c7740532f86d130c0beElliott Hughes#include <private/bionic_tls.h> 263b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#include <private/ScopedPthreadMutexLocker.h> 275419b9474753d25dff947c7740532f86d130c0beElliott Hughes#include <private/ThreadLocalBuffer.h> 283b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 293b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes/* This file hijacks the symbols stubbed out in libdl.so. */ 303b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 315419b9474753d25dff947c7740532f86d130c0beElliott Hughesstatic pthread_mutex_t gDlMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; 323b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 335419b9474753d25dff947c7740532f86d130c0beElliott Hughesstatic const char* __bionic_set_dlerror(char* new_value) { 345419b9474753d25dff947c7740532f86d130c0beElliott Hughes void* tls = const_cast<void*>(__get_tls()); 355419b9474753d25dff947c7740532f86d130c0beElliott Hughes char** dlerror_slot = &reinterpret_cast<char**>(tls)[TLS_SLOT_DLERROR]; 363b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 375419b9474753d25dff947c7740532f86d130c0beElliott Hughes const char* old_value = *dlerror_slot; 385419b9474753d25dff947c7740532f86d130c0beElliott Hughes *dlerror_slot = new_value; 395419b9474753d25dff947c7740532f86d130c0beElliott Hughes return old_value; 405419b9474753d25dff947c7740532f86d130c0beElliott Hughes} 413b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 425419b9474753d25dff947c7740532f86d130c0beElliott Hughesstatic void __bionic_format_dlerror(const char* msg, const char* detail) { 435419b9474753d25dff947c7740532f86d130c0beElliott Hughes char* buffer = __get_thread()->dlerror_buffer; 445419b9474753d25dff947c7740532f86d130c0beElliott Hughes strlcpy(buffer, msg, __BIONIC_DLERROR_BUFFER_SIZE); 453b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes if (detail != NULL) { 465419b9474753d25dff947c7740532f86d130c0beElliott Hughes strlcat(buffer, ": ", __BIONIC_DLERROR_BUFFER_SIZE); 475419b9474753d25dff947c7740532f86d130c0beElliott Hughes strlcat(buffer, detail, __BIONIC_DLERROR_BUFFER_SIZE); 483b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 495419b9474753d25dff947c7740532f86d130c0beElliott Hughes 505419b9474753d25dff947c7740532f86d130c0beElliott Hughes __bionic_set_dlerror(buffer); 515419b9474753d25dff947c7740532f86d130c0beElliott Hughes} 525419b9474753d25dff947c7740532f86d130c0beElliott Hughes 535419b9474753d25dff947c7740532f86d130c0beElliott Hughesconst char* dlerror() { 545419b9474753d25dff947c7740532f86d130c0beElliott Hughes const char* old_value = __bionic_set_dlerror(NULL); 555419b9474753d25dff947c7740532f86d130c0beElliott Hughes return old_value; 563b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes} 573b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 58cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughesvoid android_update_LD_LIBRARY_PATH(const char* ld_library_path) { 59cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes ScopedPthreadMutexLocker locker(&gDlMutex); 60cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes do_android_update_LD_LIBRARY_PATH(ld_library_path); 61cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes} 62cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes 63e66190d2a97a713ae4b4786e60ca3d67ab8aa192Elliott Hughesvoid* dlopen(const char* filename, int flags) { 6422d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes ScopedPthreadMutexLocker locker(&gDlMutex); 65e66190d2a97a713ae4b4786e60ca3d67ab8aa192Elliott Hughes soinfo* result = do_dlopen(filename, flags); 663b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes if (result == NULL) { 67650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughes __bionic_format_dlerror("dlopen failed", linker_get_error_buffer()); 683b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes return NULL; 693b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 703b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes return result; 713b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes} 723b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 733b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughesvoid* dlsym(void* handle, const char* symbol) { 7422d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes ScopedPthreadMutexLocker locker(&gDlMutex); 753b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 765419b9474753d25dff947c7740532f86d130c0beElliott Hughes if (handle == NULL) { 775419b9474753d25dff947c7740532f86d130c0beElliott Hughes __bionic_format_dlerror("dlsym library handle is null", NULL); 783b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes return NULL; 793b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 805419b9474753d25dff947c7740532f86d130c0beElliott Hughes if (symbol == NULL) { 815419b9474753d25dff947c7740532f86d130c0beElliott Hughes __bionic_format_dlerror("dlsym symbol name is null", NULL); 823b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes return NULL; 833b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 843b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 853b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes soinfo* found = NULL; 863b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes Elf32_Sym* sym = NULL; 873b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes if (handle == RTLD_DEFAULT) { 88d4ee82dfa3ba01baa10e3ca48fcb31a27b8a4e81Brian Carlstrom sym = dlsym_linear_lookup(symbol, &found, NULL); 893b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } else if (handle == RTLD_NEXT) { 903b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes void* ret_addr = __builtin_return_address(0); 913b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes soinfo* si = find_containing_library(ret_addr); 923b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 933b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes sym = NULL; 943b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes if (si && si->next) { 95d4ee82dfa3ba01baa10e3ca48fcb31a27b8a4e81Brian Carlstrom sym = dlsym_linear_lookup(symbol, &found, si->next); 963b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 973b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } else { 98d4ee82dfa3ba01baa10e3ca48fcb31a27b8a4e81Brian Carlstrom found = reinterpret_cast<soinfo*>(handle); 99d4ee82dfa3ba01baa10e3ca48fcb31a27b8a4e81Brian Carlstrom sym = dlsym_handle_lookup(found, symbol); 1003b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 1013b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1025419b9474753d25dff947c7740532f86d130c0beElliott Hughes if (sym != NULL) { 1033b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes unsigned bind = ELF32_ST_BIND(sym->st_info); 1043b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1055419b9474753d25dff947c7740532f86d130c0beElliott Hughes if (bind == STB_GLOBAL && sym->st_shndx != 0) { 1063b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes unsigned ret = sym->st_value + found->load_bias; 1073b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes return (void*) ret; 1083b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 1093b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1105419b9474753d25dff947c7740532f86d130c0beElliott Hughes __bionic_format_dlerror("symbol found but not global", symbol); 1113b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes return NULL; 1123b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } else { 1135419b9474753d25dff947c7740532f86d130c0beElliott Hughes __bionic_format_dlerror("undefined symbol", symbol); 1143b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes return NULL; 1153b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 1163b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes} 1173b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1183b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughesint dladdr(const void* addr, Dl_info* info) { 11922d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes ScopedPthreadMutexLocker locker(&gDlMutex); 1203b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1213b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes // Determine if this address can be found in any library currently mapped. 1223b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes soinfo* si = find_containing_library(addr); 1233b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes if (si == NULL) { 1243b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes return 0; 1253b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 1263b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1273b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes memset(info, 0, sizeof(Dl_info)); 1283b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1293b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes info->dli_fname = si->name; 1303b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes // Address at which the shared object is loaded. 1313b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes info->dli_fbase = (void*) si->base; 1323b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1333b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes // Determine if any symbol in the library contains the specified address. 134d4ee82dfa3ba01baa10e3ca48fcb31a27b8a4e81Brian Carlstrom Elf32_Sym *sym = dladdr_find_symbol(si, addr); 1353b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes if (sym != NULL) { 1363b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes info->dli_sname = si->strtab + sym->st_name; 1373b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes info->dli_saddr = (void*)(si->load_bias + sym->st_value); 1383b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes } 1393b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1403b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes return 1; 1413b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes} 1423b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1433b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughesint dlclose(void* handle) { 14422d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes ScopedPthreadMutexLocker locker(&gDlMutex); 145d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes return do_dlclose(reinterpret_cast<soinfo*>(handle)); 1463b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes} 1473b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1483b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#if defined(ANDROID_ARM_LINKER) 149cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes// 0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667 150cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes// 0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890 1513b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#define ANDROID_LIBDL_STRTAB \ 152cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0dl_unwind_find_exidx\0" 1533b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1543b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#elif defined(ANDROID_X86_LINKER) || defined(ANDROID_MIPS_LINKER) 155cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes// 0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667 156cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes// 0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890 1573b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#define ANDROID_LIBDL_STRTAB \ 158cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0dl_iterate_phdr\0" 1593b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#else 1603b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#error Unsupported architecture. Only ARM, MIPS, and x86 are presently supported. 1613b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#endif 1623b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1633b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes// name_offset: starting index of the name in libdl_info.strtab 1643b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#define ELF32_SYM_INITIALIZER(name_offset, value, shndx) \ 1653b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes { name_offset, \ 1663b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes reinterpret_cast<Elf32_Addr>(reinterpret_cast<void*>(value)), \ 1673b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes /* st_size */ 0, \ 1683b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes (shndx == 0) ? 0 : (STB_GLOBAL << 4), \ 1693b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes /* st_other */ 0, \ 1703b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes shndx } 1713b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 1725419b9474753d25dff947c7740532f86d130c0beElliott Hughesstatic Elf32_Sym gLibDlSymtab[] = { 1733b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes // Total length of libdl_info.strtab, including trailing 0. 1743b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes // This is actually the STH_UNDEF entry. Technically, it's 1753b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes // supposed to have st_name == 0, but instead, it points to an index 1763b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes // in the strtab with a \0 to make iterating through the symtab easier. 1773b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes ELF32_SYM_INITIALIZER(sizeof(ANDROID_LIBDL_STRTAB) - 1, NULL, 0), 1783b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes ELF32_SYM_INITIALIZER( 0, &dlopen, 1), 1793b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes ELF32_SYM_INITIALIZER( 7, &dlclose, 1), 1803b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes ELF32_SYM_INITIALIZER(15, &dlsym, 1), 1813b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes ELF32_SYM_INITIALIZER(21, &dlerror, 1), 1823b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes ELF32_SYM_INITIALIZER(29, &dladdr, 1), 183cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes ELF32_SYM_INITIALIZER(36, &android_update_LD_LIBRARY_PATH, 1), 1843b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#if defined(ANDROID_ARM_LINKER) 185cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes ELF32_SYM_INITIALIZER(67, &dl_unwind_find_exidx, 1), 1863b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#elif defined(ANDROID_X86_LINKER) || defined(ANDROID_MIPS_LINKER) 187cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes ELF32_SYM_INITIALIZER(67, &dl_iterate_phdr, 1), 1883b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#endif 1893b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes}; 1903b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 19122d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// Fake out a hash table with a single bucket. 19222d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// A search of the hash table will look through 1935419b9474753d25dff947c7740532f86d130c0beElliott Hughes// gLibDlSymtab starting with index [1], then 1945419b9474753d25dff947c7740532f86d130c0beElliott Hughes// use gLibDlChains to find the next index to 1955419b9474753d25dff947c7740532f86d130c0beElliott Hughes// look at. gLibDlChains should be set up to 1965419b9474753d25dff947c7740532f86d130c0beElliott Hughes// walk through every element in gLibDlSymtab, 19722d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// and then end with 0 (sentinel value). 19822d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// 1995419b9474753d25dff947c7740532f86d130c0beElliott Hughes// That is, gLibDlChains should look like 20022d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// { 0, 2, 3, ... N, 0 } where N is the number 2015419b9474753d25dff947c7740532f86d130c0beElliott Hughes// of actual symbols, or nelems(gLibDlSymtab)-1 2025419b9474753d25dff947c7740532f86d130c0beElliott Hughes// (since the first element of gLibDlSymtab is not 20322d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// a real symbol). 20422d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// 20522d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// (see soinfo_elf_lookup()) 20622d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// 20722d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// Note that adding any new symbols here requires 20822d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// stubbing them out in libdl. 2095419b9474753d25dff947c7740532f86d130c0beElliott Hughesstatic unsigned gLibDlBuckets[1] = { 1 }; 210cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughesstatic unsigned gLibDlChains[8] = { 0, 2, 3, 4, 5, 6, 7, 0 }; 2113b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 21222d629211d72adaf46f3fc48f59540f8e5798b1eElliott Hughes// This is used by the dynamic linker. Every process gets these symbols for free. 2133b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughessoinfo libdl_info = { 21420aa6c0f4cbe6fdaba8938536a7b80270cfe7203Pavel Chupin "libdl.so", 2153b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 2163b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes phdr: 0, phnum: 0, 2173b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes entry: 0, base: 0, size: 0, 2183b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes unused: 0, dynamic: 0, unused2: 0, unused3: 0, 2193b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes next: 0, 2203b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 2213b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes flags: FLAG_LINKED, 2223b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 2233b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes strtab: ANDROID_LIBDL_STRTAB, 2245419b9474753d25dff947c7740532f86d130c0beElliott Hughes symtab: gLibDlSymtab, 2253b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 2263b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes nbucket: 1, 227cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughes nchain: 8, 2285419b9474753d25dff947c7740532f86d130c0beElliott Hughes bucket: gLibDlBuckets, 2295419b9474753d25dff947c7740532f86d130c0beElliott Hughes chain: gLibDlChains, 2303b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 2313b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes plt_got: 0, plt_rel: 0, plt_rel_count: 0, rel: 0, rel_count: 0, 2323b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes preinit_array: 0, preinit_array_count: 0, init_array: 0, init_array_count: 0, 2333b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes fini_array: 0, fini_array_count: 0, init_func: 0, fini_func: 0, 2343b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 2353b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#if defined(ANDROID_ARM_LINKER) 2363b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes ARM_exidx: 0, ARM_exidx_count: 0, 2373b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#elif defined(ANDROID_MIPS_LINKER) 2383b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes mips_symtabno: 0, mips_local_gotno: 0, mips_gotsym: 0, 2393b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes#endif 2403b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes 2413b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes refcount: 0, 2423b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes { l_addr: 0, l_name: 0, l_ld: 0, l_next: 0, l_prev: 0, }, 243d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes constructors_called: false, 244d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes load_bias: 0, 2455ae44f302b7d1d19f25c4c6f125e32dc369961d9Ard Biesheuvel has_text_relocations: false, 2465ae44f302b7d1d19f25c4c6f125e32dc369961d9Ard Biesheuvel has_DT_SYMBOLIC: true, 2473b297c40794b23d50cb5240f9b03f6ef25fd98dbElliott Hughes}; 248