Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/scripts/download-bundled/boost-context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cd "$(dirname "$0")/../../.."
tmp_dir=/tmp/php-src-download-bundled/boost-context
rm -rf "$tmp_dir"

revision=refs/tags/boost-1.86.0
revision=refs/tags/boost-1.91.0

git clone --depth 1 --revision="$revision" https://github.com/boostorg/context.git "$tmp_dir"

Expand Down
19 changes: 19 additions & 0 deletions Zend/asm/jump_arm64_aapcs_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,29 @@

.file "jump_arm64_aapcs_elf_gas.S"
.text
#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1)
/* Mark this object as requiring BTI, enabling the linker to set BTI on the output */
.pushsection .note.gnu.property, "a", %note
.p2align 3
.long 4 /* namesz */
.long 16 /* descsz (16 bytes) */
.long 5 /* type = NT_GNU_PROPERTY_TYPE_0 */
.asciz "GNU"
.p2align 3
.long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
.long 4 /* datasz = 4 */
.long 1 /* GNU_PROPERTY_AARCH64_FEATURE_1_BTI */
.long 0 /* pad to 8-byte alignment */
.popsection
#endif
.align 2
.global jump_fcontext
.hidden jump_fcontext
.type jump_fcontext, %function
jump_fcontext:
#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1)
hint #34 /* bti c: valid indirect-entry target */
#endif
# prepare stack for GP + FPU
sub sp, sp, #0xb0

Expand Down
1 change: 1 addition & 0 deletions Zend/asm/jump_arm64_aapcs_macho_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
*******************************************************/

.text
.private_extern _jump_fcontext
.globl _jump_fcontext
.balign 16
_jump_fcontext:
Expand Down
4 changes: 2 additions & 2 deletions Zend/asm/jump_arm64_aapcs_pe_armasm.asm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
;* ------------------------------------------------- *
;* | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| *
;* ------------------------------------------------- *
;* | fiber data| base | limit | dealloc | *
;* | base | limit | dealloc | fiber data| *
;* ------------------------------------------------- *
;* ------------------------------------------------- *
;* | 48 | 49 | 50 | 51 | | | *
Expand Down Expand Up @@ -130,4 +130,4 @@ jump_fcontext proc

ret x4
ENDP
END
END
141 changes: 141 additions & 0 deletions Zend/asm/jump_arm64_aapcs_pe_armclang.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
Copyright Edward Nevill + Oliver Kowalke 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/

/******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | d8 | d9 | d10 | d11 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | d12 | d13 | d14 | d15 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| *
* ------------------------------------------------- *
* | x19 | x20 | x21 | x22 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| *
* ------------------------------------------------- *
* | x23 | x24 | x25 | x26 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| *
* ------------------------------------------------- *
* | x27 | x28 | FP | LR | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
* ------------------------------------------------- *
* | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| *
* ------------------------------------------------- *
* | base | limit | dealloc | fiber data| *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 48 | 49 | 50 | 51 | | | *
* ------------------------------------------------- *
* | 0xc0| 0xc4| 0xc8| 0xcc| | | *
* ------------------------------------------------- *
* | PC | align | | | *
* ------------------------------------------------- *
* *
*******************************************************/

.file "jump_arm64_aapcs_pe_armclang.S"
.text
.balign 4

.def jump_fcontext; .scl 2; .type 32; .endef
.seh_proc jump_fcontext
jump_fcontext:
.seh_endprologue
// prepare stack for GP + FPU
sub sp, sp, #0xd0

// save d8 - d15
stp d8, d9, [sp, #0x00]
stp d10, d11, [sp, #0x10]
stp d12, d13, [sp, #0x20]
stp d14, d15, [sp, #0x30]

// save x19-x30
stp x19, x20, [sp, #0x40]
stp x21, x22, [sp, #0x50]
stp x23, x24, [sp, #0x60]
stp x25, x26, [sp, #0x70]
stp x27, x28, [sp, #0x80]
stp x29, x30, [sp, #0x90]

// save LR as PC
str x30, [sp, #0xc0]

// save current stack base and limit
ldp x5, x6, [x18, #0x08] // TeStackBase and TeStackLimit at ksarm64.h
stp x5, x6, [sp, #0xa0]
// save current fiber data and deallocation stack
ldr x5, [x18, #0x1478] // TeDeallocationStack at ksarm64.h
ldr x6, [x18, #0x20] // TeFiberData at ksarm64.h
stp x5, x6, [sp, #0xb0]

// store RSP (pointing to context-data) in X0
mov x4, sp

// restore RSP (pointing to context-data) from X1
mov sp, x0

// restore stack base and limit
ldp x5, x6, [sp, #0xa0]
stp x5, x6, [x18, #0x08] // TeStackBase and TeStackLimit at ksarm64.h
// restore fiber data and deallocation stack
ldp x5, x6, [sp, #0xb0]
str x5, [x18, #0x1478] // TeDeallocationStack at ksarm64.h
str x6, [x18, #0x20] // TeFiberData at ksarm64.h

// load d8 - d15
ldp d8, d9, [sp, #0x00]
ldp d10, d11, [sp, #0x10]
ldp d12, d13, [sp, #0x20]
ldp d14, d15, [sp, #0x30]

// load x19-x30
ldp x19, x20, [sp, #0x40]
ldp x21, x22, [sp, #0x50]
ldp x23, x24, [sp, #0x60]
ldp x25, x26, [sp, #0x70]
ldp x27, x28, [sp, #0x80]
ldp x29, x30, [sp, #0x90]

// return transfer_t from jump
// pass transfer_t as first arg in context function
// X0 == FCTX, X1 == DATA
mov x0, x4

// load pc
ldr x4, [sp, #0xc0]

// restore stack from GP + FPU
add sp, sp, #0xd0

ret x4
.seh_endproc

.section .drectve
.ascii " -export:\"jump_fcontext\""
58 changes: 58 additions & 0 deletions Zend/asm/jump_arm_aapcs_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,46 @@
.file "jump_arm_aapcs_elf_gas.S"
.text
.globl jump_fcontext
.hidden jump_fcontext
.align 2
.type jump_fcontext,%function
.syntax unified
jump_fcontext:
@ save LR as PC
push {lr}
@ save hidden,V1-V8,LR

#if __ARM_ARCH >= 7

push {a1,v1-v8,lr}

#else

sub sp, #40

str a1, [sp, #0]
str v1, [sp, #4]
str v2, [sp, #8]
str v3, [sp, #12]
str v4, [sp, #16]

mov v4, v5
str v4, [sp, #20]

mov v4, v6
str v4, [sp, #24]

mov v4, v7
str v4, [sp, #28]

mov v4, v8
str v4, [sp, #32]

mov v4, lr
str v4, [sp, #36]

#endif

@ prepare stack for FPU
sub sp, sp, #64
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
Expand All @@ -71,7 +102,34 @@ jump_fcontext:
add sp, sp, #64

@ restore hidden,V1-V8,LR
#if __ARM_ARCH >= 7
pop {a4,v1-v8,lr}
#else

ldr v4, [sp, #20]
mov v5, v4

ldr v4, [sp, #24]
mov v6, v4

ldr v4, [sp, #28]
mov v7, v4

ldr v4, [sp, #32]
mov v8, v4

ldr v4, [sp, #36]
mov lr, v4

ldr a4, [sp, #0]
ldr v1, [sp, #4]
ldr v2, [sp, #8]
ldr v3, [sp, #12]
ldr v4, [sp, #16]

add sp, #40

#endif

@ return transfer_t from jump
str a1, [a4, #0]
Expand Down
1 change: 1 addition & 0 deletions Zend/asm/jump_arm_aapcs_macho_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
*******************************************************/

.text
.private_extern _jump_fcontext
.globl _jump_fcontext
.align 2
_jump_fcontext:
Expand Down
18 changes: 9 additions & 9 deletions Zend/asm/jump_i386_ms_pe_masm.asm
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ ENDIF
mov eax, [edx]
mov [esp+018h], eax

mov [esp+01ch], edi ; save EDI
mov [esp+020h], esi ; save ESI
mov [esp+024h], ebx ; save EBX
mov [esp+028h], ebp ; save EBP
mov [esp+01ch], edi ; save EDI
mov [esp+020h], esi ; save ESI
mov [esp+024h], ebx ; save EBX
mov [esp+028h], ebp ; save EBP

; store ESP (pointing to context-data) in EAX
mov eax, esp

; firstarg of jump_fcontext() == fcontext to jump to
mov ecx, [esp+030h]

; restore ESP (pointing to context-data) from ECX
mov esp, ecx

Expand Down Expand Up @@ -98,10 +98,10 @@ ENDIF

mov ecx, [esp+02ch] ; restore EIP

mov edi, [esp+01ch] ; restore EDI
mov esi, [esp+020h] ; restore ESI
mov ebx, [esp+024h] ; restore EBX
mov ebp, [esp+028h] ; restore EBP
mov edi, [esp+01ch] ; restore EDI
mov esi, [esp+020h] ; restore ESI
mov ebx, [esp+024h] ; restore EBX
mov ebp, [esp+028h] ; restore EBP

; prepare stack
lea esp, [esp+030h]
Expand Down
1 change: 1 addition & 0 deletions Zend/asm/jump_i386_sysv_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
.file "jump_i386_sysv_elf_gas.S"
.text
.globl jump_fcontext
.hidden jump_fcontext
.align 2
.type jump_fcontext,@function
jump_fcontext:
Expand Down
5 changes: 3 additions & 2 deletions Zend/asm/jump_i386_sysv_macho_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
****************************************************************************************/

.text
.private_extern _jump_fcontext
.globl _jump_fcontext
.align 2
_jump_fcontext:
Expand Down Expand Up @@ -54,8 +55,8 @@ _jump_fcontext:

/* return parent fcontext_t */
movl %ecx, %eax
/* returned data is stored in EDX */
/* returned data is stored in EDX */

movl 0x18(%esp), %ecx /* restore EIP */

#if !defined(BOOST_USE_TSX)
Expand Down
1 change: 1 addition & 0 deletions Zend/asm/jump_loongarch64_sysv_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
.file "jump_loongarch64_sysv_elf_gas.S"
.text
.globl jump_fcontext
.hidden jump_fcontext
.align 2
.type jump_fcontext,@function
jump_fcontext:
Expand Down
5 changes: 3 additions & 2 deletions Zend/asm/jump_mips32_o32_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
.file "jump_mips32_o32_elf_gas.S"
.text
.globl jump_fcontext
.hidden jump_fcontext
.align 2
.type jump_fcontext,@function
.ent jump_fcontext
Expand Down Expand Up @@ -102,13 +103,13 @@ jump_fcontext:

# adjust stack
addiu $sp, $sp, 96

# return transfer_t from jump
sw $a0, ($v0) # fctx of transfer_t
sw $a2, 4($v0) # data of transfer_t
# pass transfer_t as first arg in context function
# A0 == fctx, A1 == data
move $a1, $a2
move $a1, $a2

# jump to context
jr $t9
Expand Down
1 change: 1 addition & 0 deletions Zend/asm/jump_mips64_n64_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
.file "jump_mips64_n64_elf_gas.S"
.text
.globl jump_fcontext
.hidden jump_fcontext
.align 3
.type jump_fcontext,@function
.ent jump_fcontext
Expand Down
Loading
Loading