elf_aux.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * arch/um/kernel/elf_aux.c
  3. *
  4. * Scan the Elf auxiliary vector provided by the host to extract
  5. * information about vsyscall-page, etc.
  6. *
  7. * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
  8. * Author: Bodo Stroesser (bodo.stroesser@fujitsu-siemens.com)
  9. */
  10. #include <elf.h>
  11. #include <stddef.h>
  12. #include "init.h"
  13. #include "elf_user.h"
  14. #if ELF_CLASS == ELFCLASS32
  15. typedef Elf32_auxv_t elf_auxv_t;
  16. #else
  17. typedef Elf64_auxv_t elf_auxv_t;
  18. #endif
  19. char * elf_aux_platform;
  20. long elf_aux_hwcap;
  21. unsigned long vsyscall_ehdr;
  22. unsigned long vsyscall_end;
  23. unsigned long __kernel_vsyscall;
  24. __init void scan_elf_aux( char **envp)
  25. {
  26. long page_size = 0;
  27. elf_auxv_t * auxv;
  28. while ( *envp++ != NULL) ;
  29. for ( auxv = (elf_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
  30. switch ( auxv->a_type ) {
  31. case AT_SYSINFO:
  32. __kernel_vsyscall = auxv->a_un.a_val;
  33. break;
  34. case AT_SYSINFO_EHDR:
  35. vsyscall_ehdr = auxv->a_un.a_val;
  36. break;
  37. case AT_HWCAP:
  38. elf_aux_hwcap = auxv->a_un.a_val;
  39. break;
  40. case AT_PLATFORM:
  41. elf_aux_platform = auxv->a_un.a_ptr;
  42. break;
  43. case AT_PAGESZ:
  44. page_size = auxv->a_un.a_val;
  45. break;
  46. }
  47. }
  48. if ( ! __kernel_vsyscall || ! vsyscall_ehdr ||
  49. ! elf_aux_hwcap || ! elf_aux_platform ||
  50. ! page_size || (vsyscall_ehdr % page_size) ) {
  51. __kernel_vsyscall = 0;
  52. vsyscall_ehdr = 0;
  53. elf_aux_hwcap = 0;
  54. elf_aux_platform = "i586";
  55. }
  56. else {
  57. vsyscall_end = vsyscall_ehdr + page_size;
  58. }
  59. }