Skip to content

[libc] Rework getauxval to make it usable internally #153666

@SchrodingerZhu

Description

@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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions