klibc-bot for H. Peter Anvin
2014-Jan-25 04:36 UTC
[klibc] [klibc:master] auxv: convert auxiliary vector into an array; define getauxval()
Commit-ID: 45e09deb6a0a4fcb3a56efb7e18807b2800e358f Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=45e09deb6a0a4fcb3a56efb7e18807b2800e358f Author: H. Peter Anvin <hpa at zytor.com> AuthorDate: Fri, 24 Jan 2014 20:26:04 -0800 Committer: H. Peter Anvin <hpa at zytor.com> CommitDate: Fri, 24 Jan 2014 20:28:23 -0800 auxv: convert auxiliary vector into an array; define getauxval() Convert the ELF auxiliary vector into an array. Define getauxval() as an inline accessor to that array. Signed-off-by: H. Peter Anvin <hpa at zytor.com> --- usr/include/sys/auxv.h | 16 ++++++++++++++++ usr/include/sys/elfcommon.h | 2 ++ usr/klibc/libc_init.c | 25 ++++++++++++------------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/usr/include/sys/auxv.h b/usr/include/sys/auxv.h new file mode 100644 index 0000000..08fcfcf --- /dev/null +++ b/usr/include/sys/auxv.h @@ -0,0 +1,16 @@ +#ifndef _SYS_AUXV_H +#define _SYS_AUXV_H + +#include <klibc/compiler.h> +#include <elf.h> + +#define _AUXVAL_MAX AT_SYSINFO_EHDR + +__extern unsigned long __auxval[_AUXVAL_MAX]; + +__static_inline unsigned long getauxval(unsigned long __t) +{ + return (__t >= _AUXVAL_MAX) ? 0 : __auxval[__t]; +} + +#endif /* _SYS_AUXV_H */ diff --git a/usr/include/sys/elfcommon.h b/usr/include/sys/elfcommon.h index 300ff4e..603b0ce 100644 --- a/usr/include/sys/elfcommon.h +++ b/usr/include/sys/elfcommon.h @@ -107,6 +107,8 @@ #define AT_CLKTCK 17 /* frequency at which times() increments */ /* 18..22 = ? */ #define AT_SECURE 23 /* secure mode boolean */ +#define AT_SYSINFO 32 /* vdso entry point address */ +#define AT_SYSINFO_EHDR 33 /* vdso header address */ /* Program header permission flags */ #define PF_X 0x1 diff --git a/usr/klibc/libc_init.c b/usr/klibc/libc_init.c index 8d18820..1087f95 100644 --- a/usr/klibc/libc_init.c +++ b/usr/klibc/libc_init.c @@ -24,6 +24,7 @@ #include <stdint.h> #include <klibc/compiler.h> #include <elf.h> +#include <sys/auxv.h> #include "atexit.h" /* This file is included from __static_init.c or __shared_init.c */ @@ -35,12 +36,14 @@ char **environ; unsigned int __page_size, __page_shift; struct auxentry { - uintptr_t type; - uintptr_t v; + unsigned long type; + unsigned long v; }; extern void __init_stdio(void); +unsigned long __auxval[_AUXVAL_MAX]; + __noreturn __libc_init(uintptr_t * elfdata, void (*onexit) (void)) { int argc; @@ -76,20 +79,16 @@ __noreturn __libc_init(uintptr_t * elfdata, void (*onexit) (void)) auxentry = (struct auxentry *)(envend + 1); while (auxentry->type) { - switch (auxentry->type) { -#if SHARED - case AT_ENTRY: - MAIN = (main_t) (auxentry->v); - break; -#endif - case AT_PAGESZ: - page_size = (unsigned int)(auxentry->v); - break; - } + if (auxentry->type < _AUXVAL_MAX) + __auxval[auxentry->type] = auxentry->v; auxentry++; } - __page_size = page_size; +#if SHARED + MAIN = (main_t) __auxval[AT_ENTRY]; +#endif + + __page_size = page_size = __auxval[AT_PAGESZ]; #if __GNUC__ >= 4 /* unsigned int is 32 bits on all our architectures */
Seemingly Similar Threads
- [klibc:master] Move architecture-specific initialization to arch/
- [klibc:master] Inline __arch_libcinit()
- [klibc:master] <sys/auxv.h>: add missing dependency < klibc/extern.h>
- [PATCH] Kbuild for klibc and nfsmount: fix multiple definitions
- 1.3.3: powerpc portability problems