diff --git a/.github/scripts/download-bundled/boost-context.sh b/.github/scripts/download-bundled/boost-context.sh index b1fd8708b85b..02febff73c3f 100755 --- a/.github/scripts/download-bundled/boost-context.sh +++ b/.github/scripts/download-bundled/boost-context.sh @@ -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" @@ -16,12 +16,14 @@ cd Zend/asm # remove unneeded files rm jump_arm_aapcs_pe_armasm.asm +rm jump_arm64_aapcs_pe_armclang.S rm jump_i386_ms_pe_clang_gas.S rm jump_i386_ms_pe_gas.asm rm jump_i386_x86_64_sysv_macho_gas.S rm jump_ppc32_ppc64_sysv_macho_gas.S rm jump_x86_64_ms_pe_clang_gas.S rm make_arm_aapcs_pe_armasm.asm +rm make_arm64_aapcs_pe_armclang.S rm make_i386_ms_pe_clang_gas.S rm make_i386_ms_pe_gas.asm rm make_i386_x86_64_sysv_macho_gas.S diff --git a/Zend/asm/jump_arm64_aapcs_elf_gas.S b/Zend/asm/jump_arm64_aapcs_elf_gas.S index cefd1830d718..b8abb2ef6bc4 100644 --- a/Zend/asm/jump_arm64_aapcs_elf_gas.S +++ b/Zend/asm/jump_arm64_aapcs_elf_gas.S @@ -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 diff --git a/Zend/asm/jump_arm64_aapcs_macho_gas.S b/Zend/asm/jump_arm64_aapcs_macho_gas.S index 31738f745314..12cc02158685 100644 --- a/Zend/asm/jump_arm64_aapcs_macho_gas.S +++ b/Zend/asm/jump_arm64_aapcs_macho_gas.S @@ -52,6 +52,7 @@ *******************************************************/ .text +.private_extern _jump_fcontext .globl _jump_fcontext .balign 16 _jump_fcontext: diff --git a/Zend/asm/jump_arm64_aapcs_pe_armasm.asm b/Zend/asm/jump_arm64_aapcs_pe_armasm.asm index 3100243d68de..afb6d2b2e703 100644 --- a/Zend/asm/jump_arm64_aapcs_pe_armasm.asm +++ b/Zend/asm/jump_arm64_aapcs_pe_armasm.asm @@ -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 | | | * @@ -130,4 +130,4 @@ jump_fcontext proc ret x4 ENDP - END \ No newline at end of file + END diff --git a/Zend/asm/jump_arm_aapcs_elf_gas.S b/Zend/asm/jump_arm_aapcs_elf_gas.S index 86efe9d82146..4415a541fd3e 100644 --- a/Zend/asm/jump_arm_aapcs_elf_gas.S +++ b/Zend/asm/jump_arm_aapcs_elf_gas.S @@ -41,6 +41,7 @@ .file "jump_arm_aapcs_elf_gas.S" .text .globl jump_fcontext +.hidden jump_fcontext .align 2 .type jump_fcontext,%function .syntax unified @@ -48,8 +49,38 @@ 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__)) @@ -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] diff --git a/Zend/asm/jump_arm_aapcs_macho_gas.S b/Zend/asm/jump_arm_aapcs_macho_gas.S index 077c36409e83..44e7f2a42274 100644 --- a/Zend/asm/jump_arm_aapcs_macho_gas.S +++ b/Zend/asm/jump_arm_aapcs_macho_gas.S @@ -39,6 +39,7 @@ *******************************************************/ .text +.private_extern _jump_fcontext .globl _jump_fcontext .align 2 _jump_fcontext: diff --git a/Zend/asm/jump_i386_ms_pe_masm.asm b/Zend/asm/jump_i386_ms_pe_masm.asm index 7a9e848f1c3f..a0450d0532f8 100644 --- a/Zend/asm/jump_i386_ms_pe_masm.asm +++ b/Zend/asm/jump_i386_ms_pe_masm.asm @@ -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 @@ -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] diff --git a/Zend/asm/jump_i386_sysv_elf_gas.S b/Zend/asm/jump_i386_sysv_elf_gas.S index ed83717ce2b8..d00ac4fffd42 100644 --- a/Zend/asm/jump_i386_sysv_elf_gas.S +++ b/Zend/asm/jump_i386_sysv_elf_gas.S @@ -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: diff --git a/Zend/asm/jump_i386_sysv_macho_gas.S b/Zend/asm/jump_i386_sysv_macho_gas.S index 8ab7c6f29c66..4cae3252d171 100644 --- a/Zend/asm/jump_i386_sysv_macho_gas.S +++ b/Zend/asm/jump_i386_sysv_macho_gas.S @@ -25,6 +25,7 @@ ****************************************************************************************/ .text +.private_extern _jump_fcontext .globl _jump_fcontext .align 2 _jump_fcontext: @@ -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) diff --git a/Zend/asm/jump_loongarch64_sysv_elf_gas.S b/Zend/asm/jump_loongarch64_sysv_elf_gas.S index 74c081e07faa..6f99e719ec00 100644 --- a/Zend/asm/jump_loongarch64_sysv_elf_gas.S +++ b/Zend/asm/jump_loongarch64_sysv_elf_gas.S @@ -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: diff --git a/Zend/asm/jump_mips32_o32_elf_gas.S b/Zend/asm/jump_mips32_o32_elf_gas.S index f2b8034d8c5b..38d22d26f6d7 100644 --- a/Zend/asm/jump_mips32_o32_elf_gas.S +++ b/Zend/asm/jump_mips32_o32_elf_gas.S @@ -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 @@ -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 diff --git a/Zend/asm/jump_mips64_n64_elf_gas.S b/Zend/asm/jump_mips64_n64_elf_gas.S index e338912bb6e8..60027fe61734 100644 --- a/Zend/asm/jump_mips64_n64_elf_gas.S +++ b/Zend/asm/jump_mips64_n64_elf_gas.S @@ -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 diff --git a/Zend/asm/jump_ppc32_sysv_elf_gas.S b/Zend/asm/jump_ppc32_sysv_elf_gas.S index 48e09c935e09..e31336640065 100644 --- a/Zend/asm/jump_ppc32_sysv_elf_gas.S +++ b/Zend/asm/jump_ppc32_sysv_elf_gas.S @@ -53,6 +53,7 @@ .file "jump_ppc32_sysv_elf_gas.S" .text .globl jump_fcontext +.hidden jump_fcontext .align 2 .type jump_fcontext,@function jump_fcontext: diff --git a/Zend/asm/jump_ppc32_sysv_macho_gas.S b/Zend/asm/jump_ppc32_sysv_macho_gas.S index fef90c295f8c..c2a2061e8774 100644 --- a/Zend/asm/jump_ppc32_sysv_macho_gas.S +++ b/Zend/asm/jump_ppc32_sysv_macho_gas.S @@ -68,12 +68,13 @@ * ------------------------------------------------- * * | 256 | | * * ------------------------------------------------- * - * | DATA| | * + * | DATA| | * * ------------------------------------------------- * * * *******************************************************/ .text +.private_extern _jump_fcontext .globl _jump_fcontext .align 2 _jump_fcontext: @@ -193,7 +194,7 @@ _jump_fcontext: ; adjust stack addi r1, r1, 244 - ; return transfer_t + ; return transfer_t stw r6, 0(r3) stw r5, 4(r3) diff --git a/Zend/asm/jump_ppc64_sysv_elf_gas.S b/Zend/asm/jump_ppc64_sysv_elf_gas.S index 28907db32b8c..debeb3466404 100644 --- a/Zend/asm/jump_ppc64_sysv_elf_gas.S +++ b/Zend/asm/jump_ppc64_sysv_elf_gas.S @@ -68,6 +68,7 @@ .file "jump_ppc64_sysv_elf_gas.S" .globl jump_fcontext +.hidden jump_fcontext #if _CALL_ELF == 2 .text .align 2 @@ -97,7 +98,7 @@ jump_fcontext: # endif #endif # reserve space on stack - subi %r1, %r1, 184 + subi %r1, %r1, 200 #if _CALL_ELF != 2 std %r2, 0(%r1) # save TOC @@ -133,6 +134,10 @@ jump_fcontext: # save LR as PC std %r0, 176(%r1) + # Save VS63 + li %r31, 184 + stvx %v31, %r1, %r31 + # store RSP (pointing to context-data) in R6 mr %r6, %r1 @@ -145,6 +150,11 @@ jump_fcontext: ld %r2, 0(%r1) # restore TOC #endif + + # Restore VS63 + li %r31, 184 + lvx %v31, %r1, %r31 + ld %r14, 8(%r1) # restore R14 ld %r15, 16(%r1) # restore R15 ld %r16, 24(%r1) # restore R16 @@ -180,7 +190,7 @@ jump_fcontext: mtctr %r12 # adjust stack - addi %r1, %r1, 184 + addi %r1, %r1, 200 #if _CALL_ELF == 2 # copy transfer_t into transfer_fn arg registers diff --git a/Zend/asm/jump_ppc64_sysv_macho_gas.S b/Zend/asm/jump_ppc64_sysv_macho_gas.S index dcc6c645db61..e4d8944b563d 100644 --- a/Zend/asm/jump_ppc64_sysv_macho_gas.S +++ b/Zend/asm/jump_ppc64_sysv_macho_gas.S @@ -68,6 +68,7 @@ .text .align 2 +.private_extern _jump_fcontext .globl _jump_fcontext _jump_fcontext: diff --git a/Zend/asm/jump_riscv64_sysv_elf_gas.S b/Zend/asm/jump_riscv64_sysv_elf_gas.S index 5417e5d5e349..879eb7efee62 100644 --- a/Zend/asm/jump_riscv64_sysv_elf_gas.S +++ b/Zend/asm/jump_riscv64_sysv_elf_gas.S @@ -61,6 +61,7 @@ .text .align 1 .global jump_fcontext +.hidden jump_fcontext .type jump_fcontext, %function jump_fcontext: # prepare stack for GP + FPU diff --git a/Zend/asm/jump_s390x_sysv_elf_gas.S b/Zend/asm/jump_s390x_sysv_elf_gas.S index fa71467756d2..59bc58bf370b 100644 --- a/Zend/asm/jump_s390x_sysv_elf_gas.S +++ b/Zend/asm/jump_s390x_sysv_elf_gas.S @@ -46,6 +46,7 @@ .text .align 8 .global jump_fcontext +.hidden jump_fcontext .type jump_fcontext, @function #define ARG_OFFSET 0 diff --git a/Zend/asm/jump_x86_64_sysv_elf_gas.S b/Zend/asm/jump_x86_64_sysv_elf_gas.S index be264bdc2e2b..2eff59a380cb 100644 --- a/Zend/asm/jump_x86_64_sysv_elf_gas.S +++ b/Zend/asm/jump_x86_64_sysv_elf_gas.S @@ -44,6 +44,7 @@ .file "jump_x86_64_sysv_elf_gas.S" .text .globl jump_fcontext +.hidden jump_fcontext .type jump_fcontext,@function .align 16 jump_fcontext: @@ -67,14 +68,6 @@ jump_fcontext: movq %rbx, 0x30(%rsp) /* save RBX */ movq %rbp, 0x38(%rsp) /* save RBP */ -#if BOOST_CONTEXT_SHADOW_STACK - /* grow the stack to reserve space for shadow stack pointer(SSP) */ - leaq -0x8(%rsp), %rsp - /* read the current SSP and store it */ - rdsspq %rcx - movq %rcx, (%rsp) -#endif - #if BOOST_CONTEXT_SHADOW_STACK /* grow the stack to reserve space for shadow stack pointer(SSP) */ leaq -0x8(%rsp), %rsp diff --git a/Zend/asm/jump_x86_64_sysv_macho_gas.S b/Zend/asm/jump_x86_64_sysv_macho_gas.S index afc3e5c126f9..673daa61dfaa 100644 --- a/Zend/asm/jump_x86_64_sysv_macho_gas.S +++ b/Zend/asm/jump_x86_64_sysv_macho_gas.S @@ -25,6 +25,7 @@ ****************************************************************************************/ .text +.private_extern _jump_fcontext .globl _jump_fcontext .align 8 _jump_fcontext: diff --git a/Zend/asm/make_arm64_aapcs_elf_gas.S b/Zend/asm/make_arm64_aapcs_elf_gas.S index 66cfb2da17ea..246525402f5c 100644 --- a/Zend/asm/make_arm64_aapcs_elf_gas.S +++ b/Zend/asm/make_arm64_aapcs_elf_gas.S @@ -53,10 +53,29 @@ .file "make_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 make_fcontext +.hidden make_fcontext .type make_fcontext, %function make_fcontext: +#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1) + hint #34 /* bti c */ +#endif # shift address in x0 (allocated stack) to lower 16 byte boundary and x0, x0, ~0xF diff --git a/Zend/asm/make_arm64_aapcs_macho_gas.S b/Zend/asm/make_arm64_aapcs_macho_gas.S index b30b1e3e5bbb..a6a1314c0dcd 100644 --- a/Zend/asm/make_arm64_aapcs_macho_gas.S +++ b/Zend/asm/make_arm64_aapcs_macho_gas.S @@ -52,6 +52,7 @@ *******************************************************/ .text +.private_extern _make_fcontext .globl _make_fcontext .balign 16 diff --git a/Zend/asm/make_arm64_aapcs_pe_armasm.asm b/Zend/asm/make_arm64_aapcs_pe_armasm.asm index 50f9b69876be..c384af039fc4 100644 --- a/Zend/asm/make_arm64_aapcs_pe_armasm.asm +++ b/Zend/asm/make_arm64_aapcs_pe_armasm.asm @@ -73,7 +73,7 @@ make_fcontext proc ; save top address of context_stack as 'base' str x3, [x0, #0xa0] - ; save bottom address of context-stack as 'limit' and 'dealloction stack' + ; save bottom address of context-stack as 'limit' and 'deallocation stack' sub x3, x3, x1 stp x3, x3, [x0, #0xa8] ; save 0 as 'fiber data' diff --git a/Zend/asm/make_arm_aapcs_elf_gas.S b/Zend/asm/make_arm_aapcs_elf_gas.S index 98ae64b43f9d..2367c75a6a77 100644 --- a/Zend/asm/make_arm_aapcs_elf_gas.S +++ b/Zend/asm/make_arm_aapcs_elf_gas.S @@ -41,26 +41,47 @@ .file "make_arm_aapcs_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .align 2 .type make_fcontext,%function .syntax unified make_fcontext: @ shift address in A1 to lower 16 byte boundary + + #if __ARM_ARCH >= 7 bic a1, a1, #15 + #else + lsrs a1, a1, #4 + lsls a1, a1, #4 + #endif @ reserve space for context-data on context-stack + #if __ARM_ARCH >= 7 sub a1, a1, #124 + #else + subs a1, #124 + #endif @ third arg of make_fcontext() == address of context-function str a3, [a1, #104] @ compute address of returned transfer_t + #if __ARM_ARCH >= 7 add a2, a1, #108 + #else + mov a2, a1 + adds a2, #108 + #endif mov a3, a2 str a3, [a1, #64] + @ compute abs address of label finish + #if __ARM_ARCH >= 7 adr a2, finish + #else + ldr a2, =finish + #endif @ save address of finish as return-address for context-function @ will be entered after context-function returns str a2, [a1, #100] @@ -72,7 +93,13 @@ make_fcontext: finish: @ exit code is zero + #if __ARM_ARCH >=7 mov a1, #0 + #else + movs r3, #0 + movs r0, r3 + #endif + @ exit application bl _exit@PLT .size make_fcontext,.-make_fcontext diff --git a/Zend/asm/make_arm_aapcs_macho_gas.S b/Zend/asm/make_arm_aapcs_macho_gas.S index c909ae9d43a2..de934075d247 100644 --- a/Zend/asm/make_arm_aapcs_macho_gas.S +++ b/Zend/asm/make_arm_aapcs_macho_gas.S @@ -39,6 +39,7 @@ *******************************************************/ .text +.private_extern _make_fcontext .globl _make_fcontext .align 2 _make_fcontext: diff --git a/Zend/asm/make_i386_ms_pe_masm.asm b/Zend/asm/make_i386_ms_pe_masm.asm index 5246465cb975..3879396390f2 100644 --- a/Zend/asm/make_i386_ms_pe_masm.asm +++ b/Zend/asm/make_i386_ms_pe_masm.asm @@ -53,7 +53,7 @@ make_fcontext PROC BOOST_CONTEXT_EXPORT mov [eax+014h], ecx ; second arg of make_fcontext() == size of context-stack mov edx, [esp+08h] - ; negate stack size for LEA instruction (== substraction) + ; negate stack size for LEA instruction (== subtraction) neg edx ; compute bottom address of context stack (limit) lea ecx, [ecx+edx] diff --git a/Zend/asm/make_i386_sysv_elf_gas.S b/Zend/asm/make_i386_sysv_elf_gas.S index c6e0b36558a6..992bae019af2 100644 --- a/Zend/asm/make_i386_sysv_elf_gas.S +++ b/Zend/asm/make_i386_sysv_elf_gas.S @@ -31,6 +31,7 @@ .file "make_i386_sysv_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .align 2 .type make_fcontext,@function make_fcontext: diff --git a/Zend/asm/make_i386_sysv_macho_gas.S b/Zend/asm/make_i386_sysv_macho_gas.S index 519e406248bb..01076129bcf5 100644 --- a/Zend/asm/make_i386_sysv_macho_gas.S +++ b/Zend/asm/make_i386_sysv_macho_gas.S @@ -25,6 +25,7 @@ ****************************************************************************************/ .text +.private_extern _make_fcontext .globl _make_fcontext .align 2 _make_fcontext: @@ -69,7 +70,7 @@ _make_fcontext: addl $finish-2b, %ecx /* save address of finish as return-address for context-function */ /* will be entered after context-function returns */ - movl %ecx, 0x14(%eax) + movl %ecx, 0x14(%eax) ret /* return pointer to context-data */ diff --git a/Zend/asm/make_loongarch64_sysv_elf_gas.S b/Zend/asm/make_loongarch64_sysv_elf_gas.S index 55062702f18d..a067baded56f 100644 --- a/Zend/asm/make_loongarch64_sysv_elf_gas.S +++ b/Zend/asm/make_loongarch64_sysv_elf_gas.S @@ -41,6 +41,7 @@ .file "make_loongarch64_sysv_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .align 2 .type make_fcontext,@function make_fcontext: diff --git a/Zend/asm/make_mips32_o32_elf_gas.S b/Zend/asm/make_mips32_o32_elf_gas.S index 4e11e3d05825..54742f3a8be2 100644 --- a/Zend/asm/make_mips32_o32_elf_gas.S +++ b/Zend/asm/make_mips32_o32_elf_gas.S @@ -41,6 +41,7 @@ .file "make_mips32_o32_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .align 2 .type make_fcontext,@function .ent make_fcontext diff --git a/Zend/asm/make_mips64_n64_elf_gas.S b/Zend/asm/make_mips64_n64_elf_gas.S index 7bb30b14dee7..c43f2ff368f9 100644 --- a/Zend/asm/make_mips64_n64_elf_gas.S +++ b/Zend/asm/make_mips64_n64_elf_gas.S @@ -48,6 +48,7 @@ .file "make_mips64_n64_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .align 3 .type make_fcontext,@function .ent make_fcontext @@ -69,7 +70,7 @@ make_fcontext: # save global pointer in context-data sd $gp, 136($v0) - # psudo instruction compute abs address of label finish based on GP + # pseudo instruction compute abs address of label finish based on GP dla $t9, finish # save address of finish as return-address for context-function diff --git a/Zend/asm/make_ppc32_sysv_elf_gas.S b/Zend/asm/make_ppc32_sysv_elf_gas.S index 9616c4ca9b46..0dd77719354b 100644 --- a/Zend/asm/make_ppc32_sysv_elf_gas.S +++ b/Zend/asm/make_ppc32_sysv_elf_gas.S @@ -53,6 +53,7 @@ .file "make_ppc32_sysv_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .align 2 .type make_fcontext,@function make_fcontext: diff --git a/Zend/asm/make_ppc32_sysv_macho_gas.S b/Zend/asm/make_ppc32_sysv_macho_gas.S index 1102ee90ef07..75d1c80e5263 100644 --- a/Zend/asm/make_ppc32_sysv_macho_gas.S +++ b/Zend/asm/make_ppc32_sysv_macho_gas.S @@ -68,12 +68,13 @@ * ------------------------------------------------- * * | 256 | | * * ------------------------------------------------- * - * | DATA| | * + * | DATA| | * * ------------------------------------------------- * * * *******************************************************/ .text +.private_extern _make_fcontext .globl _make_fcontext .align 2 _make_fcontext: @@ -101,8 +102,8 @@ _make_fcontext: ; compute address of returned transfer_t addi r0, r3, 252 - mr r4, r0 - stw r4, 228(r3) + mr r4, r0 + stw r4, 228(r3) ; load LR mflr r0 diff --git a/Zend/asm/make_ppc64_sysv_elf_gas.S b/Zend/asm/make_ppc64_sysv_elf_gas.S index c4d7ee59826a..f513d3639ea9 100644 --- a/Zend/asm/make_ppc64_sysv_elf_gas.S +++ b/Zend/asm/make_ppc64_sysv_elf_gas.S @@ -68,6 +68,7 @@ .file "make_ppc64_sysv_elf_gas.S" .globl make_fcontext +.hidden make_fcontext #if _CALL_ELF == 2 .text .align 2 diff --git a/Zend/asm/make_ppc64_sysv_macho_gas.S b/Zend/asm/make_ppc64_sysv_macho_gas.S index dd7bf2c5c0c0..d8cdd2d080db 100644 --- a/Zend/asm/make_ppc64_sysv_macho_gas.S +++ b/Zend/asm/make_ppc64_sysv_macho_gas.S @@ -67,6 +67,7 @@ *******************************************************/ .text +.private_extern _make_fcontext .globl _make_fcontext _make_fcontext: ; save return address into R6 diff --git a/Zend/asm/make_riscv64_sysv_elf_gas.S b/Zend/asm/make_riscv64_sysv_elf_gas.S index 5322e0fdbdec..6d97c59e877e 100644 --- a/Zend/asm/make_riscv64_sysv_elf_gas.S +++ b/Zend/asm/make_riscv64_sysv_elf_gas.S @@ -61,6 +61,7 @@ .text .align 1 .global make_fcontext +.hidden make_fcontext .type make_fcontext, %function make_fcontext: # shift address in a0 (allocated stack) to lower 16 byte boundary diff --git a/Zend/asm/make_s390x_sysv_elf_gas.S b/Zend/asm/make_s390x_sysv_elf_gas.S index 4dd423e2a44c..4d6aa62c0ae1 100644 --- a/Zend/asm/make_s390x_sysv_elf_gas.S +++ b/Zend/asm/make_s390x_sysv_elf_gas.S @@ -46,6 +46,7 @@ .text .align 8 .global make_fcontext +.hidden make_fcontext .type make_fcontext, @function #define ARG_OFFSET 0 diff --git a/Zend/asm/make_sparc64_sysv_elf_gas.S b/Zend/asm/make_sparc64_sysv_elf_gas.S index 3e7ee809c918..3d504471afd5 100644 --- a/Zend/asm/make_sparc64_sysv_elf_gas.S +++ b/Zend/asm/make_sparc64_sysv_elf_gas.S @@ -45,7 +45,7 @@ make_fcontext: add %l0, (trampoline - 1b - 8), %l0 stx %l0, [%i0 + I7] - # Save framepointer to first stack frame but first substract the BIAS + # Save framepointer to first stack frame but first subtract the BIAS add %i0, CC64FSZ - BIAS, %l0 stx %l0, [%i0 + SP] diff --git a/Zend/asm/make_x86_64_ms_pe_gas.S b/Zend/asm/make_x86_64_ms_pe_gas.S index 958a2a7b6d0e..7146637c0319 100644 --- a/Zend/asm/make_x86_64_ms_pe_gas.S +++ b/Zend/asm/make_x86_64_ms_pe_gas.S @@ -113,7 +113,7 @@ make_fcontext: /* save top address of context stack as 'base' */ movq %rcx, 0xc8(%rax) /* second arg of make_fcontext() == size of context-stack */ - /* negate stack size for LEA instruction (== substraction) */ + /* negate stack size for LEA instruction (== subtraction) */ negq %rdx /* compute bottom address of context stack (limit) */ leaq (%rcx,%rdx), %rcx @@ -151,7 +151,7 @@ make_fcontext: trampoline: /* store return address on stack */ - /* fix stack alignment */ + /* fix stack alignment */ pushq %rbp /* jump to context-function */ jmp *%rbx diff --git a/Zend/asm/make_x86_64_ms_pe_masm.asm b/Zend/asm/make_x86_64_ms_pe_masm.asm index 8f6c959a8376..a6c2b147e446 100644 --- a/Zend/asm/make_x86_64_ms_pe_masm.asm +++ b/Zend/asm/make_x86_64_ms_pe_masm.asm @@ -110,7 +110,7 @@ make_fcontext PROC BOOST_CONTEXT_EXPORT FRAME ; save top address of context stack as 'base' mov [rax+0c8h], rcx ; second arg of make_fcontext() == size of context-stack - ; negate stack size for LEA instruction (== substraction) + ; negate stack size for LEA instruction (== subtraction) neg rdx ; compute bottom address of context stack (limit) lea rcx, [rcx+rdx] @@ -141,7 +141,7 @@ make_fcontext PROC BOOST_CONTEXT_EXPORT FRAME ; compute abs address of label finish lea rcx, finish ; save address of finish as return-address for context-function in RBP - ; will be entered after context-function returns + ; will be entered after context-function returns mov [rax+0108h], rcx ret ; return pointer to context-data diff --git a/Zend/asm/make_x86_64_sysv_elf_gas.S b/Zend/asm/make_x86_64_sysv_elf_gas.S index b0d0c0341ef3..cabebff6e626 100644 --- a/Zend/asm/make_x86_64_sysv_elf_gas.S +++ b/Zend/asm/make_x86_64_sysv_elf_gas.S @@ -44,6 +44,7 @@ .file "make_x86_64_sysv_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .type make_fcontext,@function .align 16 make_fcontext: @@ -76,7 +77,7 @@ make_fcontext: #if defined(BOOST_CONTEXT_TLS_STACK_PROTECTOR) /* save stack guard */ movq %fs:0x28, %rcx /* read stack guard from TLS record */ - movq %rcx, 0x8(%rsp) /* save stack guard */ + movq %rcx, 0x8(%rax) /* save stack guard */ #endif /* compute abs address of label trampoline */ @@ -91,35 +92,6 @@ make_fcontext: /* will be entered after context-function returns */ movq %rcx, 0x38(%rax) -#if BOOST_CONTEXT_SHADOW_STACK - /* Populate the shadow stack and normal stack */ - /* get original SSP */ - rdsspq %r8 - /* restore new shadow stack */ - rstorssp -0x8(%r9) - /* save the restore token on the original shadow stack */ - saveprevssp - /* push the address of "jmp trampoline" to the new shadow stack */ - /* as well as the stack */ - call 1f - jmp trampoline -1: - /* save address of "jmp trampoline" as return-address */ - /* for context-function */ - pop 0x38(%rax) - /* Get the new SSP. */ - rdsspq %r9 - /* restore original shadow stack */ - rstorssp -0x8(%r8) - /* save the restore token on the new shadow stack. */ - saveprevssp - - /* reserve space for the new SSP */ - leaq -0x8(%rax), %rax - /* save the new SSP to this fcontext */ - movq %r9, (%rax) -#endif - #if BOOST_CONTEXT_SHADOW_STACK /* Populate the shadow stack */ @@ -161,6 +133,8 @@ make_fcontext: ret /* return pointer to context-data */ trampoline: + .cfi_startproc + .cfi_undefined rip /* store return address on stack */ /* fix stack alignment */ _CET_ENDBR @@ -175,6 +149,7 @@ trampoline: #endif /* jump to context-function */ jmp *%rbx + .cfi_endproc finish: _CET_ENDBR diff --git a/Zend/asm/make_x86_64_sysv_macho_gas.S b/Zend/asm/make_x86_64_sysv_macho_gas.S index 5d6c5431c598..06357f678ac9 100644 --- a/Zend/asm/make_x86_64_sysv_macho_gas.S +++ b/Zend/asm/make_x86_64_sysv_macho_gas.S @@ -25,6 +25,7 @@ ****************************************************************************************/ .text +.private_extern _make_fcontext .globl _make_fcontext .align 8 _make_fcontext: