[libc-commits] [libc] [libc][WIP] try to make sysconf work (PR #74166)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Sun Dec 3 20:56:18 PST 2023
SchrodingerZhu wrote:
Hi,
This PR itself does not mean to be merged but provides a way in which we can get the correct aux vector and corresponding page sizes. The previous implementation in `sysconf` simply uses `EXEC_PAGESIZE` which is almost incorrect on architectures other than x86-64.
The major change involves the implementation of `getauxval` (see also https://lwn.net/Articles/928305/):
1. it first checks if the`app` global variable is initialized, if so, it uses the `auxv_ptr` inside it directly.
2. otherwise, since we need to consider the usage in overlay mode where other unit tests can be dependent on `getauxval`, we fall back into two possible approaches:
1. use `prctl` together with `PR_GET_AUXV` to get a copy of the aux array in the userspace. This is a rather new API from linux kernel -- it is only available for 6.0+, but it can handles the situations where `/proc` is not mounted.
2. read the data from `/proc/self/auxv`
If this proposal works, I would split the PR into several parts:
1. implement `prctl`
2. change `app_h` to an object library. Or change `app` to an `inline` variable as in the PR? I can also extract the app initialization part from the startup library. AFAIK, this part is not platform-dependent and should not replicate inside startup. @MaskRay
3. expose `auxv_ptr` from `app`.
4. implement `getauxval` and update `sysconf`.
https://github.com/llvm/llvm-project/pull/74166
More information about the libc-commits
mailing list