Skip to content

Conversation

@arnaud-lb
Copy link
Owner

No description provided.

ndossche and others added 6 commits July 25, 2025 11:56
* PHP-8.3:
  NEWS for hrtime in FTP and standard
  Handle broken hrtime in ftp
  Fix arginfo/zpp violation if zend_hrtime is not available
* PHP-8.4:
  NEWS for hrtime in FTP and standard
  Handle broken hrtime in ftp
  Fix arginfo/zpp violation if zend_hrtime is not available
Specifically, it is added to openssl_public_encrypt() and
openssl_private_decrypt() functions. The purpose is to specify digest
algorithm for OEAP padding. It currently defaults to SHA1 for some
OpenSSL versions which is not preferred for modern setup and causes
problems in compatibility with web crypto.

Closes phpGH-19223
@arnaud-lb arnaud-lb force-pushed the static-opcache-tls-test-entry-point branch 2 times, most recently from d8ec09b to e2530cb Compare July 25, 2025 11:13
marc-mabe and others added 14 commits July 25, 2025 13:22
This fixes the following linker error:

    TLS transition from R_X86_64_TLSGD to R_X86_64_GOTTPOFF against
    `_tsrm_ls_cache' at 0x12fc3 in section `.text' failed"

The error arises from how we obtain information about the _tsrm_ls_cache TLS
variable for use in JIT'ed code:

Normally, TLS variables are resolved via linker relocations [1], which of course
can not be used in JIT'ed code. Therefore we emit the relocation in AOT code and
use the result in JIT.

Specifically we use a fragment of the "General Dynamic" code sequence described
in [1]. Using the full code sequence would give us the address of the variable
in the current thread. Therefore we only use a fragment that gives us the
variable's TLS index and offset.

When Opcache is statically linked into the binary, linkers attempt to relax
(rewrite) this code sequence into a more efficient one. However, this fails
because they will not recognize the code sequence.

We now take a different approach:

 * Emit the exact full code sequence expected by linkers
 * Extract the TLS index/offset or TCB offset by inspecting the ASM code, rather
   than executing it (execution would give us the thread-local address).
 * This is done in a conservative way so that 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
@arnaud-lb arnaud-lb force-pushed the static-opcache-tls-test-entry-point branch 2 times, most recently from 6ef6581 to 89e21b0 Compare July 25, 2025 15:28
@arnaud-lb arnaud-lb force-pushed the static-opcache-tls-test-entry-point branch from 89e21b0 to bf94dea Compare July 25, 2025 18:52
@arnaud-lb arnaud-lb closed this Jul 27, 2025
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.

5 participants