Skip to content

Resolve IE TLS GOT entries statically in PIE#1208

Open
quic-areg wants to merge 1 commit into
qualcomm:mainfrom
quic-areg:tls-relocs
Open

Resolve IE TLS GOT entries statically in PIE#1208
quic-areg wants to merge 1 commit into
qualcomm:mainfrom
quic-areg:tls-relocs

Conversation

@quic-areg
Copy link
Copy Markdown
Contributor

@quic-areg quic-areg commented May 21, 2026

For non-preemptible symbols accessed through R_*_GOTTPOFF / R_*_TLS_IE, the IE-mode GOT entry was being initialized with a dynamic TPREL/TPOFF relocation in any non-static link, including -pie. PIE executables are not preempted, so the static TLS offset is known at link time and a dynamic relocation is both unnecessary and rejected by the loader.

Also set DF_STATIC_TLS on AArch64, ARM, and RISCV (Hexagon and X86 already do).

Fixes #1110

@quic-areg quic-areg changed the title Fix IE TLS relocations for PIE links Resolve IE TLS GOT entries statically in PIE May 27, 2026
Comment thread test/Common/standalone/TLS/TLSIELocalSymbol/TLSIELocalSymbol.test Outdated
For non-preemptible symbols accessed through R_*_GOTTPOFF / R_*_TLS_IE,
the IE-mode GOT entry was being initialized with a dynamic
TPREL/TPOFF relocation in any non-static link, including -pie. PIE
executables are not preempted, so the static TLS offset is known at
link time and a dynamic relocation is both unnecessary and rejected
by the loader.

Also set `DF_STATIC_TLS` on AArch64, ARM, and RISCV
(Hexagon and X86 already do).

Fixes: qualcomm#1110

Signed-off-by: quic-areg <aregmi@qti.qualcomm.com>
Copy link
Copy Markdown
Contributor

@quic-seaswara quic-seaswara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add a build/run test to make sure that the values printed are consistent and match expectations ?

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.

eld creates invalid dynamic relocations with pie/TLS

3 participants