Skip to content

Commit 79862f2

Browse files
committed
Fix TLS access in JIT on FreeBSD/amd64
DTV elements are 8 bytes in size a per ABI [1], and the index is offset by 1 on FreeBSD [2] [1] http://people.redhat.com/drepper/tls.pdf [2] https://github.com/freebsd/freebsd-src/blob/bf56e8b9c8639ac4447d223b83cdc128107cc3cd/libexec/rtld-elf/rtld.c#L5260 Closes GH-13928
1 parent 272da51 commit 79862f2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ PHP NEWS
1313
- Opcache:
1414
. Fixed bug GH-14267 (opcache.jit=off does not allow enabling JIT at runtime).
1515
(ilutov)
16+
. Fixed TLS access in JIT on FreeBSD/amd64. (Arnaud)
1617

1718
- Soap:
1819
. Fixed bug #47925 (PHPClient can't decompress response). (nielsdos)

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,6 +2910,15 @@ static int zend_jit_setup(void)
29102910
: "=a" (ti));
29112911
tsrm_tls_offset = ti[1];
29122912
tsrm_tls_index = ti[0] * 8;
2913+
#elif defined(__FreeBSD__)
2914+
size_t *ti;
2915+
2916+
__asm__(
2917+
"leaq _tsrm_ls_cache@tlsgd(%%rip), %0\n"
2918+
: "=a" (ti));
2919+
tsrm_tls_offset = ti[1];
2920+
/* Index is offset by 1 on FreeBSD (https://github.com/freebsd/freebsd-src/blob/bf56e8b9c8639ac4447d223b83cdc128107cc3cd/libexec/rtld-elf/rtld.c#L5260) */
2921+
tsrm_tls_index = (ti[0] + 1) * 8;
29132922
#else
29142923
size_t *ti;
29152924

0 commit comments

Comments
 (0)