Issue |
153666
|
Summary |
[libc[ Rework getauxval to make it usable internally
|
Labels |
libc
|
Assignees |
SchrodingerZhu
|
Reporter |
SchrodingerZhu
|
The auxiliary vector (AUXV) is an important source of system information and is used in multiple places across libc. Unfortunately, since it was implemented before the latest paradigm shift, its functionality is exposed solely through the public interface—something that is not recommended for internal APIs. We should consider moving it to **OSUtils** or another suitable internal module.
The current implementation uses three strategies to obtain AUXV:
1. **Startup routine path** – If the library is using libc’s own startup routine, the AUXV pointer is passed via the platform ABI to the startup function. This pointer is cached directly by `crt0`, and `getauxval` accesses the vector through this cached pointer.
2. **`prctl(PR_GET_AUXV)`** – If the system supports the `prctl` `PR_GET_AUXV` operation, the vector is retrieved via a syscall from cached `mmap`-ed pages.
3. **`/proc/self/auxv`** – If `/proc` is mounted, the vector is read from `/proc/self/auxv`.
The fallback routines (2) and (3) introduce most of the complexity.
During the rework, we might want to simplify this behavior, possibly consolidating or streamlining the retrieval logic.
Looking forward to your thoughts.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs