Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use libc::getauxval #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: use libc::getauxval #23

wants to merge 1 commit into from

Conversation

rjzak
Copy link
Member

@rjzak rjzak commented Mar 9, 2024

This is preferred as crt0stack::Reader::from_environ() relies on the global environ pointer and:

  1. The environ pointer is not guaranteed to point to memory before auxv by any standard I am aware of. It just happens to do so in some C library implementations if the environment has not been modified.
  2. The environ pointer is definitely not going to point to memory before auxv after calling any environment modifying function such as setenv(3).

Calling getauxval(3) is the only standards compliant way of accessing values in the auxiliary vector.

Dup of #20 since it has conflicts and tests weren't running.

@rjzak rjzak requested a review from a team as a code owner March 9, 2024 17:57
@rjzak rjzak requested review from bstrie and removed request for a team March 9, 2024 17:57
This is preferred as crt0stack::Reader::from_environ() relies on the
global environ pointer and:
1. The environ pointer is not guaranteed to point to memory before auxv
   by any standard I am aware of. It just happens to do so in some C
   library implementations if the environment has not been modified.
2. The environ pointer is definitely not going to point to memory before
   auxv after calling any environment modifying function such as
   setenv(3).

Calling getauxval(3) is the only standards compliant way of accessing
values in the auxiliary vector.

Co-authored-by: Patrick Oppenlander <[email protected]>
Signed-off-by: Richard Zak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant