diff --git a/boost-context-0001-add-support-for-ARM64-MACH-O.patch b/boost-context-0001-add-support-for-ARM64-MACH-O.patch new file mode 100644 index 0000000..ddd4c4c --- /dev/null +++ b/boost-context-0001-add-support-for-ARM64-MACH-O.patch @@ -0,0 +1,281 @@ +From cbcd605a24352521d769cff7008d92f15f08bfe6 Mon Sep 17 00:00:00 2001 +From: Oliver Kowalke +Date: Wed, 12 Nov 2014 19:46:42 +0100 +Subject: [PATCH 01/54] add support fro ARM64/MACH-O + +--- + build/Jamfile.v2 | 31 +++++++++ + src/asm/jump_arm64_aapcs_macho_gas.S | 124 +++++++++++++++++++++++++++++++++++ + src/asm/make_arm64_aapcs_macho_gas.S | 87 ++++++++++++++++++++++++ + 3 files changed, 242 insertions(+) + create mode 100644 src/asm/jump_arm64_aapcs_macho_gas.S + create mode 100644 src/asm/make_arm64_aapcs_macho_gas.S + +diff --git a/libs/context/build/Jamfile.v2 b/libs/context/build/Jamfile.v2 +index 7cc8a07..32d5222 100644 +--- a/libs/context/build/Jamfile.v2 ++++ b/libs/context/build/Jamfile.v2 +@@ -209,6 +209,37 @@ alias asm_context_sources + msvc + ; + ++# ARM64 ++# ARM64/AAPCS/MACH-O ++alias asm_context_sources ++ : [ make asm/make_arm64_aapcs_macho_gas.o : asm/make_arm64_aapcs_macho_gas.S : @gas64 ] ++ [ make asm/jump_arm64_aapcs_macho_gas.o : asm/jump_arm64_aapcs_macho_gas.S : @gas64 ] ++ : aapcs ++ 64 ++ arm ++ mach-o ++ ; ++ ++alias asm_context_sources ++ : asm/make_arm64_aapcs_macho_gas.S ++ asm/jump_arm64_aapcs_macho_gas.S ++ : aapcs ++ 64 ++ arm ++ mach-o ++ clang ++ ; ++ ++alias asm_context_sources ++ : asm/make_arm64_aapcs_macho_gas.S ++ asm/jump_arm64_aapcs_macho_gas.S ++ : aapcs ++ 64 ++ arm ++ mach-o ++ darwin ++ ; ++ + # MIPS + # MIPS/O32/ELF + alias asm_context_sources +diff --git a/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S b/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S +new file mode 100644 +index 0000000..6ad5b38 +--- /dev/null ++++ b/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S +@@ -0,0 +1,124 @@ ++/* ++ Copyright Oliver Kowalke 2014. ++ 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| * ++ * ------------------------------------------------- * ++ * | s16 | s17 | s18 | s19 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * ++ * ------------------------------------------------- * ++ * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * ++ * ------------------------------------------------- * ++ * | s20 | s21 | s22 | s23 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * ++ * ------------------------------------------------- * ++ * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * ++ * ------------------------------------------------- * ++ * | s24 | s25 | s26 | s27 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * ++ * ------------------------------------------------- * ++ * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * ++ * ------------------------------------------------- * ++ * | s28 | s29 | s30 | s31 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * ++ * ------------------------------------------------- * ++ * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * ++ * ------------------------------------------------- * ++ * | sjlj | v1 | v2 | v3 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * ++ * ------------------------------------------------- * ++ * | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| * ++ * ------------------------------------------------- * ++ * | v4 | v5 | v6 | v7 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 48 | 49 | 50 | 51 | 52 | 53 | | * ++ * ------------------------------------------------- * ++ * | 0xc0| 0xc4| 0xc8| 0xcc| 0xd0| 0xd4| | * ++ * ------------------------------------------------- * ++ * | v8 | lr | pc | | * ++ * ------------------------------------------------- * ++ * * ++ *******************************************************/ ++ ++.text ++.globl _jump_fcontext ++.align 2 ++_jump_fcontext: ++ @ save LR as PC ++ push {lr} ++ @ save V1-V8,LR ++ push {v1-v8,lr} ++ ++ @ locate TLS to save/restore SjLj handler ++ mrc p15, 0, v2, c13, c0, #3 ++ bic v2, v2, #3 ++ ++ @ load TLS[__PTK_LIBC_DYLD_Unwind_SjLj_Key] ++ ldr v1, [v2, #72] ++ @ save SjLj handler ++ push {v1} ++ ++ @ prepare stack for FPU ++ sub sp, sp, #128 ++ ++#if (defined(__VFP_FP__) && !defined(__SOFTFP__)) ++ @ test if fpu env should be preserved ++ cmp a4, #0 ++ beq 1f ++ ++ @ save S16-S31 ++ vstmia sp, {d8-d15} ++ ++1: ++#endif ++ ++ @ store RSP (pointing to context-data) in A1 ++ str sp, [a1] ++ ++ @ restore RSP (pointing to context-data) from A2 ++ mov sp, a2 ++ ++#if (defined(__VFP_FP__) && !defined(__SOFTFP__)) ++ @ test if fpu env should be preserved ++ cmp a4, #0 ++ beq 2f ++ ++ @ restore S16-S31 ++ vldmia sp, {d8-d15} ++ ++2: ++#endif ++ ++ @ prepare stack for FPU ++ add sp, sp, #128 ++ ++ @ restore SjLj handler ++ pop {v1} ++ @ store SjLj handler in TLS ++ str v1, [v2, #72] ++ ++ @ use third arg as return value after jump ++ @ and as first arg in context function ++ mov a1, a3 ++ ++ @ restore v1-V8,LR,PC ++ pop {v1-v8,lr,pc} +diff --git a/libs/context/src/asm/make_arm64_aapcs_macho_gas.S b/libs/context/src/asm/make_arm64_aapcs_macho_gas.S +new file mode 100644 +index 0000000..67d2f89 +--- /dev/null ++++ b/libs/context/src/asm/make_arm64_aapcs_macho_gas.S +@@ -0,0 +1,87 @@ ++/* ++ Copyright Oliver Kowalke 2014. ++ 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| * ++ * ------------------------------------------------- * ++ * | s16 | s17 | s18 | s19 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * ++ * ------------------------------------------------- * ++ * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * ++ * ------------------------------------------------- * ++ * | s20 | s21 | s22 | s23 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * ++ * ------------------------------------------------- * ++ * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * ++ * ------------------------------------------------- * ++ * | s24 | s25 | s26 | s27 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * ++ * ------------------------------------------------- * ++ * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * ++ * ------------------------------------------------- * ++ * | s28 | s29 | s30 | s31 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * ++ * ------------------------------------------------- * ++ * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * ++ * ------------------------------------------------- * ++ * | sjlj | v1 | v2 | v3 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * ++ * ------------------------------------------------- * ++ * | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| * ++ * ------------------------------------------------- * ++ * | v4 | v5 | v6 | v7 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 48 | 49 | 50 | 51 | 52 | 53 | | * ++ * ------------------------------------------------- * ++ * | 0xc0| 0xc4| 0xc8| 0xcc| 0xd0| 0xd4| | * ++ * ------------------------------------------------- * ++ * | v8 | lr | pc | | * ++ * ------------------------------------------------- * ++ * * ++ *******************************************************/ ++ ++.text ++.globl _make_fcontext ++.align 2 ++_make_fcontext: ++ @ shift address in A1 to lower 16 byte boundary ++ bic a1, a1, #15 ++ ++ @ reserve space for context-data on context-stack ++ sub a1, a1, #216 ++ ++ @ third arg of make_fcontext() == address of context-function ++ str a3, [a1,#208] ++ ++ @ compute abs address of label finish ++ adr a2, finish ++ @ save address of finish as return-address for context-function ++ @ will be entered after context-function returns ++ str a2, [a1,#200] ++ ++ bx lr @ return pointer to context-data ++ ++finish: ++ @ exit code is zero ++ mov a1, #0 ++ @ exit application ++ bl __exit +-- +2.3.5 + diff --git a/boost-context-0002-make-ARM64-unsupported.patch b/boost-context-0002-make-ARM64-unsupported.patch new file mode 100644 index 0000000..b6a4420 --- /dev/null +++ b/boost-context-0002-make-ARM64-unsupported.patch @@ -0,0 +1,86 @@ +From c5292fea24c003c3279e0f0770a93cae829e75e3 Mon Sep 17 00:00:00 2001 +From: Oliver Kowalke +Date: Fri, 21 Nov 2014 20:21:22 +0100 +Subject: [PATCH 02/54] make ARM64 unsupported + +--- + build/Jamfile.v2 | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +diff --git a/libs/context/build/Jamfile.v2 b/libs/context/build/Jamfile.v2 +index 32d5222..112e979 100644 +--- a/libs/context/build/Jamfile.v2 ++++ b/libs/context/build/Jamfile.v2 +@@ -14,9 +14,22 @@ import os ; + import toolset ; + import architecture ; + ++feature.feature segmented-stacks : on : optional propagated composite ; ++feature.compose on : BOOST_USE_SEGMENTED_STACKS ; ++ + project boost/context + : requirements ++ /boost/system//boost_system ++ /boost/thread//boost_thread + SOLARIS:_XOPEN_SOURCE=600 ++ gcc-4.7,on:-fsplit-stack ++ gcc-4.7,on:"-static-libgcc" ++ gcc-4.8,on:-fsplit-stack ++ gcc-4.8,on:"-static-libgcc" ++ gcc-4.9,on:-fsplit-stack ++ gcc-4.9,on:"-static-libgcc" ++ clang-3.4,on:-fsplit-stack ++ clang-3.4,on:"-static-libgcc" + shared:BOOST_CONTEXT_DYN_LINK=1 + BOOST_CONTEXT_SOURCE + : usage-requirements +@@ -214,6 +227,7 @@ alias asm_context_sources + alias asm_context_sources + : [ make asm/make_arm64_aapcs_macho_gas.o : asm/make_arm64_aapcs_macho_gas.S : @gas64 ] + [ make asm/jump_arm64_aapcs_macho_gas.o : asm/jump_arm64_aapcs_macho_gas.S : @gas64 ] ++ untested.cpp + : aapcs + 64 + arm +@@ -223,6 +237,7 @@ alias asm_context_sources + alias asm_context_sources + : asm/make_arm64_aapcs_macho_gas.S + asm/jump_arm64_aapcs_macho_gas.S ++ untested.cpp + : aapcs + 64 + arm +@@ -233,6 +248,7 @@ alias asm_context_sources + alias asm_context_sources + : asm/make_arm64_aapcs_macho_gas.S + asm/jump_arm64_aapcs_macho_gas.S ++ untested.cpp + : aapcs + 64 + arm +@@ -799,8 +815,22 @@ alias select_asm_context_sources + [ architecture.address-model ] + ; + ++ ++alias stack_traits_sources ++ : windows/stack_traits.cpp ++ : windows ++ ; ++ ++alias stack_traits_sources ++ : posix/stack_traits.cpp ++ ; ++ ++explicit stack_traits_sources ; ++ ++ + lib boost_context + : select_asm_context_sources ++ stack_traits_sources + ; + + boost-install boost_context ; +-- +2.3.5 + diff --git a/boost-context-0015-jump-and-make-stubs-for-arm64-aarch64-for-iOS-ABI.patch b/boost-context-0015-jump-and-make-stubs-for-arm64-aarch64-for-iOS-ABI.patch new file mode 100644 index 0000000..2ef000b --- /dev/null +++ b/boost-context-0015-jump-and-make-stubs-for-arm64-aarch64-for-iOS-ABI.patch @@ -0,0 +1,329 @@ +From efcdb6aae82d2ade5b81183e961e9ef282eaca31 Mon Sep 17 00:00:00 2001 +From: Evgeny Shapovalov +Date: Tue, 30 Dec 2014 17:14:49 +0300 +Subject: [PATCH 15/54] jump and make stubs for arm64 (aarch64) for iOS ABI + +--- + src/asm/jump_arm64_aapcs_macho_gas.S | 126 +++++++++++++++++------------------ + src/asm/make_arm64_aapcs_macho_gas.S | 72 ++++++++++---------- + 2 files changed, 95 insertions(+), 103 deletions(-) + +diff --git a/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S b/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S +index 6ad5b38..29df555 100644 +--- a/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S ++++ b/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S +@@ -1,10 +1,3 @@ +-/* +- Copyright Oliver Kowalke 2014. +- 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) +-*/ +- + /******************************************************* + * * + * ------------------------------------------------- * +@@ -12,113 +5,116 @@ + * ------------------------------------------------- * + * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * + * ------------------------------------------------- * +- * | s16 | s17 | s18 | s19 | * ++ * | d8 | d9 | d10 | d11 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * + * ------------------------------------------------- * + * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * + * ------------------------------------------------- * +- * | s20 | s21 | s22 | s23 | * ++ * | d12 | d13 | d14 | d15 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * + * ------------------------------------------------- * + * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * + * ------------------------------------------------- * +- * | s24 | s25 | s26 | s27 | * ++ * | x19 | x20 | x21 | x22 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * + * ------------------------------------------------- * + * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * + * ------------------------------------------------- * +- * | s28 | s29 | s30 | s31 | * ++ * | x23 | x24 | x25 | x26 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * + * ------------------------------------------------- * + * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * + * ------------------------------------------------- * +- * | sjlj | v1 | v2 | v3 | * +- * ------------------------------------------------- * +- * ------------------------------------------------- * +- * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * ++ * | x27 | x28 | FP | LR | * + * ------------------------------------------------- * +- * | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| * + * ------------------------------------------------- * +- * | v4 | v5 | v6 | v7 | * ++ * | 40 | 41 | 42 | 43 | | | * + * ------------------------------------------------- * ++ * | 0xa0| 0xa4| 0xa8| 0xac| | | * + * ------------------------------------------------- * +- * | 48 | 49 | 50 | 51 | 52 | 53 | | * +- * ------------------------------------------------- * +- * | 0xc0| 0xc4| 0xc8| 0xcc| 0xd0| 0xd4| | * +- * ------------------------------------------------- * +- * | v8 | lr | pc | | * ++ * | PC | align | | | * + * ------------------------------------------------- * + * * + *******************************************************/ + + .text + .globl _jump_fcontext +-.align 2 ++.balign 16 + _jump_fcontext: +- @ save LR as PC +- push {lr} +- @ save V1-V8,LR +- push {v1-v8,lr} +- +- @ locate TLS to save/restore SjLj handler +- mrc p15, 0, v2, c13, c0, #3 +- bic v2, v2, #3 +- +- @ load TLS[__PTK_LIBC_DYLD_Unwind_SjLj_Key] +- ldr v1, [v2, #72] +- @ save SjLj handler +- push {v1} +- +- @ prepare stack for FPU +- sub sp, sp, #128 ++ ; prepare stack for GP + FPU ++ sub sp, sp, #0xb0 + + #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) +- @ test if fpu env should be preserved +- cmp a4, #0 +- beq 1f ++ ; test if fpu env should be preserved ++ cmp w3, #0 ++ b.eq 1f + +- @ save S16-S31 +- vstmia sp, {d8-d15} ++ ; save d8 - d15 ++ stp d8, d9, [x0, #0x00] ++ stp d10, d11, [x0, #0x10] ++ stp d12, d13, [x0, #0x20] ++ stp d14, d15, [x0, #0x30] + + 1: + #endif + +- @ store RSP (pointing to context-data) in A1 +- str sp, [a1] ++ ; 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 fp, lr, [sp, #0x90] ++ ++ ; save LR as PC ++ str lr, [sp, #0xa0] + +- @ restore RSP (pointing to context-data) from A2 +- mov sp, a2 ++ ; store RSP (pointing to context-data) in first argument (x0). ++ ; STR cannot have sp as a target register ++ mov x4, sp ++ str x4, [x0] ++ ++ ; restore RSP (pointing to context-data) from A2 (x1) ++ mov sp, x1 + + #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) +- @ test if fpu env should be preserved +- cmp a4, #0 +- beq 2f ++ ; test if fpu env should be preserved ++ cmp w3, #0 ++ b.eq 2f + +- @ restore S16-S31 +- vldmia sp, {d8-d15} ++ ; load d8 - d15 ++ ldp d8, d9, [x0, #0x00] ++ ldp d10, d11, [x0, #0x10] ++ ldp d12, d13, [x0, #0x20] ++ ldp d14, d15, [x0, #0x30] + + 2: + #endif + +- @ prepare stack for FPU +- add sp, sp, #128 ++ ; 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 fp, lr, [sp, #0x90] ++ ++ ; use third arg as return value after jump ++ ; and as first arg in context function ++ mov x0, x2 ++ ++ ; load pc ++ ldr x4, [sp, #0xa0] + +- @ restore SjLj handler +- pop {v1} +- @ store SjLj handler in TLS +- str v1, [v2, #72] ++ ; restore stack from GP + FPU ++ add sp, sp, #0xb0 + +- @ use third arg as return value after jump +- @ and as first arg in context function +- mov a1, a3 +- +- @ restore v1-V8,LR,PC +- pop {v1-v8,lr,pc} ++ ret x4 +diff --git a/libs/context/src/asm/make_arm64_aapcs_macho_gas.S b/libs/context/src/asm/make_arm64_aapcs_macho_gas.S +index 67d2f89..6b55a08 100644 +--- a/libs/context/src/asm/make_arm64_aapcs_macho_gas.S ++++ b/libs/context/src/asm/make_arm64_aapcs_macho_gas.S +@@ -1,10 +1,3 @@ +-/* +- Copyright Oliver Kowalke 2014. +- 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) +-*/ +- + /******************************************************* + * * + * ------------------------------------------------- * +@@ -12,76 +5,79 @@ + * ------------------------------------------------- * + * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * + * ------------------------------------------------- * +- * | s16 | s17 | s18 | s19 | * ++ * | d8 | d9 | d10 | d11 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * + * ------------------------------------------------- * + * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * + * ------------------------------------------------- * +- * | s20 | s21 | s22 | s23 | * ++ * | d12 | d13 | d14 | d15 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * + * ------------------------------------------------- * + * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * + * ------------------------------------------------- * +- * | s24 | s25 | s26 | s27 | * ++ * | x19 | x20 | x21 | x22 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * + * ------------------------------------------------- * + * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * + * ------------------------------------------------- * +- * | s28 | s29 | s30 | s31 | * ++ * | x23 | x24 | x25 | x26 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * + * ------------------------------------------------- * + * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * + * ------------------------------------------------- * +- * | sjlj | v1 | v2 | v3 | * +- * ------------------------------------------------- * +- * ------------------------------------------------- * +- * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * ++ * | x27 | x28 | FP | LR | * + * ------------------------------------------------- * +- * | 0xa0| 0xa4| 0xa8| 0xac| 0xb0| 0xb4| 0xb8| 0xbc| * + * ------------------------------------------------- * +- * | v4 | v5 | v6 | v7 | * ++ * | 40 | 41 | 42 | 43 | | | * + * ------------------------------------------------- * ++ * | 0xa0| 0xa4| 0xa8| 0xac| | | * + * ------------------------------------------------- * +- * | 48 | 49 | 50 | 51 | 52 | 53 | | * +- * ------------------------------------------------- * +- * | 0xc0| 0xc4| 0xc8| 0xcc| 0xd0| 0xd4| | * +- * ------------------------------------------------- * +- * | v8 | lr | pc | | * ++ * | PC | align | | | * + * ------------------------------------------------- * + * * + *******************************************************/ + ++ + .text + .globl _make_fcontext +-.align 2 ++.balign 16 ++ + _make_fcontext: +- @ shift address in A1 to lower 16 byte boundary +- bic a1, a1, #15 ++ ; shift address in x0 (allocated stack) to lower 16 byte boundary ++ and x0, x0, ~0xF ++ ++ ; reserve space for context-data on context-stack ++ sub x0, x0, #0xb0 ++ ++ ; third arg of make_fcontext() == address of context-function ++ ; store address as a PC to jump in ++ str x2, [x0, #0xa0] + +- @ reserve space for context-data on context-stack +- sub a1, a1, #216 ++ ; compute abs address of label finish ++ ; 0x0c = 3 instructions * size (4) before label 'finish' + +- @ third arg of make_fcontext() == address of context-function +- str a3, [a1,#208] ++ ; TODO: Numeric offset since llvm still does not support labels in ADR. Fix: ++ ; http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140407/212336.html ++ adr x1, 0x0c + +- @ compute abs address of label finish +- adr a2, finish +- @ save address of finish as return-address for context-function +- @ will be entered after context-function returns +- str a2, [a1,#200] ++ ; save address of finish as return-address for context-function ++ ; will be entered after context-function returns (LR register) ++ str x1, [x0, #0x98] + +- bx lr @ return pointer to context-data ++ ret lr ; return pointer to context-data (x0) + + finish: +- @ exit code is zero +- mov a1, #0 +- @ exit application ++ ; exit code is zero ++ mov x0, #0 ++ ; exit application + bl __exit ++ ++ +-- +2.3.5 + diff --git a/boost-context-0016-remove-untested.cpp-for-ARM64-MACH-O.patch b/boost-context-0016-remove-untested.cpp-for-ARM64-MACH-O.patch new file mode 100644 index 0000000..85f88b0 --- /dev/null +++ b/boost-context-0016-remove-untested.cpp-for-ARM64-MACH-O.patch @@ -0,0 +1,40 @@ +From de60227a90989e502f5a0ade0c2a5d6bf7af82b8 Mon Sep 17 00:00:00 2001 +From: Oliver Kowalke +Date: Tue, 30 Dec 2014 21:08:50 +0100 +Subject: [PATCH 16/54] remove untested.cpp for ARM64/MACH-O + +--- + build/Jamfile.v2 | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/libs/context/build/Jamfile.v2 b/libs/context/build/Jamfile.v2 +index c2d34cb..c7f2af2 100644 +--- a/libs/context/build/Jamfile.v2 ++++ b/libs/context/build/Jamfile.v2 +@@ -227,7 +227,6 @@ alias asm_context_sources + alias asm_context_sources + : [ make asm/make_arm64_aapcs_macho_gas.o : asm/make_arm64_aapcs_macho_gas.S : @gas64 ] + [ make asm/jump_arm64_aapcs_macho_gas.o : asm/jump_arm64_aapcs_macho_gas.S : @gas64 ] +- untested.cpp + : aapcs + 64 + arm +@@ -237,7 +236,6 @@ alias asm_context_sources + alias asm_context_sources + : asm/make_arm64_aapcs_macho_gas.S + asm/jump_arm64_aapcs_macho_gas.S +- untested.cpp + : aapcs + 64 + arm +@@ -248,7 +246,6 @@ alias asm_context_sources + alias asm_context_sources + : asm/make_arm64_aapcs_macho_gas.S + asm/jump_arm64_aapcs_macho_gas.S +- untested.cpp + : aapcs + 64 + arm +-- +2.3.5 + diff --git a/boost-context-0046-add-support-for-ARM64-ELF.patch b/boost-context-0046-add-support-for-ARM64-ELF.patch new file mode 100644 index 0000000..57b544e --- /dev/null +++ b/boost-context-0046-add-support-for-ARM64-ELF.patch @@ -0,0 +1,299 @@ +From 8481d3ccfc8e9cd3b689c43418e27ccfe722fcb2 Mon Sep 17 00:00:00 2001 +From: Oliver Kowalke +Date: Mon, 23 Feb 2015 16:23:11 +0100 +Subject: [PATCH 46/54] add support for ARM64/ELF + +--- + build/Jamfile.v2 | 30 +++++++++ + config/arm.cpp | 2 +- + src/asm/jump_arm64_aapcs_elf_gas.S | 131 +++++++++++++++++++++++++++++++++++++ + src/asm/make_arm64_aapcs_elf_gas.S | 85 ++++++++++++++++++++++++ + 4 files changed, 247 insertions(+), 1 deletion(-) + create mode 100644 src/asm/jump_arm64_aapcs_elf_gas.S + create mode 100644 src/asm/make_arm64_aapcs_elf_gas.S + +diff --git a/libs/context/build/Jamfile.v2 b/libs/context/build/Jamfile.v2 +index 80d1c46..4bf3fce 100644 +--- a/libs/context/build/Jamfile.v2 ++++ b/libs/context/build/Jamfile.v2 +@@ -223,6 +223,36 @@ alias asm_context_sources + ; + + # ARM64 ++# ARM64/AAPCS/ELF ++alias asm_context_sources ++ : [ make asm/make_arm64_aapcs_elf_gas.o : asm/make_arm64_aapcs_elf_gas.S : @gas64 ] ++ [ make asm/jump_arm64_aapcs_elf_gas.o : asm/jump_arm64_aapcs_elf_gas.S : @gas64 ] ++ : aapcs ++ 64 ++ arm ++ elf ++ ; ++ ++alias asm_context_sources ++ : asm/make_arm64_aapcs_elf_gas.S ++ asm/jump_arm64_aapcs_elf_gas.S ++ : aapcs ++ 64 ++ arm ++ elf ++ clang ++ ; ++ ++alias asm_context_sources ++ : asm/make_arm64_aapcs_elf_gas.S ++ asm/jump_arm64_aapcs_elf_gas.S ++ : aapcs ++ 64 ++ arm ++ elf ++ gcc ++ ; ++ + # ARM64/AAPCS/MACH-O + alias asm_context_sources + : [ make asm/make_arm64_aapcs_macho_gas.o : asm/make_arm64_aapcs_macho_gas.S : @gas64 ] +diff --git a/libs/context/config/arm.cpp b/libs/context/config/arm.cpp +index 6a83737..6eece0b 100644 +--- a/libs/context/config/arm.cpp ++++ b/libs/context/config/arm.cpp +@@ -6,7 +6,7 @@ + // accompanying file LICENSE_1_0.txt or copy at + // http://www.boost.org/LICENSE_1_0.txt) + +-#if !defined(__arm__) && !defined(__thumb__) && \ ++#if !defined(__aarch64__) && !defined(__arm__) && !defined(__thumb__) && \ + !defined(__TARGET_ARCH_ARM) && !defined(__TARGET_ARCH_THUMB) && \ + !defined(_ARM) && !defined(_M_ARM) + #error "Not ARM" +diff --git a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S +new file mode 100644 +index 0000000..46e029d +--- /dev/null ++++ b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S +@@ -0,0 +1,131 @@ ++/* ++ Copyright Edward Nevill 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 | | | * ++ * ------------------------------------------------- * ++ * | 0xa0| 0xa4| 0xa8| 0xac| | | * ++ * ------------------------------------------------- * ++ * | PC | align | | | * ++ * ------------------------------------------------- * ++ * * ++ *******************************************************/ ++ ++.cpu generic+fp+simd ++.text ++.align 2 ++.global jump_fcontext ++.type jump_fcontext, %function ++jump_fcontext: ++ # prepare stack for GP + FPU ++ sub sp, sp, #0xb0 ++ ++# Because gcc may save integer registers in fp registers across a ++# function call we cannot skip saving the fp registers. ++# ++# Do not reinstate this test unless you fully understand what you ++# are doing. ++# ++# # test if fpu env should be preserved ++# cmp w3, #0 ++# b.eq 1f ++ ++ # save d8 - d15 ++ stp d8, d9, [sp, #0x00] ++ stp d10, d11, [sp, #0x10] ++ stp d12, d13, [sp, #0x20] ++ stp d14, d15, [sp, #0x30] ++ ++1: ++ # 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, #0xa0] ++ ++ # store RSP (pointing to context-data) in first argument (x0). ++ # STR cannot have sp as a target register ++ mov x4, sp ++ str x4, [x0] ++ ++ # restore RSP (pointing to context-data) from A2 (x1) ++ mov sp, x1 ++ ++# # test if fpu env should be preserved ++# cmp w3, #0 ++# b.eq 2f ++ ++ # load d8 - d15 ++ ldp d8, d9, [x0, #0x00] ++ ldp d10, d11, [x0, #0x10] ++ ldp d12, d13, [x0, #0x20] ++ ldp d14, d15, [x0, #0x30] ++ ++2: ++ # 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] ++ ++ # use third arg as return value after jump ++ # and as first arg in context function ++ mov x0, x2 ++ ++ # load pc ++ ldr x4, [sp, #0xa0] ++ ++ # restore stack from GP + FPU ++ add sp, sp, #0xb0 ++ ++ ret x4 ++.size jump_fcontext,.-jump_fcontext ++# Mark that we don't need executable stack. ++.section .note.GNU-stack,"",%progbits +diff --git a/libs/context/src/asm/make_arm64_aapcs_elf_gas.S b/libs/context/src/asm/make_arm64_aapcs_elf_gas.S +new file mode 100644 +index 0000000..b208ab7 +--- /dev/null ++++ b/libs/context/src/asm/make_arm64_aapcs_elf_gas.S +@@ -0,0 +1,85 @@ ++/* ++ Copyright Edward Nevill 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 | | | * ++ * ------------------------------------------------- * ++ * | 0xa0| 0xa4| 0xa8| 0xac| | | * ++ * ------------------------------------------------- * ++ * | PC | align | | | * ++ * ------------------------------------------------- * ++ * * ++ *******************************************************/ ++ ++.cpu generic+fp+simd ++.text ++.align 2 ++.global make_fcontext ++.type make_fcontext, %function ++make_fcontext: ++ # shift address in x0 (allocated stack) to lower 16 byte boundary ++ and x0, x0, ~0xF ++ ++ # reserve space for context-data on context-stack ++ sub x0, x0, #0xb0 ++ ++ # third arg of make_fcontext() == address of context-function ++ # store address as a PC to jump in ++ str x2, [x0, #0xa0] ++ ++ # save address of finish as return-address for context-function ++ # will be entered after context-function returns (LR register) ++ adr x1, finish ++ str x1, [x0, #0x98] ++ ++ ret x30 // return pointer to context-data (x0) ++ ++finish: ++ # exit code is zero ++ mov x0, #0 ++ # exit application ++ bl _exit ++ ++.size make_fcontext,.-make_fcontext ++# Mark that we don't need executable stack. ++.section .note.GNU-stack,"",%progbits +-- +2.3.5 + diff --git a/boost-context-0047-some-fixes-for-ARM64.patch b/boost-context-0047-some-fixes-for-ARM64.patch new file mode 100644 index 0000000..e6dfa2c --- /dev/null +++ b/boost-context-0047-some-fixes-for-ARM64.patch @@ -0,0 +1,169 @@ +From 1e2584e00c71e120d652f0d4ae105e54ceca16a8 Mon Sep 17 00:00:00 2001 +From: Oliver Kowalke +Date: Tue, 24 Feb 2015 17:50:14 +0100 +Subject: [PATCH 47/54] some fixes for ARM64 + +--- + src/asm/jump_arm64_aapcs_elf_gas.S | 44 ++++++++++++++++++------------------ + src/asm/jump_arm64_aapcs_macho_gas.S | 44 ++++++++++++++++++------------------ + 2 files changed, 44 insertions(+), 44 deletions(-) + +diff --git a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S +index 46e029d..889008f 100644 +--- a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S ++++ b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S +@@ -71,22 +71,22 @@ jump_fcontext: + # b.eq 1f + + # save d8 - d15 +- stp d8, d9, [sp, #0x00] +- stp d10, d11, [sp, #0x10] +- stp d12, d13, [sp, #0x20] +- stp d14, d15, [sp, #0x30] ++ stp d8, d9, [sp, #0x00] ++ stp d10, d11, [sp, #0x10] ++ stp d12, d13, [sp, #0x20] ++ stp d14, d15, [sp, #0x30] + + 1: + # 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] ++ 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 fp, lr, [sp, #0x90] + + # save LR as PC +- str x30, [sp, #0xa0] ++ str lr, [sp, #0xa0] + + # store RSP (pointing to context-data) in first argument (x0). + # STR cannot have sp as a target register +@@ -101,26 +101,26 @@ jump_fcontext: + # b.eq 2f + + # load d8 - d15 +- ldp d8, d9, [x0, #0x00] +- ldp d10, d11, [x0, #0x10] +- ldp d12, d13, [x0, #0x20] +- ldp d14, d15, [x0, #0x30] ++ ldp d8, d9, [sp, #0x00] ++ ldp d10, d11, [sp, #0x10] ++ ldp d12, d13, [sp, #0x20] ++ ldp d14, d15, [sp, #0x30] + + 2: + # 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] ++ 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 fp, lr, [sp, #0x90] + + # use third arg as return value after jump + # and as first arg in context function + mov x0, x2 + + # load pc +- ldr x4, [sp, #0xa0] ++ ldr x4, [sp, #0xa0] + + # restore stack from GP + FPU + add sp, sp, #0xb0 +diff --git a/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S b/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S +index 29df555..958178e 100644 +--- a/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S ++++ b/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S +@@ -58,24 +58,24 @@ _jump_fcontext: + b.eq 1f + + ; save d8 - d15 +- stp d8, d9, [x0, #0x00] +- stp d10, d11, [x0, #0x10] +- stp d12, d13, [x0, #0x20] +- stp d14, d15, [x0, #0x30] ++ stp d8, d9, [sp, #0x00] ++ stp d10, d11, [sp, #0x10] ++ stp d12, d13, [sp, #0x20] ++ stp d14, d15, [sp, #0x30] + + 1: + #endif + + ; 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 fp, lr, [sp, #0x90] ++ 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 fp, lr, [sp, #0x90] + + ; save LR as PC +- str lr, [sp, #0xa0] ++ str lr, [sp, #0xa0] + + ; store RSP (pointing to context-data) in first argument (x0). + ; STR cannot have sp as a target register +@@ -91,28 +91,28 @@ _jump_fcontext: + b.eq 2f + + ; load d8 - d15 +- ldp d8, d9, [x0, #0x00] +- ldp d10, d11, [x0, #0x10] +- ldp d12, d13, [x0, #0x20] +- ldp d14, d15, [x0, #0x30] ++ ldp d8, d9, [sp, #0x00] ++ ldp d10, d11, [sp, #0x10] ++ ldp d12, d13, [sp, #0x20] ++ ldp d14, d15, [sp, #0x30] + + 2: + #endif + + ; 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 fp, lr, [sp, #0x90] ++ 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 fp, lr, [sp, #0x90] + + ; use third arg as return value after jump + ; and as first arg in context function + mov x0, x2 + + ; load pc +- ldr x4, [sp, #0xa0] ++ ldr x4, [sp, #0xa0] + + ; restore stack from GP + FPU + add sp, sp, #0xb0 +-- +2.3.5 + diff --git a/boost-context-0048-do-not-use-aliases-LR-and-FP-for-ARM64-gcc.patch b/boost-context-0048-do-not-use-aliases-LR-and-FP-for-ARM64-gcc.patch new file mode 100644 index 0000000..2152702 --- /dev/null +++ b/boost-context-0048-do-not-use-aliases-LR-and-FP-for-ARM64-gcc.patch @@ -0,0 +1,38 @@ +From 6e2a2b4b309f4f98ece77edc8746fa683a2e05d8 Mon Sep 17 00:00:00 2001 +From: Oliver Kowalke +Date: Wed, 25 Feb 2015 19:49:30 +0100 +Subject: [PATCH 48/54] do not use aliases LR and FP for ARM64/gcc + +--- + src/asm/jump_arm64_aapcs_elf_gas.S | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S +index 889008f..09bd7b5 100644 +--- a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S ++++ b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S +@@ -83,10 +83,10 @@ jump_fcontext: + stp x23, x24, [sp, #0x60] + stp x25, x26, [sp, #0x70] + stp x27, x28, [sp, #0x80] +- stp fp, lr, [sp, #0x90] ++ stp x29, x30, [sp, #0x90] + + # save LR as PC +- str lr, [sp, #0xa0] ++ str x30, [sp, #0xa0] + + # store RSP (pointing to context-data) in first argument (x0). + # STR cannot have sp as a target register +@@ -113,7 +113,7 @@ jump_fcontext: + ldp x23, x24, [sp, #0x60] + ldp x25, x26, [sp, #0x70] + ldp x27, x28, [sp, #0x80] +- ldp fp, lr, [sp, #0x90] ++ ldp x29, x30, [sp, #0x90] + + # use third arg as return value after jump + # and as first arg in context function +-- +2.3.5 + diff --git a/boost-context-partial-revert-of-0002.patch b/boost-context-partial-revert-of-0002.patch new file mode 100644 index 0000000..b71cf5d --- /dev/null +++ b/boost-context-partial-revert-of-0002.patch @@ -0,0 +1,35 @@ +Index: boost_1_57_0/libs/context/build/Jamfile.v2 +=================================================================== +--- boost_1_57_0.orig/libs/context/build/Jamfile.v2 ++++ boost_1_57_0/libs/context/build/Jamfile.v2 +@@ -14,22 +14,9 @@ import os ; + import toolset ; + import architecture ; + +-feature.feature segmented-stacks : on : optional propagated composite ; +-feature.compose on : BOOST_USE_SEGMENTED_STACKS ; +- + project boost/context + : requirements +- /boost/system//boost_system +- /boost/thread//boost_thread + SOLARIS:_XOPEN_SOURCE=600 +- gcc-4.7,on:-fsplit-stack +- gcc-4.7,on:"-static-libgcc" +- gcc-4.8,on:-fsplit-stack +- gcc-4.8,on:"-static-libgcc" +- gcc-4.9,on:-fsplit-stack +- gcc-4.9,on:"-static-libgcc" +- clang-3.4,on:-fsplit-stack +- clang-3.4,on:"-static-libgcc" + shared:BOOST_CONTEXT_DYN_LINK=1 + BOOST_CONTEXT_SOURCE + : usage-requirements +@@ -849,7 +836,6 @@ alias stack_traits_sources + ; + + alias stack_traits_sources +- : posix/stack_traits.cpp + ; + + explicit stack_traits_sources ; diff --git a/boost-context-use-sysv-not-aapcs.patch b/boost-context-use-sysv-not-aapcs.patch new file mode 100644 index 0000000..11d988e --- /dev/null +++ b/boost-context-use-sysv-not-aapcs.patch @@ -0,0 +1,40 @@ +http://lists.boost.org/Archives/boost/2015/02/220155.php + +commit d19baee73f90de01375af69a9f8621799c649964 +Author: Edward Nevill +Date: Mon Feb 23 17:32:49 2015 +0000 + + Fix build for aarch64. + + +Index: boost_1_57_0/libs/context/build/Jamfile.v2 +=================================================================== +--- boost_1_57_0.orig/libs/context/build/Jamfile.v2 ++++ boost_1_57_0/libs/context/build/Jamfile.v2 +@@ -214,7 +214,7 @@ alias asm_context_sources + alias asm_context_sources + : [ make asm/make_arm64_aapcs_elf_gas.o : asm/make_arm64_aapcs_elf_gas.S : @gas64 ] + [ make asm/jump_arm64_aapcs_elf_gas.o : asm/jump_arm64_aapcs_elf_gas.S : @gas64 ] +- : aapcs ++ : sysv + 64 + arm + elf +@@ -223,7 +223,7 @@ alias asm_context_sources + alias asm_context_sources + : asm/make_arm64_aapcs_elf_gas.S + asm/jump_arm64_aapcs_elf_gas.S +- : aapcs ++ : sysv + 64 + arm + elf +@@ -233,7 +233,7 @@ alias asm_context_sources + alias asm_context_sources + : asm/make_arm64_aapcs_elf_gas.S + asm/jump_arm64_aapcs_elf_gas.S +- : aapcs ++ : sysv + 64 + arm + elf diff --git a/boost.spec b/boost.spec index f6c7743..751db4e 100644 --- a/boost.spec +++ b/boost.spec @@ -20,7 +20,7 @@ %bcond_without openmpi %endif -%ifnarch %{ix86} x86_64 %{arm} ppc64 ppc64le +%ifnarch %{ix86} x86_64 %{arm} ppc64 ppc64le aarch64 %bcond_with context %else %bcond_without context @@ -32,7 +32,7 @@ Name: boost Summary: The free peer-reviewed portable C++ source libraries Version: 1.57.0 %define version_enc 1_57_0 -Release: 6%{?dist} +Release: 7%{?dist} License: Boost and MIT and Python %define toplev_dirname %{name}_%{version_enc} @@ -135,6 +135,16 @@ Patch66: boost-1.57.0-uuid-comparison.patch # https://svn.boost.org/trac/boost/ticket/11044 Patch67: boost-1.57.0-move-is_class.patch +Patch70: boost-context-0001-add-support-for-ARM64-MACH-O.patch +Patch71: boost-context-0002-make-ARM64-unsupported.patch +Patch72: boost-context-0015-jump-and-make-stubs-for-arm64-aarch64-for-iOS-ABI.patch +Patch73: boost-context-0016-remove-untested.cpp-for-ARM64-MACH-O.patch +Patch74: boost-context-0046-add-support-for-ARM64-ELF.patch +Patch75: boost-context-0047-some-fixes-for-ARM64.patch +Patch76: boost-context-0048-do-not-use-aliases-LR-and-FP-for-ARM64-gcc.patch +Patch77: boost-context-partial-revert-of-0002.patch +Patch78: boost-context-use-sysv-not-aapcs.patch + %bcond_with tests %bcond_with docs_generated @@ -625,6 +635,15 @@ a number of significant features and is now developed independently %patch65 -p1 %patch66 -p2 %patch67 -p0 +%patch70 -p1 +%patch71 -p1 +%patch72 -p1 +%patch73 -p1 +%patch74 -p1 +%patch75 -p1 +%patch76 -p1 +%patch77 -p1 +%patch78 -p1 # At least python2_version needs to be a macro so that it's visible in # %%install as well. @@ -1244,6 +1263,13 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/bjam.1* %changelog +* Mon Apr 13 2015 Marcin Juszkiewicz - 1.57.0-7 +- Add AArch64 support for boost::context + - Numbered patches are cherry-picked from upstream repository. + - partial-revert-of-0002 removes some build definitions which are defined + in coroutine/ + - last patch changes ABI names - taken from boost ML + * Sun Apr 12 2015 David Tardon - 1.57.0-6 - rebuild for yet another C++ ABI break