| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* arch/um/kernel/elf_aux.c |
| 4 |
* |
| 5 |
* Scan the ELF auxiliary vector provided by the host to extract |
| 6 |
* information about vsyscall-page, etc. |
| 7 |
* |
| 8 |
* Copyright (C) 2004 Fujitsu Siemens Computers GmbH |
| 9 |
* Author: Bodo Stroesser ([email protected]) |
| 10 |
*/ |
| 11 |
#include <elf.h> |
| 12 |
#include <stddef.h> |
| 13 |
#include <init.h> |
| 14 |
#include <elf_user.h> |
| 15 |
#include <mem_user.h> |
| 16 |
#include "internal.h" |
| 17 |
#include <linux/swab.h> |
| 18 |
|
| 19 |
#if __BITS_PER_LONG == 64 |
| 20 |
typedef Elf64_auxv_t elf_auxv_t; |
| 21 |
#else |
| 22 |
typedef Elf32_auxv_t elf_auxv_t; |
| 23 |
#endif |
| 24 |
|
| 25 |
/* These are initialized very early in boot and never changed */ |
| 26 |
char * elf_aux_platform; |
| 27 |
long elf_aux_hwcap; |
| 28 |
|
| 29 |
__init void scan_elf_aux( char **envp) |
| 30 |
{ |
| 31 |
elf_auxv_t * auxv; |
| 32 |
|
| 33 |
while ( *envp++ != NULL) ; |
| 34 |
|
| 35 |
for ( auxv = (elf_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) { |
| 36 |
switch ( auxv->a_type ) { |
| 37 |
case AT_HWCAP: |
| 38 |
elf_aux_hwcap = auxv->a_un.a_val; |
| 39 |
break; |
| 40 |
case AT_PLATFORM: |
| 41 |
/* elf.h removed the pointer elements from |
| 42 |
* a_un, so we have to use a_val, which is |
| 43 |
* all that's left. |
| 44 |
*/ |
| 45 |
elf_aux_platform = |
| 46 |
(char *) (long) auxv->a_un.a_val; |
| 47 |
break; |
| 48 |
} |
| 49 |
} |
| 50 |
} |