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

Handle static PIE in startup_tls_info. #850

Merged
merged 2 commits into from
Sep 25, 2023
Merged

Conversation

sunfishcode
Copy link
Member

In static PIE mode, we don't get a PT_PHDR segment, but we do get a PT_DYNAMIC segment, and we can compare that against the _DYNAMIC symbol that the linker creates and dynamic linker relocates to learn our virtual address offset.

In static PIE mode, we don't get a `PT_PHDR` segment, but we do get a
`PT_DYNAMIC` segment, and we can compare that against the `_DYNAMIC`
symbol that the linker creates and dynamic linker relocates to learn
our virtual address offset.
This makes the code independent of whether the offset is positive or
negative.
sunfishcode added a commit to sunfishcode/origin that referenced this pull request Sep 25, 2023
rustix exports all the functions needed to do what `startup_tls_info`
does, so the code can live in origin, and it makes more sense to have
it in origin.

Also incorporate bytecodealliance/rustix#850, handling static PIE by
adding logic to compute the load offset using the difference between
the `PT_DYNAMIC` static address and the dynamic address of the
`_DYNAMIC` symbol.
@sunfishcode
Copy link
Member Author

I think a better approach here is to move startup_tls_into out of rustix and into origin, which I've started in sunfishcode/origin#58, but for now, it makes sense to fix rustix's version to handle the static PIE case correctly.

@sunfishcode sunfishcode merged commit b08519f into main Sep 25, 2023
43 checks passed
@sunfishcode sunfishcode deleted the sunfishcode/static-pie-tls branch September 25, 2023 05:29
sunfishcode added a commit to sunfishcode/origin that referenced this pull request Sep 25, 2023
rustix exports all the functions needed to do what `startup_tls_info`
does, so the code can live in origin, and it makes more sense to have
it in origin.

Also incorporate bytecodealliance/rustix#850, handling static PIE by
adding logic to compute the load offset using the difference between
the `PT_DYNAMIC` static address and the dynamic address of the
`_DYNAMIC` symbol.
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