Skip to content

[RFC][PoC] Allow opcache to be built statically #18660

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

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix "TLS transition from R_X86_64_TLSGD to R_X86_64_GOTTPOFF against …
…`_tsrm_ls_cache' at 0x12fc3 in section `.text' failed"

In order to get information about the _tsrm_ls_cache TLS variable, we emit ASM
code with TLS-related relocations [1]. These relocations, once adjusted by the
linker, give us the offset or address of the variable's TLS descriptor.

Specifically, we use relocations meant for use in the "General Dynamic" model
described in [1].

When building Opcache statically in a binary, the linker will attempt to
optimize the General Dynamic code sequence to a more efficient one.
Unfortunately, linkers will break as we don't use the exact code sequence they
are expecting.

Here I use a different approach to get information about the TLS variable:

 * Emit the exact code sequence expected by linker, so that linking works
 * Extract the information we want by inspecting the ASM code. If the linker
   did something we didn't expect, we fallback to a safer (but slower)
   mechanism.

[1] https://www.akkadia.org/drepper/tls.pdf
  • Loading branch information
arnaud-lb committed May 26, 2025
commit ba04798bb9fc20cb93b1a50c0c496f15b13109dd
Loading
Loading