0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <elf.h>
0012 #include <stddef.h>
0013 #include <init.h>
0014 #include <elf_user.h>
0015 #include <mem_user.h>
0016
0017 typedef Elf32_auxv_t elf_auxv_t;
0018
0019
0020 char * elf_aux_platform;
0021 extern long elf_aux_hwcap;
0022 unsigned long vsyscall_ehdr;
0023 unsigned long vsyscall_end;
0024 unsigned long __kernel_vsyscall;
0025
0026 __init void scan_elf_aux( char **envp)
0027 {
0028 long page_size = 0;
0029 elf_auxv_t * auxv;
0030
0031 while ( *envp++ != NULL) ;
0032
0033 for ( auxv = (elf_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
0034 switch ( auxv->a_type ) {
0035 case AT_SYSINFO:
0036 __kernel_vsyscall = auxv->a_un.a_val;
0037
0038 if (__kernel_vsyscall < (unsigned long) envp)
0039 __kernel_vsyscall = 0;
0040 break;
0041 case AT_SYSINFO_EHDR:
0042 vsyscall_ehdr = auxv->a_un.a_val;
0043
0044 if (vsyscall_ehdr < (unsigned long) envp)
0045 vsyscall_ehdr = 0;
0046 break;
0047 case AT_HWCAP:
0048 elf_aux_hwcap = auxv->a_un.a_val;
0049 break;
0050 case AT_PLATFORM:
0051
0052
0053
0054
0055 elf_aux_platform =
0056 (char *) (long) auxv->a_un.a_val;
0057 break;
0058 case AT_PAGESZ:
0059 page_size = auxv->a_un.a_val;
0060 break;
0061 }
0062 }
0063 if ( ! __kernel_vsyscall || ! vsyscall_ehdr ||
0064 ! elf_aux_hwcap || ! elf_aux_platform ||
0065 ! page_size || (vsyscall_ehdr % page_size) ) {
0066 __kernel_vsyscall = 0;
0067 vsyscall_ehdr = 0;
0068 elf_aux_hwcap = 0;
0069 elf_aux_platform = "i586";
0070 }
0071 else {
0072 vsyscall_end = vsyscall_ehdr + page_size;
0073 }
0074 }