dlfcn.c (229768) | dlfcn.c (231868) |
---|---|
1/*- 2 * Copyright (c) 1998 John D. Polstra 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998 John D. Polstra 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/lib/libc/gen/dlfcn.c 229768 2012-01-07 10:33:01Z kib $"); | 28__FBSDID("$FreeBSD: head/lib/libc/gen/dlfcn.c 231868 2012-02-17 10:49:29Z kib $"); |
29 30/* 31 * Linkage to services provided by the dynamic linker. 32 */ 33#include <sys/mman.h> 34#include <dlfcn.h> 35#include <link.h> 36#include <stddef.h> | 29 30/* 31 * Linkage to services provided by the dynamic linker. 32 */ 33#include <sys/mman.h> 34#include <dlfcn.h> 35#include <link.h> 36#include <stddef.h> |
37#include "namespace.h" 38#include <pthread.h> 39#include "un-namespace.h" 40#include "libc_private.h" |
|
37 38static char sorry[] = "Service unavailable"; 39 40/* 41 * For ELF, the dynamic linker directly resolves references to its 42 * services to functions inside the dynamic linker itself. These 43 * weak-symbol stubs are necessary so that "ld" won't complain about 44 * undefined symbols. The stubs are executed only when the program is --- 88 unchanged lines hidden (view full) --- 133 134#pragma weak _rtld_thread_init 135void 136_rtld_thread_init(void * li) 137{ 138 _rtld_error(sorry); 139} 140 | 41 42static char sorry[] = "Service unavailable"; 43 44/* 45 * For ELF, the dynamic linker directly resolves references to its 46 * services to functions inside the dynamic linker itself. These 47 * weak-symbol stubs are necessary so that "ld" won't complain about 48 * undefined symbols. The stubs are executed only when the program is --- 88 unchanged lines hidden (view full) --- 137 138#pragma weak _rtld_thread_init 139void 140_rtld_thread_init(void * li) 141{ 142 _rtld_error(sorry); 143} 144 |
145static pthread_once_t dl_phdr_info_once = PTHREAD_ONCE_INIT; 146static struct dl_phdr_info phdr_info; 147 148static void 149dl_init_phdr_info(void) 150{ 151 Elf_Auxinfo *auxp; 152 size_t phent; 153 unsigned int i; 154 155 phent = 0; 156 for (auxp = __elf_aux_vector; auxp->a_type != AT_NULL; auxp++) { 157 switch (auxp->a_type) { 158 case AT_BASE: 159 phdr_info.dlpi_addr = (Elf_Addr)auxp->a_un.a_ptr; 160 break; 161 case AT_EXECPATH: 162 phdr_info.dlpi_name = (const char *)auxp->a_un.a_ptr; 163 break; 164 case AT_PHDR: 165 phdr_info.dlpi_phdr = 166 (const Elf_Phdr *)auxp->a_un.a_ptr; 167 break; 168 case AT_PHENT: 169 phent = auxp->a_un.a_val; 170 break; 171 case AT_PHNUM: 172 phdr_info.dlpi_phnum = (Elf_Half)auxp->a_un.a_val; 173 break; 174 } 175 } 176 for (i = 0; i < phdr_info.dlpi_phnum; i++) { 177 if (phdr_info.dlpi_phdr[i].p_type == PT_TLS) { 178 phdr_info.dlpi_tls_modid = 1; 179 phdr_info.dlpi_tls_data = 180 (void*)phdr_info.dlpi_phdr[i].p_vaddr; 181 } 182 } 183 phdr_info.dlpi_adds = 1; 184} 185 |
|
141#pragma weak dl_iterate_phdr 142int 143dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), 144 void *data) 145{ | 186#pragma weak dl_iterate_phdr 187int 188dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), 189 void *data) 190{ |
146 _rtld_error(sorry); 147 return 0; | 191 192 __init_elf_aux_vector(); 193 if (__elf_aux_vector == NULL) 194 return (1); 195 _once(&dl_phdr_info_once, dl_init_phdr_info); 196 return (callback(&phdr_info, sizeof(phdr_info), data)); |
148} 149 150#pragma weak fdlopen 151void * 152fdlopen(int fd, int mode) 153{ 154 155 _rtld_error(sorry); --- 31 unchanged lines hidden --- | 197} 198 199#pragma weak fdlopen 200void * 201fdlopen(int fd, int mode) 202{ 203 204 _rtld_error(sorry); --- 31 unchanged lines hidden --- |