Skip to content

[X86] Emit R_X86_64_TPOFF64 for IE-mode TLS in shared objects.#1207

Merged
quic-seaswara merged 1 commit into
qualcomm:mainfrom
quic-areg:x86-tls
May 22, 2026
Merged

[X86] Emit R_X86_64_TPOFF64 for IE-mode TLS in shared objects.#1207
quic-seaswara merged 1 commit into
qualcomm:mainfrom
quic-areg:x86-tls

Conversation

@quic-areg
Copy link
Copy Markdown
Contributor

For IE TLS, x86_64 accesses a GOT entry containing the symbol's offset from the thread pointer. For executable outputs, the TP offset is fixed at link time, so the GOT entry can be resolved statically.

For shared objects, the offset is assigned by the dynamic loader. ELD was still writing the link-time static TLS offset into the GOT entry for local IE TLS references, leaving no dynamic relocation for the loader to apply.

Emit R_X86_64_TPOFF64 for IE TLS GOT entries in shared objects, and mark the output with DF_STATIC_TLS when static TLS is required. Keep PIE output statically resolved.

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.

It would be good to add a build and run test to make sure that the executable / shared object returns the value that we are looking for.

I posted this here

#885 (comment)

Comment thread test/x86_64/linux/TLSIELocalSymbol/TLSIELocalSymbol.test Outdated
Comment thread lib/Target/X86/x86_64Relocator.cpp Outdated
For IE TLS, x86_64 accesses a GOT entry containing the symbol's offset
from the thread pointer. For executable outputs, the TP offset is fixed
at link time, so the GOT entry can be resolved statically.

For shared objects, the offset is assigned by the dynamic loader. ELD was
still writing the link-time static TLS offset into the GOT entry for local
IE TLS references, leaving no dynamic relocation for the loader to apply.

Emit `R_X86_64_TPOFF64` for IE TLS GOT entries in shared objects, and mark
the output with `DF_STATIC_TLS` when static TLS is required. Keep PIE output
statically resolved.

Signed-off-by: quic-areg <aregmi@qti.qualcomm.com>
@quic-seaswara quic-seaswara merged commit 282e30a into qualcomm:main May 22, 2026
13 checks passed
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.

2 participants