auxv.c (211416) | auxv.c (231868) |
---|---|
1/*- | 1/*- |
2 * Copyright 2010 Konstantin Belousov | 2 * Copyright 2010, 2012 Konstantin Belousov <kib@FreeBSD.ORG>. |
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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 9 unchanged lines hidden (view full) --- 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 */ 26 27#include <sys/cdefs.h> | 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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 9 unchanged lines hidden (view full) --- 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/lib/libc/gen/aux.c 211416 2010-08-17 09:13:26Z kib $"); | 28__FBSDID("$FreeBSD: head/lib/libc/gen/aux.c 231868 2012-02-17 10:49:29Z kib $"); |
29 30#include "namespace.h" 31#include <elf.h> 32#include <errno.h> 33#include <link.h> 34#include <pthread.h> 35#include <string.h> 36#include "un-namespace.h" 37#include "libc_private.h" 38 | 29 30#include "namespace.h" 31#include <elf.h> 32#include <errno.h> 33#include <link.h> 34#include <pthread.h> 35#include <string.h> 36#include "un-namespace.h" 37#include "libc_private.h" 38 |
39Elf_Auxinfo *__elf_aux_vector; | 39extern char **environ; 40extern int _DYNAMIC; 41#pragma weak _DYNAMIC |
40 | 42 |
41static pthread_once_t aux_once = PTHREAD_ONCE_INIT; | 43void *__elf_aux_vector; 44static pthread_once_t aux_vector_once = PTHREAD_ONCE_INIT; |
42 | 45 |
46static void 47init_aux_vector_once(void) 48{ 49 Elf_Addr *sp; 50 51 sp = (Elf_Addr *)environ; 52 while (*sp++ != 0) 53 ; 54 __elf_aux_vector = (Elf_Auxinfo *)sp; 55} 56 57void 58__init_elf_aux_vector(void) 59{ 60 61 if (&_DYNAMIC != NULL) 62 return; 63 _once(&aux_vector_once, init_aux_vector_once); 64} 65 66static pthread_once_t aux_once = PTHREAD_ONCE_INIT; |
|
43static int pagesize, osreldate, canary_len, ncpus, pagesizes_len; 44static char *canary, *pagesizes; 45 46static void 47init_aux(void) 48{ 49 Elf_Auxinfo *aux; 50 --- 30 unchanged lines hidden (view full) --- 81 } 82} 83 84int 85_elf_aux_info(int aux, void *buf, int buflen) 86{ 87 int res; 88 | 67static int pagesize, osreldate, canary_len, ncpus, pagesizes_len; 68static char *canary, *pagesizes; 69 70static void 71init_aux(void) 72{ 73 Elf_Auxinfo *aux; 74 --- 30 unchanged lines hidden (view full) --- 105 } 106} 107 108int 109_elf_aux_info(int aux, void *buf, int buflen) 110{ 111 int res; 112 |
113 __init_elf_aux_vector(); |
|
89 if (__elf_aux_vector == NULL) 90 return (ENOSYS); 91 _once(&aux_once, init_aux); 92 93 switch (aux) { 94 case AT_CANARY: 95 if (canary != NULL && canary_len >= buflen) { 96 memcpy(buf, canary, buflen); --- 50 unchanged lines hidden --- | 114 if (__elf_aux_vector == NULL) 115 return (ENOSYS); 116 _once(&aux_once, init_aux); 117 118 switch (aux) { 119 case AT_CANARY: 120 if (canary != NULL && canary_len >= buflen) { 121 memcpy(buf, canary, buflen); --- 50 unchanged lines hidden --- |