If a library wants to get information from auxv (for instance, AT_HWCAP/AT_HWCAP2), it has a few options, none of them perfectly reliable or ideal: - Be main or the pre-main startup code, and grub through the stack above main. Doesn't work for a library. - Call libc getauxval. Not ideal for libraries that are trying to be libc-independent and/or don't otherwise require anything from other libraries. - Open and read /proc/self/auxv. Doesn't work for libraries that may run in arbitrarily constrained environments that may not have /proc mounted (e.g. libraries that might be used by an init program or a container setup tool). - Assume you're on the main thread and still on the original stack, and try to walk the stack upwards, hoping to find auxv. Extremely bad idea. - Ask the caller to pass auxv in for you. Not ideal for a user-friendly library, and then your caller may have the same problem. Add a prctl that copies current->mm->saved_auxv to a userspace buffer.
Showing the changes to include/uapi (1 of 2 files). Show all
Unified · Split
| @@ -290,4 +290,6 @@ struct prctl_mm_map { · 289 unmodified lines | |||
| 290 | #define PR_SET_VMA 0x53564d41 | 290 | #define PR_SET_VMA 0x53564d41 |
| 291 | # define PR_SET_VMA_ANON_NAME 0 | 291 | # define PR_SET_VMA_ANON_NAME 0 |
| 292 | 292 | ||
| 293 | #define PR_GET_AUXV 0x41555856 | ||
| 294 | |||
| 293 | #endif /* _LINUX_PRCTL_H */ | 295 | #endif /* _LINUX_PRCTL_H */ |