elf_auxvec.rst 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ==================================
  3. x86-specific ELF Auxiliary Vectors
  4. ==================================
  5. This document describes the semantics of the x86 auxiliary vectors.
  6. Introduction
  7. ============
  8. ELF Auxiliary vectors enable the kernel to efficiently provide
  9. configuration-specific parameters to userspace. In this example, a program
  10. allocates an alternate stack based on the kernel-provided size::
  11. #include <sys/auxv.h>
  12. #include <elf.h>
  13. #include <signal.h>
  14. #include <stdlib.h>
  15. #include <assert.h>
  16. #include <err.h>
  17. #ifndef AT_MINSIGSTKSZ
  18. #define AT_MINSIGSTKSZ 51
  19. #endif
  20. ....
  21. stack_t ss;
  22. ss.ss_sp = malloc(ss.ss_size);
  23. assert(ss.ss_sp);
  24. ss.ss_size = getauxval(AT_MINSIGSTKSZ) + SIGSTKSZ;
  25. ss.ss_flags = 0;
  26. if (sigaltstack(&ss, NULL))
  27. err(1, "sigaltstack");
  28. The exposed auxiliary vectors
  29. =============================
  30. AT_SYSINFO is used for locating the vsyscall entry point. It is not
  31. exported on 64-bit mode.
  32. AT_SYSINFO_EHDR is the start address of the page containing the vDSO.
  33. AT_MINSIGSTKSZ denotes the minimum stack size required by the kernel to
  34. deliver a signal to user-space. AT_MINSIGSTKSZ comprehends the space
  35. consumed by the kernel to accommodate the user context for the current
  36. hardware configuration. It does not comprehend subsequent user-space stack
  37. consumption, which must be added by the user. (e.g. Above, user-space adds
  38. SIGSTKSZ to AT_MINSIGSTKSZ.)