From 8a9db1d4ce79ce40d63b23b185aa18ca77834525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 30 Nov 2020 21:50:18 +0000 Subject: [PATCH 001/115] Define boolean preprocessor macro explicitly for Visual Studio --- src/stackman_switch.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/stackman_switch.h b/src/stackman_switch.h index 11d4157..3694cdf 100644 --- a/src/stackman_switch.h +++ b/src/stackman_switch.h @@ -30,8 +30,11 @@ * building a library, because an optimizing compiler may * decide to inline functions that contain in-line assembler */ -#define STACKMAN_SWITCH_NEED_INDIRECT \ - (!defined(STACKMAN_ASSEMBLY_SRC) && !defined(STACKMAN_BUILD_LIB)) +#if (!defined(STACKMAN_ASSEMBLY_SRC) && !defined(STACKMAN_BUILD_LIB)) +#define STACKMAN_SWITCH_NEED_INDIRECT 1 +#else +#define STACKMAN_SWITCH_NEED_INDIRECT 0 +#endif #if STACKMAN_SWITCH_NEED_INDIRECT #define STACKMAN_SWITCH_INASM_NAME _stackman_switch_inasm From 641f3e1dfffc846c7f930f9fec1fb1e1e6d54a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 30 Nov 2020 21:50:50 +0000 Subject: [PATCH 002/115] Initial visual studio commit, 32bit x86 --- .gitignore | 7 ++ src/platforms/switch_x86_msvc.asm | 4 +- src/platforms/switch_x86_msvc.h | 6 +- vs2019/stackman.sln | 34 ++++++++ vs2019/stackman/stackman.vcxproj | 106 +++++++++++++++++++++++ vs2019/stackman/stackman.vcxproj.filters | 50 +++++++++++ vs2019/test/test.vcxproj | 85 ++++++++++++++++++ vs2019/test/test.vcxproj.filters | 22 +++++ 8 files changed, 309 insertions(+), 5 deletions(-) create mode 100644 vs2019/stackman.sln create mode 100644 vs2019/stackman/stackman.vcxproj create mode 100644 vs2019/stackman/stackman.vcxproj.filters create mode 100644 vs2019/test/test.vcxproj create mode 100644 vs2019/test/test.vcxproj.filters diff --git a/.gitignore b/.gitignore index f50aad5..50d2d13 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,10 @@ dkms.conf # custom bin/ + +# Visual Studio noise +# Visual Studio 2015/2017 cache/options directory +.vs/ +*.user +# Build results +[Dd]ebug/ \ No newline at end of file diff --git a/src/platforms/switch_x86_msvc.asm b/src/platforms/switch_x86_msvc.asm index 1e6542e..edb20da 100644 --- a/src/platforms/switch_x86_msvc.asm +++ b/src/platforms/switch_x86_msvc.asm @@ -13,8 +13,8 @@ stackman_switch_raw PROC callback:DWORD, context:DWORD push edi push ebp - mov esi, callback ; /* save 'callback' for later */ - mov edi, extra ; /* save 'context' for later */ + mov esi, callback ; /* save 'callback' for later */ + mov edi, context ; /* save 'context' for later */ mov eax, esp diff --git a/src/platforms/switch_x86_msvc.h b/src/platforms/switch_x86_msvc.h index afa3669..9b5d280 100644 --- a/src/platforms/switch_x86_msvc.h +++ b/src/platforms/switch_x86_msvc.h @@ -3,7 +3,7 @@ * The C function defined here, saves and restores the structured * exception handling state. */ -#ifndef STACKMAN_ASSEMBLY_SRC +#if !defined(STACKMAN_ASSEMBLY_SRC) #define STACKMAN_ASSEMBLY_SRC switch_x86_msvc.asm #define STACKMAN_SWITCH_C 1 /* contains a C implementation */ #endif @@ -21,11 +21,11 @@ extern void *stackman_switch_raw(stackman_cb_t callback, void *context); #pragma warning(disable:4733) /* disable warning about modifying FS[0] */ STACKMAN_LINKAGE_SWITCH -void *stackman_switch(vtackman_cb_t callback, void *context) +void *stackman_switch(stackman_cb_t callback, void *context) { /* store the structured exception state for this stack */ DWORD seh_state = __readfsdword(FIELD_OFFSET(NT_TIB, ExceptionList)); - void * result = sta_switchckman_raw(callback, context); + void * result = stackman_switch_raw(callback, context); __writefsdword(FIELD_OFFSET(NT_TIB, ExceptionList), seh_state); return result; } diff --git a/vs2019/stackman.sln b/vs2019/stackman.sln new file mode 100644 index 0000000..8c508bf --- /dev/null +++ b/vs2019/stackman.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}" + ProjectSection(ProjectDependencies) = postProject + {BF7D0638-AC4F-4206-B426-66CDDD468281} = {BF7D0638-AC4F-4206-B426-66CDDD468281} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stackman", "stackman\stackman.vcxproj", "{BF7D0638-AC4F-4206-B426-66CDDD468281}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x64.ActiveCfg = Debug|x64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x64.Build.0 = Debug|x64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x86.ActiveCfg = Debug|Win32 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x86.Build.0 = Debug|Win32 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x64.ActiveCfg = Debug|x64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x64.Build.0 = Debug|x64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x86.ActiveCfg = Debug|Win32 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x86.Build.0 = Debug|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A71982F0-A89C-45AB-9F23-149A1983A11B} + EndGlobalSection +EndGlobal diff --git a/vs2019/stackman/stackman.vcxproj b/vs2019/stackman/stackman.vcxproj new file mode 100644 index 0000000..d7232ec --- /dev/null +++ b/vs2019/stackman/stackman.vcxproj @@ -0,0 +1,106 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + + 16.0 + Win32Proj + {bf7d0638-ac4f-4206-b426-66cddd468281} + stackman + 10.0 + stackman + + + + StaticLibrary + true + v142 + Unicode + + + StaticLibrary + true + v142 + Unicode + + + + + + + + + + + + + + + + true + $(SolutionDir)\..\lib\x86_msvc\ + + + true + + + + Level3 + true + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + Use + pch.h + + + + + true + + + + + + + + + + + + + + + + true + + + + + + + + \ No newline at end of file diff --git a/vs2019/stackman/stackman.vcxproj.filters b/vs2019/stackman/stackman.vcxproj.filters new file mode 100644 index 0000000..aad1ba2 --- /dev/null +++ b/vs2019/stackman/stackman.vcxproj.filters @@ -0,0 +1,50 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/vs2019/test/test.vcxproj b/vs2019/test/test.vcxproj new file mode 100644 index 0000000..84e4901 --- /dev/null +++ b/vs2019/test/test.vcxproj @@ -0,0 +1,85 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + + 16.0 + Win32Proj + {cafdbd3e-9d0d-4e90-bb6d-6c2a19f5ef53} + test + 10.0 + + + + Application + true + v142 + Unicode + + + Application + true + v142 + Unicode + + + + + + + + + + + + + + + true + + + true + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\src + + + Console + true + ..\..\lib\x86_msvc;%(AdditionalLibraryDirectories) + stackman.lib;%(AdditionalDependencies) + + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + + + + + \ No newline at end of file diff --git a/vs2019/test/test.vcxproj.filters b/vs2019/test/test.vcxproj.filters new file mode 100644 index 0000000..154d04b --- /dev/null +++ b/vs2019/test/test.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file From 31bd6206ae7669ba016f50db0728e67040714513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 1 Dec 2020 08:59:38 +0000 Subject: [PATCH 003/115] Add stackman_call for x86 32 bit --- src/platforms/switch_x86_msvc.asm | 18 ++++++++++++++++++ src/platforms/switch_x86_msvc.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/platforms/switch_x86_msvc.asm b/src/platforms/switch_x86_msvc.asm index edb20da..c23b861 100644 --- a/src/platforms/switch_x86_msvc.asm +++ b/src/platforms/switch_x86_msvc.asm @@ -38,4 +38,22 @@ stackman_switch_raw PROC callback:DWORD, context:DWORD ret stackman_switch_raw ENDP + +stackman_call PROC callback:DWORD, context:DWORD, stack_pointer:DWORD + ;enter prolog has pushed ebp and saved esp in ebp + + mov eax, callback + mov ecx, context + mov edx, stack_pointer + + ; switch stack pointer + mov esp, stack_pointer + push ebp ;old stack pointer + push 2 ;STACKMAN_OP_CALL + push ecx ;context + call eax ;callback + ret ; this assembles a LEAVE instruction which restores esp to ebp, then pops the ebp +stackman_call ENDP + + end diff --git a/src/platforms/switch_x86_msvc.h b/src/platforms/switch_x86_msvc.h index 9b5d280..e2c42eb 100644 --- a/src/platforms/switch_x86_msvc.h +++ b/src/platforms/switch_x86_msvc.h @@ -8,6 +8,9 @@ #define STACKMAN_SWITCH_C 1 /* contains a C implementation */ #endif +#define STACKMAN_HAVE_CALL 1 +#define STACKMAN_STACK_ALIGN 4 + #ifdef STACKMAN_SWITCH_IMPL #include "../stackman_switch.h" From 5018e95b46d0dee9f8ca11878332f031db9ecc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 1 Dec 2020 11:28:03 +0000 Subject: [PATCH 004/115] Fix warnings from Visual Studio --- tests/test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test.c b/tests/test.c index a06f003..3bf8af3 100644 --- a/tests/test.c +++ b/tests/test.c @@ -108,6 +108,7 @@ void *jmp_cb(void* context, int opcode, void *sp) jmp *jmp_save(void *farptr) { jmp *res = (jmp*)malloc(sizeof(jmp)); + assert(res); memset(res, 0, sizeof(jmp)); /* far end of stack, add buffer to catch memory backed registers, etc. */ res->stack_far = STACKMAN_SP_ADD((char*)farptr, 32); @@ -206,12 +207,12 @@ void test_04(void) char *block, *stack, *stack2; int stacksize=1024; int i, cnt; - void *res; ctxt01 ctxt; assert(STACKMAN_STACK_FULL_DESCENDING); block = (char*)malloc(stacksize); + assert(block); stack = block + stacksize; /* clear it all to a certain value */ memset(block, '\x7f', stacksize); From 77454994d18283f92f11880edff625d9553ffc19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 1 Dec 2020 11:36:13 +0000 Subject: [PATCH 005/115] Add win x86 library. Rename windows abi to win_XXX --- .gitignore | 6 +++++- README.md | 4 ++-- lib/win_x86/stackman.lib | Bin 0 -> 12318 bytes lib/x86_msvc/stackman.lib | Bin 0 -> 12318 bytes src/platforms/platform.h | 6 +++--- vs2019/stackman/stackman.vcxproj | 11 ++++++++--- vs2019/test/test.vcxproj | 5 ++++- 7 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 lib/win_x86/stackman.lib create mode 100644 lib/x86_msvc/stackman.lib diff --git a/.gitignore b/.gitignore index 50d2d13..966beb3 100644 --- a/.gitignore +++ b/.gitignore @@ -59,4 +59,8 @@ bin/ .vs/ *.user # Build results -[Dd]ebug/ \ No newline at end of file +[Dd]ebug/ + +# Allow our release libraries +!lib/**/*.lib +!lib/**/*.a \ No newline at end of file diff --git a/README.md b/README.md index 07254b3..c854640 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ platforms so that no assembly steps are required by users. The current code is distilled out of other work, with the aim of simplifying and standardizing the api. A number of ABI specifications is supported, meaning architecture and calling convention, plus archive format: - - microsoft_cdecl (32 bits) - - microsoft_x64 + - win_x86 (32 bits) + - win_x64 - sysv_i386 (linux) - sysv_amd64 (linux) - AAPCS (32 bit arm) diff --git a/lib/win_x86/stackman.lib b/lib/win_x86/stackman.lib new file mode 100644 index 0000000000000000000000000000000000000000..be3275f00b3abea96ae448af015df399de7d3a5c GIT binary patch literal 12318 zcmcIq3vgSGcNPVoziu5GYA4w(zegqPc?0E9=w05O5BiEg#uAOn+N$NE5)O9_HDch+g zk;9(5?>+oQ%AvA@#qQp{d-v|$yLWf*+wJ?Jx!BAB(;l%h^w_Mn!QQ@JYfmNIsu%73 z2K+t~W2}iW;b|?l9$>8XfRZmnV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TkNY!LHvc28V~gVz{)pRqwm>mcckZTVmR}(awk~ zj3I)M?3`#d`|M=TXwe-rW1Q7Ww3Qqf=@0Ezf(rGm>W%@g*=w0 zKlB?6J9@-!uM@OJLt^*w>`)e891?j|?9QsWR00n{PN-;cEH|(cj$5qbR*JFMYn%`~5 z@41_3A(=WJi!9e0Y}GG}G5-#)aHQF}L^2W0or+9^mhDG>;&W}66!@5y6V0^|N!2A$ zJKk%eruld3Qv4tzJDEsdhoQx?*=r?4I=zuKZKP}ZHrPCRys#Z{2jVWw`z-|H-e6o$ zT}MLBLy>;VV9_r;OF}#XnQdl`8`rR#fxQLs!-!iEyAUre&i(Y&zx<A>r6zjD|AJ^J?S=FpR$I2U>D!MSJFEWVyS{nC58hTflkW7B`$9sOd{-|YDh zBR&1{*Eb4J{PLf`A`hh}K}}Upf*x%Y=Jh8*Wsh3m_rfzBx^Y*A@&_XgsA?4GNeg*C zN}>EQ3-`7N)6wxiT8{p?n*(XdBSVk0c+WbNu{)9D{S+ZMcokb{ew=AQh*pWt z!zfkydd>lYy|fJHYbeq4fl{jrD3N2Y1bG!Da`2TPzeI^VJ0-{(Fig%p4O0H_hVvwZ zQAfGn*)Qp{QI5m86zHGA#2dRY7#eT6oH^eDJ7XqHj@^*OPs6(KG zI%KQ{GNVJ*6mcG@!TDqj~D3DChPJCLR{8YY4x1mN}G@J z2V{Ic1X^>I!BX~Ah|iD^s6;^N6;M@bzu7BFozL`&vfP(>MOo%!yrR^8e+R7kle?lU z`;}c$>V8-U|8>5l16up}939m8Vy-C5d?c@aOjrMP-3sreuJT}B!2v{jXC>#ez@ef$ fohXdpW4~Su&CC|?F)dwHThukJk%3iICe!}|hFunT literal 0 HcmV?d00001 diff --git a/lib/x86_msvc/stackman.lib b/lib/x86_msvc/stackman.lib new file mode 100644 index 0000000000000000000000000000000000000000..66ce8a52b410b2a0d51411b952ccd7aed9d2cafc GIT binary patch literal 12318 zcmcIq4R9OBb>1T>k^yBJq<*Z*igc3cA4w(z{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Dir)\..\lib\x86_msvc\ + $(SolutionDir)\..\lib\win_x86\ + $(Platform)\$(Configuration)\ true + $(SolutionDir)\..\lib\win_x64\ @@ -73,8 +75,9 @@ true _DEBUG;_LIB;%(PreprocessorDefinitions) true - Use + NotUsing pch.h + OldStyle @@ -97,7 +100,9 @@ true - + + true + diff --git a/vs2019/test/test.vcxproj b/vs2019/test/test.vcxproj index 84e4901..0422056 100644 --- a/vs2019/test/test.vcxproj +++ b/vs2019/test/test.vcxproj @@ -59,7 +59,7 @@ Console true - ..\..\lib\x86_msvc;%(AdditionalLibraryDirectories) + ..\..\lib\win_x86;%(AdditionalLibraryDirectories) stackman.lib;%(AdditionalDependencies) @@ -70,10 +70,13 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + ..\..\src Console true + stackman.lib;%(AdditionalDependencies) + ..\..\lib\win_x64;%(AdditionalLibraryDirectories) From 0864522a2818d738f8ed18c0ab69f6a92f6de0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 1 Dec 2020 12:35:50 +0000 Subject: [PATCH 006/115] Pass in stack marker from calling function to ensure that it is outside the stack that we want to save. On x64 (windows) it is the best way to ensure that we capture the entirety of the callee's local stack. --- tests/test.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/test.c b/tests/test.c index 3bf8af3..5205d76 100644 --- a/tests/test.c +++ b/tests/test.c @@ -110,6 +110,8 @@ jmp *jmp_save(void *farptr) jmp *res = (jmp*)malloc(sizeof(jmp)); assert(res); memset(res, 0, sizeof(jmp)); + + /* add safety margin */ /* far end of stack, add buffer to catch memory backed registers, etc. */ res->stack_far = STACKMAN_SP_ADD((char*)farptr, 32); @@ -136,13 +138,12 @@ void test_02_called(jmp *c) assert(0); } -void test_02(void) +void test_02(void *stack_marker) { - int stack_marker; static jmp *c; jmp * tmp; - tmp = jmp_save(&stack_marker); + tmp = jmp_save(stack_marker); if (tmp) { c = tmp; assert(c->counter == 2); @@ -162,9 +163,8 @@ void test_02(void) } /* test stack stuff not changing */ -void test_03(void) +void test_03(void *stack_marker) { - int stack_marker; static jmp *c; jmp * tmp; int foo[2]; @@ -253,12 +253,13 @@ void test_04(void) int main(int argc, char*argv[]) { + int stack_marker = 0; test_01(); printf("test_01 ok\n"); - test_02(); + test_02((void*)&stack_marker); printf("test_02 ok\n"); - test_03(); + test_03((void*)&stack_marker); printf("test_03 ok\n"); #ifdef TEST_04 test_04(); From bfdd3a6c6bcadb8c98d226aaf1852a3a6074fa9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 1 Dec 2020 12:36:12 +0000 Subject: [PATCH 007/115] Add initial win_x64 lib --- lib/win_x64/stackman.lib | Bin 0 -> 4534 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/win_x64/stackman.lib diff --git a/lib/win_x64/stackman.lib b/lib/win_x64/stackman.lib new file mode 100644 index 0000000000000000000000000000000000000000..198638d91b2b87046fb68b799e8c32d37dc81a54 GIT binary patch literal 4534 zcmb`KU2GiH701td9ouXoY(q&QKs<3bG%nupezDoONxEyVzvA@=UVk-AvL4Uw+SBap ztaip9P*g1hs#GZ@qEbSu79qq#sQS={sH)UfifBZUN>xO8pb|oGX%E+~sfU0p(L@rAshus`7Qhim)2_D_GX+&||c zA_x9D4O3Q5X>u-Utf;24NVlppP^GgDN;{$TE@%f(uhYIs{Z2ZkBe}Pc z=x(fsi)f}-O}CaS{km~0(Dk2iWFG=8}&=->Fw!l$V0!|Gz`%hxL0g#m4F zcqcm@#fcgrZ$wgdL#c-mp_U$d++=y& z0}$%qkLtqX-m*$2)7rIbW!{{jE-J= zcksEntEFCcUHt52?mK-&IGKFxL{y5Nh@OllGqGm9WD83rV_1SU44A`!Jq#GcfJF>U zl4;gq6WXAA@Tn`jwBN7+A97PJEfAapM^Z^@g4AmDIi}la+CMS(Xnx!~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KHFp~ptK{>yrf9TpvVS%a z8-}C0Mv-RUY9R2LC_YOaK@0q1X zFTVf!9!|%tQpr2&H{~7YoQ|TMcU0Y99B-Wtul;rf)%ScU@8H|3wp8EqrM!c0uG%72 R-B}#NoerUP0Df`*{{R92>;3=$ literal 0 HcmV?d00001 From be92e082173453717a7975ab609e6d04a72e508b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 1 Dec 2020 16:05:45 +0000 Subject: [PATCH 008/115] Complete windows support for x86 and x64 --- lib/win_x64/stackman.lib | Bin 4534 -> 5048 bytes lib/win_x86/stackman.lib | Bin 12318 -> 12318 bytes lib/x86_msvc/stackman.lib | Bin 12318 -> 0 bytes src/platforms/switch_x64_msvc.asm | 35 ++++++++++++++++++++++- src/platforms/switch_x64_msvc.h | 4 +++ tests/test.c | 2 +- vs2019/stackman/stackman.vcxproj | 8 ++++++ vs2019/stackman/stackman.vcxproj.filters | 3 ++ vs2019/stackman/template.c | 15 ++++++++++ vs2019/test/test.vcxproj | 2 ++ 10 files changed, 67 insertions(+), 2 deletions(-) delete mode 100644 lib/x86_msvc/stackman.lib create mode 100644 vs2019/stackman/template.c diff --git a/lib/win_x64/stackman.lib b/lib/win_x64/stackman.lib index 198638d91b2b87046fb68b799e8c32d37dc81a54..cb336fc7addccfccc5db49d44bae21bdbfd4a444 100644 GIT binary patch delta 1541 zcmaLXe{2(F7{Kx8db`nGhpE`j01j@@Z4hg1_oIS8l7S<3+D(uRf8yG$Rgeua6f^wQ zQ`Be*k#Ppp7&RJ=8c8Heh=I&RCC2DKi{YRBVIuxPG!hdf#^@jF_qldRjq%;y_w(Fy zckkUjeeaI1{HWt#%et;LJ)NCSO-od_x-aCjwul5oj6v-58rd1lfmk$M{-h;c{&JxFMW%e}gkG_~d?vl`ob%Ug`anUp zem4DLz%-f`vBQ))#!95qUFID%`;&$hu&m9-MiPDv`ZSUqWM2rebqgUz@X7vm$?f{)^Id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stackman.lib index be3275f00b3abea96ae448af015df399de7d3a5c..cb7e7c82e6f5fec3bd0c7ba71e891b3fcc8e65c0 100644 GIT binary patch delta 72 zcmbQ2FfU<(EUU4Fsgcn{rKwQHo|zEFMa*7-QL(jSN71@yYod L{2;Lgj(O?;|ECm+ diff --git a/lib/x86_msvc/stackman.lib b/lib/x86_msvc/stackman.lib deleted file mode 100644 index 66ce8a52b410b2a0d51411b952ccd7aed9d2cafc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12318 zcmcIq4R9OBb>1T>k^yBJq<*Z*igc3cA4w(z{(%H7**pRV5)%FdfTSeDIfKB7gpEG~ zphVfV!bH;_g^3cUNhTT3WX6sAn`tH!yPhWXw05O5BiEg#uAOn+N$NE5)O9_HDch+g zk;8s(?+*VWHWTj&MWTFt8RdUgjOi>QbcR)ioMn3HZWM?ZYq)P z>y0?o>A9JRE|&Qro07_(h*>hz53q`QU7Wnaw9l9ZotV+9)oxJN(jKeTX0wT6kFBRy zgWPZO2u&=t=O2~fb&TBr`B1PF)cHbJDy@|mJAlm7MnO+SX1(7Mj~1d;@ap0Svp#2u z)1bOSM%{%*#+Fcc26{rF8F7S}M|Hd~2jXuW@sf^XzzA<*@$Jy$)WqUk>*Ay97cT@L zo8=!Yz8-i$KzioF`umiR-FxvouomUkMeq8>3GVbquVJG579p1v&0%XA2kP<)ZkwX470ShFIcBH^zW~8*9I*`)jY(RP=(oINF z$2KGFM0yia)Dd3`sAF4^0>-u>C0;*@6fm|O>CH%YAO(zxND{qAQV9^Wq&~Vt1s}#bhEs z7fp(x!dyI&iSQwy!ErU8Ph`^3WMtA231>3Ne8d|)baX0b%@y9VX7Gcy;aAp)8-5(uRNX^a*OeOJoN?*`V^0lP@Lz{uiF z!(g*c0HK^3Fq0;`0E^j-39jsil#Tk~X`Oz!3BBeXwxCxcLacCBm24(~&U3tP0NE@e z@zutXdd|c?fHKiyX=4Idp`3}S$YGHoCiI+%(SmDdLMPC957bLLYc&)93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W+Qf`9v}i&7F!&hF0uHf8uj(mlXJzRuav% z5lPi0Q9IsiqNe$G>QekLBRiQ$Ux%T^ve|1TL^{2hHEpJA`VQDUdc3d`aTnqq%=;|_ z%cHM_cTcP z!yC?%5Jny4dgs2P&qg^8=Te}53X^Z{#b9W><#OhH3-mOH`k=6mkB)M?NL&a_OyuqG z!cm7n2X)AJ4P;h_tSjO?T7&cH8pz`nkn$%%T#f>bvWTMh&DdY+AWhcg4}`d^uhQyy zy_Gf}{g|%)>$+9mOI_u`yn+LW_RdPq kXMsaScREoR#m9cV7@D0c;A2|4s + + AssemblyCode + false + Default + false + true + true + diff --git a/vs2019/stackman/stackman.vcxproj.filters b/vs2019/stackman/stackman.vcxproj.filters index aad1ba2..7ebc972 100644 --- a/vs2019/stackman/stackman.vcxproj.filters +++ b/vs2019/stackman/stackman.vcxproj.filters @@ -38,6 +38,9 @@ Source Files + + Source Files + diff --git a/vs2019/stackman/template.c b/vs2019/stackman/template.c new file mode 100644 index 0000000..ca9b63f --- /dev/null +++ b/vs2019/stackman/template.c @@ -0,0 +1,15 @@ +#include "..\..\src\stackman.h" + +/* + * template file to create assembly code (template.asm) to modify and add to real assembler. + */ + +void* stackman_call_templ(stackman_cb_t callback, void* context, void* stack) +{ + // We use this variabl here for the template generation. Int the modified assembly + // code, we will store the ebp (base pointer) in that place on the stack, + // before storing the original unmodified stack pointer there. + void* localvar = stack; + return callback(context, 2, localvar); + +} \ No newline at end of file diff --git a/vs2019/test/test.vcxproj b/vs2019/test/test.vcxproj index 0422056..017cdf3 100644 --- a/vs2019/test/test.vcxproj +++ b/vs2019/test/test.vcxproj @@ -44,6 +44,8 @@ true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ true From e20907352a4ae8c55a03a83fe1ea759cde75757c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 1 Dec 2020 16:35:01 +0000 Subject: [PATCH 009/115] conditionally define some macros to avoid warnings. --- src/platforms/switch_aarch64_gcc.h | 2 ++ src/platforms/switch_arm_gcc.h | 2 ++ src/platforms/switch_x64_msvc.h | 6 ++---- src/platforms/switch_x86_64_gcc.h | 2 ++ src/platforms/switch_x86_gcc.h | 2 ++ src/platforms/switch_x86_msvc.h | 4 ++-- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/platforms/switch_aarch64_gcc.h b/src/platforms/switch_aarch64_gcc.h index 93d1067..2ace4bd 100644 --- a/src/platforms/switch_aarch64_gcc.h +++ b/src/platforms/switch_aarch64_gcc.h @@ -14,8 +14,10 @@ #endif #endif +#ifndef STACKMAN_HAVE_CALL #define STACKMAN_HAVE_CALL 1 #define STACKMAN_STACK_ALIGN 16 +#endif #ifdef STACKMAN_SWITCH_IMPL #if !__ASSEMBLER__ && !defined(STACKMAN_ASSEMBLY_SRC) diff --git a/src/platforms/switch_arm_gcc.h b/src/platforms/switch_arm_gcc.h index 3e239a3..de8254c 100644 --- a/src/platforms/switch_arm_gcc.h +++ b/src/platforms/switch_arm_gcc.h @@ -15,8 +15,10 @@ #endif #endif +#ifndef STACKMAN_HAVE_CALL #define STACKMAN_HAVE_CALL 1 #define STACKMAN_STACK_ALIGN 8 +#endif #ifdef STACKMAN_SWITCH_IMPL #if !__ASSEMBLER__ && !defined(STACKMAN_ASSEMBLY_SRC) diff --git a/src/platforms/switch_x64_msvc.h b/src/platforms/switch_x64_msvc.h index bd91b75..0b4d1c5 100644 --- a/src/platforms/switch_x64_msvc.h +++ b/src/platforms/switch_x64_msvc.h @@ -3,8 +3,6 @@ */ #ifndef STACKMAN_ASSEMBLY_SRC #define STACKMAN_ASSEMBLY_SRC switch_x64_msvc.asm -#endif - - #define STACKMAN_HAVE_CALL 1 -#define STACKMAN_STACK_ALIGN 16 \ No newline at end of file +#define STACKMAN_STACK_ALIGN 16 +#endif diff --git a/src/platforms/switch_x86_64_gcc.h b/src/platforms/switch_x86_64_gcc.h index 20375f3..acb9eba 100644 --- a/src/platforms/switch_x86_64_gcc.h +++ b/src/platforms/switch_x86_64_gcc.h @@ -16,8 +16,10 @@ #endif #endif +#ifndef STACKMAN_HAVE_CALL #define STACKMAN_HAVE_CALL 1 #define STACKMAN_STACK_ALIGN 16 +#endif #if defined(STACKMAN_SWITCH_IMPL) diff --git a/src/platforms/switch_x86_gcc.h b/src/platforms/switch_x86_gcc.h index c380529..e8dbf18 100644 --- a/src/platforms/switch_x86_gcc.h +++ b/src/platforms/switch_x86_gcc.h @@ -10,8 +10,10 @@ #endif #endif +#ifndef STACKMAN_HAVE_CALL #define STACKMAN_HAVE_CALL 1 #define STACKMAN_STACK_ALIGN 16 +#endif #if defined(STACKMAN_SWITCH_IMPL ) #if !__ASSEMBLER__ && !defined(STACKMAN_ASSEMBLY_SRC) diff --git a/src/platforms/switch_x86_msvc.h b/src/platforms/switch_x86_msvc.h index e2c42eb..ca176d0 100644 --- a/src/platforms/switch_x86_msvc.h +++ b/src/platforms/switch_x86_msvc.h @@ -6,10 +6,10 @@ #if !defined(STACKMAN_ASSEMBLY_SRC) #define STACKMAN_ASSEMBLY_SRC switch_x86_msvc.asm #define STACKMAN_SWITCH_C 1 /* contains a C implementation */ -#endif - #define STACKMAN_HAVE_CALL 1 #define STACKMAN_STACK_ALIGN 4 +#endif + #ifdef STACKMAN_SWITCH_IMPL #include "../stackman_switch.h" From d4c12150593664ae757616aa8bccec5a7549455a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 1 Dec 2020 16:35:42 +0000 Subject: [PATCH 010/115] use the /Brepro flag in library generation to avoid timestamps in the executable and get reproducable builds. --- lib/win_x64/stackman.lib | Bin 5048 -> 5048 bytes lib/win_x86/stackman.lib | Bin 12318 -> 12318 bytes vs2019/stackman/stackman.vcxproj | 6 ++++++ 3 files changed, 6 insertions(+) diff --git a/lib/win_x64/stackman.lib b/lib/win_x64/stackman.lib index cb336fc7addccfccc5db49d44bae21bdbfd4a444..8d53b0413854ff1024a6a887af6d502f81e6720f 100644 GIT binary patch delta 98 zcmdm?zC(S21edO%0u)SCib3Xeq#*OYWgzh;>+y(9u45EnYAV<~fpH2Ks+1Z?IE*KW F9RNLZ7AgP$ delta 98 zcmdm?zC(S21ec+iftiJ|g{hIzM5P#HUPlTt?^^~EZ?Ybb*yK7!0j6IWn={5FU2B(Vbk01O#{ diff --git a/lib/win_x86/stackman.lib b/lib/win_x86/stackman.lib index cb7e7c82e6f5fec3bd0c7ba71e891b3fcc8e65c0..60374c7f75d98e1a97f27f66fdd37214959ebeb3 100644 GIT binary patch delta 135 zcmbQ2FfU<(1edO%0u)SCnt;sPGX;q^If^j{nR|gzjj6F<^AE-_HdJBp$@v`oAgKn9 s9ozyIbDi8iNeLg=T3Gjhtw2&_vxmrfF^>Fflgo7z*c~?i*OF%i0P$iax&QzG delta 135 zcmbQ2FfU<(1ec+iftiJ|g{hIzM5PJHyggHpc$1?TbC9_g7}c15Wo-Vz7{&$>HZnFf zH=2BbQG9Yf2S3vkz0D0AJGcdwPyI1jxpS*tb$H(^nUfB`HhYMy7vnhdcgw_@>U%7k J|7*#!0sxK=Enfft diff --git a/vs2019/stackman/stackman.vcxproj b/vs2019/stackman/stackman.vcxproj index 2624386..ce9a6bf 100644 --- a/vs2019/stackman/stackman.vcxproj +++ b/vs2019/stackman/stackman.vcxproj @@ -68,6 +68,9 @@ true + + /Brepro %(AdditionalOptions) + @@ -84,6 +87,9 @@ true + + /Brepro %(AdditionalOptions) + From ed59c3b1adac26201c55ab36590689c026b04013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Wed, 2 Dec 2020 21:03:20 +0000 Subject: [PATCH 011/115] Initial windows-arm (32T) support. Untested. --- lib/win_arm/stackman.lib | Bin 0 -> 3002 bytes src/platforms/platform.h | 4 ++ src/platforms/switch_arm_msvc.asm | 69 +++++++++++++++++++++++ src/platforms/switch_arm_msvc.h | 8 +++ vs2019/stackman.sln | 5 ++ vs2019/stackman/stackman.vcxproj | 47 +++++++++++++++ vs2019/stackman/stackman.vcxproj.filters | 8 +++ vs2019/test/test.vcxproj | 31 ++++++++++ 8 files changed, 172 insertions(+) create mode 100644 lib/win_arm/stackman.lib create mode 100644 src/platforms/switch_arm_msvc.asm create mode 100644 src/platforms/switch_arm_msvc.h diff --git a/lib/win_arm/stackman.lib b/lib/win_arm/stackman.lib new file mode 100644 index 0000000000000000000000000000000000000000..1fd6413ba3a58e068a86ae32053bcebecd95f872 GIT binary patch literal 3002 zcmcImO>7%Q6n>j^(&AF&P_+k$&=7u2H&3-Cx-i%xdp|1w=`^YKa2C;zTgi@uR;xCu7?v6>(V>|7xd^Uj+%=RQq z4)VDCzcW)!dJcx*ssoUvnq#|m#Umq&hY4CCSrsKD;kvrHYUro}Q<`noL|VS;@ZA0T z06a`pbk!3jDT2K%iCCeA-ZBmUpiY(Vjo5WGrDmvJ#db{h0Zgc_*&YqR=FbS15qOTR zSdhBcieZ}P*lImU2T_zlW_Fk!z$?wKFNtBRR7&X;wQhI?UGu1I?Xn@lqp=`Bcf)7& zSPW6hh~YB?ZzDc`7yw{fo{?B~(DAyTI*?Fyz1h?C2}e*bh|f>3`=>4yR-J;#bX%|J zcS-#KmskS2sHvx|opa;3Iod?9{0id=5C(~XkEUki#Hma%lb)U!&K8!Ei^bG%P@2!A za*6CrVVH!_0K@J($j2WayWMBO1cDYwAAJva(+C1SlNkWiMn;wAO){p zrnb`DoEVK+x2ShPSxPEJ+csQ&+dKZ&7d5zdw{c=8u17r={M^>ctI+tPJzmg=aQaOmoXjSPVA+OUwTZAC zLtYVxP^N0t!sw{xPH47KH!UK#WrGO$GV%q~NR?7E)2C)x1@XZOJVQ#$>0DwVU0O&i z7SqLaK8H$$`C@*dR7lO25=)76CNZ6vIUZ&Dr*i3JJ~e~YPHomi%QJH>`(S*F#UyHG zQ|NQHK!i$dqK2D>x;hbRx?@t;rRzG5IIT@=Xltrd@|tx#XbPHLLoMu}mO(AdYaiEI zcQl3Oia2T2QjH52*?1XSy5rc6qt|T5LoWy?w3Qylv+Sv?KD9KXUe<@7rVrIK%!;P? zuHbItulCwM5wD5*d1_GAL68?ZP99=;nObFg!zJ_7bCsy1q+2P#swj!k@mPFJl$5&W zcn?d;qZu)KOt5|PJcJJ6^9MqB4)h}rATvzt!7{M3AIXJ_Xw%C*ZXVyv2DP5Re6?Dw zW2pD??R_rzS+AQ!SYdg20r*3BRbUo4mJwtgc`x$a#(S?F+?wYHZ~gq|-+R9NoICkq z`o{Oa9T;K9YLj-}2ce$#!4;l+xBWioy60N=y5tYt1KKT#&l&H@1#E$8NYF SiCuRaJL`Fl1QoEw + + Debug + ARM + Debug Win32 @@ -31,8 +35,15 @@ v142 Unicode + + StaticLibrary + true + v142 + Unicode + + @@ -43,6 +54,9 @@ + + + true @@ -53,6 +67,10 @@ true $(SolutionDir)\..\lib\win_x64\ + + true + $(SolutionDir)\..\lib\win_arm\ + Level3 @@ -91,8 +109,28 @@ /Brepro %(AdditionalOptions) + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + @@ -103,23 +141,32 @@ AssemblyCode + AssemblyCode false + false Default + Default false + false true + true true + true + true true + true + \ No newline at end of file diff --git a/vs2019/stackman/stackman.vcxproj.filters b/vs2019/stackman/stackman.vcxproj.filters index 7ebc972..fb4872b 100644 --- a/vs2019/stackman/stackman.vcxproj.filters +++ b/vs2019/stackman/stackman.vcxproj.filters @@ -33,6 +33,9 @@ Header Files + + Header Files + @@ -50,4 +53,9 @@ Source Files + + + Source Files + + \ No newline at end of file diff --git a/vs2019/test/test.vcxproj b/vs2019/test/test.vcxproj index 017cdf3..73cef91 100644 --- a/vs2019/test/test.vcxproj +++ b/vs2019/test/test.vcxproj @@ -1,6 +1,10 @@ + + Debug + ARM + Debug Win32 @@ -30,6 +34,12 @@ v142 Unicode + + Application + true + v142 + Unicode + @@ -41,6 +51,9 @@ + + + true @@ -50,6 +63,9 @@ true + + true + Level3 @@ -81,6 +97,21 @@ ..\..\lib\win_x64;%(AdditionalLibraryDirectories) + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\src + + + Console + true + stackman.lib;%(AdditionalDependencies) + ..\..\lib\win_arm;%(AdditionalLibraryDirectories) + + From aaec1be4d8feb952a50e83bf03078f370a0a9355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 3 Dec 2020 10:13:55 +0000 Subject: [PATCH 012/115] Initial aarch64_msvc support, untested --- lib/win_arm64/stackman.lib | Bin 0 -> 6178 bytes src/platforms/platform.h | 4 + src/platforms/switch_arm64_msvc.asm | 102 +++++++++++++++++++++++ src/platforms/switch_arm64_msvc.h | 8 ++ vs2019/stackman.sln | 5 ++ vs2019/stackman/stackman.vcxproj | 53 +++++++++++- vs2019/stackman/stackman.vcxproj.filters | 6 ++ vs2019/test/test.vcxproj | 31 +++++++ 8 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 lib/win_arm64/stackman.lib create mode 100644 src/platforms/switch_arm64_msvc.asm create mode 100644 src/platforms/switch_arm64_msvc.h diff --git a/lib/win_arm64/stackman.lib b/lib/win_arm64/stackman.lib new file mode 100644 index 0000000000000000000000000000000000000000..0ff4d9a422a1b3879c1fed9b8cb8d999b6348a1c GIT binary patch literal 6178 zcmdT|U2Gd!6+ZT)*)-j@N&2%ZS}n67uw4l|&To@Yh@Ch;Zhnc=AGNb`CSxZV>hYMF zarzU`7GB^12`WLw3o9gq*hD;ngbGv@TBM>rfPk&U!b4j6P|y<8q$~;$mhX&b>~S_F zNmoJaQLgX3XU?2+@44sP^G#knAsfofrz-2kQVKMb&fQta8ML;#oQX;z5{P`S6!MWDtzfxy z9Ui*{31@Bf>lU(^7uuSOUWkkhwKhx9)MRd2%BxGrhSu7g(9BsSs84=|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pchr4EkF9=M-SZ|5UT(5%J0Ab*6S-!8Cim1749cuoX;JfOeW)J#9c>2cg zHOLoso~2*C{JDadU8i^^kcg^PH#p1?*d~6foV=)z&qMHWJ>`}Crse$W=p5qe&ScAw z7b5~5;w?srr4;nwLtgtvJLSb}RORYytXj9xqssag2VUnvwzwG{Z)k6BE8_7o8;?K0 zg81JFOdH{G#u_EG0Ul@PJSY)D1TY@YqYAM(H8ji~L{X zXV>ZWKL*|>erDX~Zk;hC#}?x`&NGgr4+4UD!9g0qpoBmErY(3#;hStH(9Fppl;{6j zNHaFx4e;~Szy>#Kr7w?MJs9VM2U0f03r~Q{rO<@_;l$U5rE=R4edjRBMwNU!RXVpG znIH~ofC9J<@z)N2NAtI(AF;vpxa1pUOE_T1fy;Kb`}Cj$cS;_W@b@EsJKEoi=oz6D zQOWI!#b119tm<1;LnFUb=8Yw|(Wae4As#s3*z(r8JPP4zS4v(SkVhC|sQ_lo{|}w3 B2&Mo4 literal 0 HcmV?d00001 diff --git a/src/platforms/platform.h b/src/platforms/platform.h index 272a8c7..b797de9 100644 --- a/src/platforms/platform.h +++ b/src/platforms/platform.h @@ -41,6 +41,10 @@ #include "switch_arm_msvc.h" /* MS Visual Studio on ARM */ #define _STACKMAN_PLATFORM arm_msvc #define _STACKMAN_ABI win_arm +#elif defined(_M_ARM64) +#include "switch_arm64_msvc.h" /* MS Visual Studio on ARM */ +#define _STACKMAN_PLATFORM arm64_msvc +#define _STACKMAN_ABI win_aarch64 #endif diff --git a/src/platforms/switch_arm64_msvc.asm b/src/platforms/switch_arm64_msvc.asm new file mode 100644 index 0000000..96a0f32 --- /dev/null +++ b/src/platforms/switch_arm64_msvc.asm @@ -0,0 +1,102 @@ + + +; this code is adopted from the switch_aarch64_gcc.S +; which again was generated from switch_arm_gcc.h +; This code is also modelled on the hand-customized switch_arm_msvc.asm +; see https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-160 + + ;ARM64 + + EXPORT |stackman_switch| + ALIGN +|stackman_switch| PROC + ; args "callback", "context" are in x0, x1 + ; push non-volatile x18-x28 registers, in addition to fp,rl pair. + ; x29 is fp, x30 is lr. + stp x29, x30, [sp, -176]! ; store fp,lr pair, allocate stack space + mov x29, sp ; and set fp pointing to old fp on stack + ; push non-volatile registers 18-x28 and fp regs d8-d15) + ; also fpcr (fp control register) + mrs x2,fpcr + stp x2, x18, [sp, 16] + stp x19, x20, [sp, 32] + stp x21, x22, [sp, 48] + stp x23, x24, [sp, 64] + stp x25, x26, [sp, 80] + stp x27, x28, [sp, 96] + stp d8, d9, [sp, 112] + stp d10, d11, [sp, 128] + stp d12, d13, [sp, 144] + stp d14, d15, [sp, 160] + + ; args are x0=callback, x1=context + ; shuffle calling arguments into r0, r1 and r2 + ; for the call to the callback. + mov x3, x0 + mov x0, x1 ;context + mov x2, sp ;stack pointer + mov x1, #0 ;operation + mov x19, x0 ;store these a bit in nv registers + mov x18, x3 + blr x3 ;first callback + mov x2, x0 ;store new stackpointer in register, for next cb, + ; switch stack, maintaining fp offset + sub x1, sp, x0 + mov sp, x0 ;switch stack pointer + sub fp, fp, x1 + + mov x1, #1 ;operation + mov x0, x19 ;context + blr x18 ;second callback + + ; restore registers from stack + ldp x2, x18, [sp, 16] + ldp x19, x20, [sp, 32] + ldp x21, x22, [sp, 48] + ldp x23, x24, [sp, 64] + ldp x25, x26, [sp, 80] + ldp x27, x28, [sp, 96] + ldp d8, d9, [sp, 112] + ldp d10, d11, [sp, 128] + ldp d12, d13, [sp, 144] + ldp d14, d15, [sp, 160] + msr fpcr,x2 + ;return + ldp x29, x30, [sp], 176 + ret + ENDP + + EXPORT |stackman_call| + ALIGN +|stackman_call| PROC +; args "callback", "context" are in x0, x1 + ; push non-volatile x18-x28 registers, in addition to fp,rl pair. + ; x29 is fp, x30 is lr. + stp x29, x30, [sp, -32]! ; store fp,lr pair, allocate stack space + mov x29, sp ; and set fp pointing to old fp on stack + ; push non-volatile register 18 + str x18, [sp, 16] + + ; args are x0 = callback, x1 = context, x2=stack + mov x3, x0 + mov x0, x1 ;context + mov x1, x2 ;stack + ; store current sp in nv register + mov x18, sp + mov x2, sp ; new stack + + ; change stack + mov sp, x1 + mov x1, #2 ; callback opcode + blr x3 ; call callback, with context, opcode, new stack + + ; restore stack (could do: sub sp, fp #12) + mov sp, x18 + + ; return + ldr x18, [sp, 16] + ldp x29, x30, [sp], 32 + ret + ENDP + + END diff --git a/src/platforms/switch_arm64_msvc.h b/src/platforms/switch_arm64_msvc.h new file mode 100644 index 0000000..891c035 --- /dev/null +++ b/src/platforms/switch_arm64_msvc.h @@ -0,0 +1,8 @@ +/* The actual stack saving function, which just stores the stack, + * this declared in an .asm file + */ +#ifndef STACKMAN_ASSEMBLY_SRC +#define STACKMAN_ASSEMBLY_SRC switch_arm64_msvc.asm +#define STACKMAN_HAVE_CALL 1 +#define STACKMAN_STACK_ALIGN 16 +#endif diff --git a/vs2019/stackman.sln b/vs2019/stackman.sln index 17239cd..6dff39b 100644 --- a/vs2019/stackman.sln +++ b/vs2019/stackman.sln @@ -13,18 +13,23 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM.ActiveCfg = Debug|ARM {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM.Build.0 = Debug|ARM + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM64.Build.0 = Debug|ARM64 {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x64.ActiveCfg = Debug|x64 {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x64.Build.0 = Debug|x64 {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x86.ActiveCfg = Debug|Win32 {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x86.Build.0 = Debug|Win32 {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM.ActiveCfg = Debug|ARM {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM.Build.0 = Debug|ARM + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM64.Build.0 = Debug|ARM64 {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x64.ActiveCfg = Debug|x64 {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x64.Build.0 = Debug|x64 {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x86.ActiveCfg = Debug|Win32 diff --git a/vs2019/stackman/stackman.vcxproj b/vs2019/stackman/stackman.vcxproj index 528b499..a7bce7f 100644 --- a/vs2019/stackman/stackman.vcxproj +++ b/vs2019/stackman/stackman.vcxproj @@ -5,6 +5,10 @@ Debug ARM + + Debug + ARM64 + Debug Win32 @@ -41,6 +45,12 @@ v142 Unicode + + StaticLibrary + true + v142 + Unicode + @@ -57,6 +67,9 @@ + + + true @@ -71,6 +84,10 @@ true $(SolutionDir)\..\lib\win_arm\ + + true + $(SolutionDir)\..\lib\win_arm64\ + Level3 @@ -128,8 +145,28 @@ /Brepro %(AdditionalOptions) + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + @@ -142,26 +179,40 @@ AssemblyCode AssemblyCode + AssemblyCode false false + false Default Default + Default false false + false true true + false true - + + false + true + + + Document + true + true true + true true true + true diff --git a/vs2019/stackman/stackman.vcxproj.filters b/vs2019/stackman/stackman.vcxproj.filters index fb4872b..6db744f 100644 --- a/vs2019/stackman/stackman.vcxproj.filters +++ b/vs2019/stackman/stackman.vcxproj.filters @@ -36,6 +36,9 @@ Header Files + + Header Files + @@ -57,5 +60,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/vs2019/test/test.vcxproj b/vs2019/test/test.vcxproj index 73cef91..2559e40 100644 --- a/vs2019/test/test.vcxproj +++ b/vs2019/test/test.vcxproj @@ -5,6 +5,10 @@ Debug ARM + + Debug + ARM64 + Debug Win32 @@ -40,6 +44,12 @@ v142 Unicode + + Application + true + v142 + Unicode + @@ -54,6 +64,9 @@ + + + true @@ -66,6 +79,9 @@ true + + true + Level3 @@ -112,6 +128,21 @@ ..\..\lib\win_arm;%(AdditionalLibraryDirectories) + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\src + + + Console + true + stackman.lib;%(AdditionalDependencies) + ..\..\lib\win_arm64;%(AdditionalLibraryDirectories) + + From 2469fbe56ec23ad3e49fdaa675617376082be91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 3 Dec 2020 16:46:10 +0000 Subject: [PATCH 013/115] Preserve ebp in stackman_switch, win_x86. Do not compile runtime checks in c-wrapper. --- lib/win_x86/stackman.lib | Bin 12318 -> 10042 bytes src/platforms/switch_x86_msvc.asm | 13 ++++++++----- vs2019/stackman/stackman.vcxproj | 9 ++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/win_x86/stackman.lib b/lib/win_x86/stackman.lib index 60374c7f75d98e1a97f27f66fdd37214959ebeb3..9edceac9ae24a6459e83a8f1a5ff518f316ac7b2 100644 GIT binary patch delta 1256 zcmY+ENoZ4H5Xa}sYnqq$(%RToO&5JlmvphQTAMVb)mqdliUzlWYcLkI*0pJ^2kE0d zDCScA4uTX<3W5k?F6zaD#SQTwK@>fBs0TsB3WBIb|C79=bzt(FH{X2Q%zU{XdAMb~ zwJZ=aEQx4D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kax022u*`RmXRA)}>t$4nUyTSR?3wQSf z=2ffJ%k>rfrWPftEtj9$!d>T#-<(I`gAg&DyrEf5H(njYX4W_Kd?0V=B|rx-44ey$ z07BRhU$`+lU3F%Uu8D> z3QuNs`qpGJsZ!22U^1Eh#$MySXD16z4KtbMfK})|r^#drf*Ds&#AGt<1T(Ill*wdz zHVeuZgq@C>Or}vVzM<{(w#j5V2Zoy*z6&Ok$%31J?;bmqnM|feFq}U47MM(?m0*0Q z*lDfFFc>gC#;fd1HK8ssX0<@fGryFtw5r4!YE_n-0^^4$Es;SbdEz>oJr8N9R4U+vjZi`ohuX7vS zZ!$YQWHMe>!*EexW;t_kZRE4MYxe2ClNH$%nJw;Ew8igOv}$cwJ2!WC>3ti*&02?Z zxAfD_$fzG9NZWRG32bK}nntn7R9po(8}Q zHTp26+~(VK`A*D+XIz+J^?^&AV~rkpa#o%{o0B63D}X*UZn1a2Mu!J>1v%>ZJLVu_R_ZIGDzg zSR{vbv2k`*Uk#}+0~?*6$LC^lsuW_1>?p*4B}5^R1Fx3?vqDTxd+<%nbV6Jwxfyv& zh$+(EgjEV=wXUHCB*ep)A0B6v;Xtk2qDb>RLcK%BXGYMzo|Mheb8`q hWwJ+YM*=mg>l6KIS87jk!rSpZV|-MTla22R`CpLkVVD2_ diff --git a/src/platforms/switch_x86_msvc.asm b/src/platforms/switch_x86_msvc.asm index c23b861..ce5a42b 100644 --- a/src/platforms/switch_x86_msvc.asm +++ b/src/platforms/switch_x86_msvc.asm @@ -5,13 +5,12 @@ .code stackman_switch_raw PROC callback:DWORD, context:DWORD - + ;Assembler has already pushed the basepointer and saved it. ;save registers. EAX ECX and EDX are available for function use and thus ;do not have to be stored. push ebx push esi push edi - push ebp mov esi, callback ; /* save 'callback' for later */ mov edi, context ; /* save 'context' for later */ @@ -22,8 +21,13 @@ stackman_switch_raw PROC callback:DWORD, context:DWORD push 0; /* arg 2: opcode STACKMAN_OP_SAVE */ push edi ; /* arg 1: context */ call esi ; /* call callback() */ - - mov esp, eax; /* change the stack pointer */ + add esp, 12; + + mov ecx, eax; /* change stack pointer to eax, preserving */ + sub ecx, esp; /* base pointer offset from esp */ + mov esp, eax; + add ebp, ecx; + push eax ; /* arg 3: current (new) stack pointer */ push 1; /* arg 2: opcode STACKMAN_OP_RESTORE */ @@ -31,7 +35,6 @@ stackman_switch_raw PROC callback:DWORD, context:DWORD call esi ; /* call callback() */ add esp, 12 - pop ebp pop edi pop esi pop ebx diff --git a/vs2019/stackman/stackman.vcxproj b/vs2019/stackman/stackman.vcxproj index a7bce7f..1d48cb8 100644 --- a/vs2019/stackman/stackman.vcxproj +++ b/vs2019/stackman/stackman.vcxproj @@ -175,7 +175,10 @@ - + + false + Default + AssemblyCode AssemblyCode @@ -199,10 +202,14 @@ false true + true + true Document true + true + true true From 1a1207410bacd55273d74cef9cfe7a99d095b9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 3 Dec 2020 17:26:13 +0000 Subject: [PATCH 014/115] readjust base pointer after stack switch, x64_msvc --- lib/win_x64/stackman.lib | Bin 5048 -> 5082 bytes src/platforms/switch_x64_msvc.asm | 4 ++++ 2 files changed, 4 insertions(+) diff --git a/lib/win_x64/stackman.lib b/lib/win_x64/stackman.lib index 8d53b0413854ff1024a6a887af6d502f81e6720f..6422336802506c79b8f5d113e7c0248ee403e6df 100644 GIT binary patch delta 640 zcmXZaTSyd99LMqhncb<~oi(<0S*Vm1HdtaG7PjaDA}mQw&_(iAR=P$HMbL{a6j58I z5=j?17)1}7Au2xUpjZ$2WUyVx#D^|M(Oa|-N`#=GUza_@%;)$2&tYcH%uL3<#vYCN z_xME&5m9X2)sgP+{h__PlI4Yw_MPwa$j)uK=C@j_OKL^0s<@e9dYeudQPrnwjF_3H zUeZ}3;w?2r!Y+}d9^~v}{myU#cGrArbko3g_+m!sqMPTtjt~zxy1v?MO1hhxv;dN2d|)o8Qg?daWh`SFy6qecoWMoixF(Y zDBi&x*p7?%dHp8Eu_EFt#C;s!Yiq-gY$elfQ>Cy258z#_!Y(|B5AYE7pp8%PFh0X0 z*o#N850Bw+DSU&C_yJGj9G<~%cou(Q z6aL0#{EKP)hb_2_=WqePC>EttB}pAsLC5V$C~uy2J$qhPcsqCZxJ80gmOL#cpG=ds o6neR0;{EZpLWQ2&)c?J&_-{si4^^p?vVzL>GMsZ7{4E>T0Fls$lK=n! delta 597 zcmXZaOGs2v9LMqhxii;s?hIi%i6SzJ!Yo`wV4@qzG|)01XqwLybd!P)6ntPa3c0F$ z98e1paZxQ2(h-qB5Ro=+B5Yw0NdqD%A`Q4yzcb9am;3qs|Mzh2z1;KLx8<8&cYE9- zhKMMRnJVwhpA}DDL4HPbv{@aK@iNi-{l#akRhJ6uYn5YmGkr+kHL}#4t}%S(Kk9Ss zH@r@}DdM(?B~W^!alr(19%$;F&T$36-O`~N70L~Fbn;djRDU8xD$Cu zY=lLuXuQvLL*I$}>wmzs395(q8jJA_mf#dV!dWcEIV{6@e2feD1m9yhe!vP`#7bPk zDqO~DT)`Urg0;9AS>_pGn?@b(VLk5SbNq=7c!-U7giUyi&3K9}82QfD;4eo&IYUI2 zl8|n7PUeo;MUtpoG9F8otdbI=y|q}fpj_Rj1&#rnn$NOPs@3#;FZ{A){(C#C9u N>(a&^2@bp49XI`3eW?Hd diff --git a/src/platforms/switch_x64_msvc.asm b/src/platforms/switch_x64_msvc.asm index 6e9bfe0..f4bd70f 100644 --- a/src/platforms/switch_x64_msvc.asm +++ b/src/platforms/switch_x64_msvc.asm @@ -58,10 +58,14 @@ NESTED_ENTRY stackman_switch, _TEXT$00 mov rcx, r13 ;arg1, context mov rdx, 0 ;arg2, opcode STACKMAN_OP_SAVE lea r8, [rsp+20h] ;arg3, stack pointer + mov rbx, rsp; ; keep old stack pointer call r12 ; ;actual stack switch (and re-allocating the shadow stack): lea rsp, [rax-20h] + ;re-adjust base pointer + sub rbx, rsp; + sub rbp, rbx; mov rcx, r13 ;arg1, context mov rdx, 1 ;arg2, opcode STACKMAN_OP_RESTORE From fdeed8ef2044cc141f3a06fa1f50fe7e022cbe2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 3 Dec 2020 22:41:39 +0000 Subject: [PATCH 015/115] update test source code generation --- src/platforms/test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/platforms/test.c b/src/platforms/test.c index 753157e..a4f8fb1 100644 --- a/src/platforms/test.c +++ b/src/platforms/test.c @@ -1,11 +1,16 @@ /* function to test the generation * of assembly code under e.g. Gcc. * use by calling, for example: - * cc -DSTACKMAN_SWITCH_IMPL -S -m32 -fcf-protection=none test.c - * and examinine the generated test.s assembly code. The fcf-protection + * cc -S -m32 -fcf-protection=none test.c + * and examinine the generated test.s assembly code. + * -m32 selects 32 bit mode, use other directives to select a different platform. + * The -fcf-protection * flag disables generation of intel CET compatible code, but stack switching * is not compatible with the proposed shadow stack. */ #define STACKMAN_VERBOSE +#define STACKMAN_SWITCH_IMPL +#define STACKMAN_INLINE_ASM 1 +#define STACKMAN_BUILD_LIB /* so that we don´t generate indirection shims */ #include "platform.h" From aa5be0decc1d2b94d4a28c393bd7cefb7200ff1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 3 Dec 2020 23:32:55 +0000 Subject: [PATCH 016/115] adjust base pointer for sysv_amd64. submit lib --- lib/sysv_amd64/libstackman.a | Bin 0 -> 3758 bytes src/platforms/switch_x86_64_gcc.S | 37 ++++++++++++++++++------------ src/platforms/switch_x86_64_gcc.h | 10 +++++--- 3 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 lib/sysv_amd64/libstackman.a diff --git a/lib/sysv_amd64/libstackman.a b/lib/sysv_amd64/libstackman.a new file mode 100644 index 0000000000000000000000000000000000000000..765c9d70d800441405819210a2dba658e5720296 GIT binary patch literal 3758 zcmcIm&2Jk;6rc6x!#K$%r67U=(nbo9BD}VP6Cy++Z`{yLsZaz7All%rosDg3udCg4 z2?({3A}Xx}wBm%sg}okYu2t*jU>kh#x zvUQ7?QdR~{Han{_o>z-MJ z*>i%q!a2{{^@z4@dM43|u1hq>s+rohRcw|ERePraI?9{HqGMfZQ=5)ymo0D!ENWHT z;ygqrTB%X5ThRKN4ehJJ4*=R1j*e(y_r_0w8}?*$%`s9Ahc1M+QJMw;F|iYKQKJYi z`ac0W+>d+p&w#HO6Vv5z0D3Bz!cnwEJ)U#9&>~S`g$Sd}wz|!7j~S|LhRcke zMdJG5*(3HY2Ktl*<>wb-NMe3G$GZ8y#=vXTt2K!J{1`2`!7HKP8zD2FKJptujTD%p zrR3m5PZ0f8{S|#v-`ITF*#B+P@c%UYyPw>7cP24@X5E1?hl_-)?=rYMF4bV77V};99EP##@I%GAbJkz z%EZ-Jer#xUUoJwfK+`$mvi$#Vgtl8PETZ=t0Z*BB!VkDV($RFS0K+o}aW2zuM_12s zJ$PfadbZoEmkBUU%!i^~Zg~{JqZherNMM^AD9`F{r<3GV>(75#hN4HsGdes6 #include "../stackman_switch.h" /* @@ -48,7 +49,8 @@ __attribute__((optimize(OPTIMIZE))) STACKMAN_LINKAGE_SWITCH_INASM void *STACKMAN_SWITCH_INASM_NAME(stackman_cb_t callback, void *context) { - void *stack_pointer; + void *stack_pointer, *stack_pointer2; + ptrdiff_t diff; /* assembly to save non-volatile registers, including x87 and mmx */ int mxcsr; short x87cw; __asm__ volatile ( @@ -58,10 +60,12 @@ void *STACKMAN_SWITCH_INASM_NAME(stackman_cb_t callback, void *context) /* sp = get stack pointer from assembly code */ __asm__ ("movq %%rsp, %[result]" : [result] "=r" (stack_pointer)); - stack_pointer = callback(context, STACKMAN_OP_SAVE, stack_pointer); + stack_pointer2 = callback(context, STACKMAN_OP_SAVE, stack_pointer); + diff = stack_pointer2 - stack_pointer; /* set stack pointer from sp using assembly */ - __asm__ ("movq %[result], %%rsp" :: [result] "r" (stack_pointer)); + __asm__ ("movq %[result], %%rsp" :: [result] "r" (stack_pointer2)); + __asm__ ("addq %[arg], %%rbp" :: [arg] "r" (diff)); stack_pointer = callback(context, STACKMAN_OP_RESTORE, stack_pointer); /* restore non-volatile registers from stack */ From f7b7f3efcc65997f1c467b41129236f2d84012f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 3 Dec 2020 23:33:49 +0000 Subject: [PATCH 017/115] allow redefinition of macro when testing. --- tests/test_asm.c | 1 + tests/test_static.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/test_asm.c b/tests/test_asm.c index 03533bf..72f1866 100644 --- a/tests/test_asm.c +++ b/tests/test_asm.c @@ -1,5 +1,6 @@ /* testing of inline asm functionality */ +#undef STACKMAN_INLINE_ASM #define STACKMAN_INLINE_ASM 1 #include "stackman.h" #include "stackman_impl.h" diff --git a/tests/test_static.c b/tests/test_static.c index eaa3806..69ad40e 100644 --- a/tests/test_static.c +++ b/tests/test_static.c @@ -2,6 +2,7 @@ * rather than linking in an object file. Only possible if the * implementation is inline asm. Real assembler must be linked */ +#undef STACKMAN_INLINE_ASM #define STACKMAN_INLINE_ASM 1 #define STACKMAN_LINKAGE_STATIC #include "stackman.h" From f80c7448e44d572e1cc83eb12be6bdb240280895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Fri, 4 Dec 2020 09:04:50 +0000 Subject: [PATCH 018/115] =?UTF-8?q?Update=20x86=5Fgcc.=20send=2016=20bit?= =?UTF-8?q?=20aligned=20stack=20to=20callbacks.=20Don=C2=B4t=20include=20c?= =?UTF-8?q?allback=20arguments=20in=20callback=20stack.=20Update=20base=20?= =?UTF-8?q?pointe=20when=20switching=20stack.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/sysv_i386/libstackman.a | Bin 0 -> 2674 bytes src/platforms/switch_x86_gcc.S | 24 ++++++++++++++---------- src/platforms/switch_x86_gcc.h | 26 ++++++++++++++++++-------- 3 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 lib/sysv_i386/libstackman.a diff --git a/lib/sysv_i386/libstackman.a b/lib/sysv_i386/libstackman.a new file mode 100644 index 0000000000000000000000000000000000000000..a13b31a2c3fe7563bd464dc747507a44fd2ca084 GIT binary patch literal 2674 zcmbtV&2Jk;6o2d86q7h6rA2@O(nfN@MR;u|ZYU_NFit2%RTU8#kWg^en~m+(URS$o z3W$$GMCmHx$QAK-0EbFRTX9El;edp=<-(at;rC{C>`j^|MLhY<`})m$GdnZSGYhuw zv@ebq&HYqLm{L!UrdgR)fVFWVN)er~n1j%EuJ>%O5!~#APMe0dV|Tkl%j(N|M^%}x zR7Co6r5x8;8~<|Y%A1;|p_n9%bQ)PihA#aTA@VduPf#AZA#6jNgv_jB=n4ncY&^!A zZj5!jkVreJoyne>(6iIosizUm(Zs|>m_Wp88tBttY!)Q*3Khe%;1r$0sA>OXCozhp zVuAP#yr9$a+;x)+UAkH~Yvr=}ignH^nT6imEQWC4xffcl=lUH7CZEZL&iwg#v(PdN z8_Sn#7{#Y7-0=IM>x6y35QKi;Yf<1kMfH^}hl=ff&n;f}J3)BO_KK}eIE)fqs?}aI z^Y!My3kPxmg}H&S%3qYvTcyfb=~cT*%6;FO{@zQ*_MZg4Sp1C?Mu#U!`hl;f(}`pl zXmK<{pH7btbyjrZOE)5&G9v?;P7^e`Y>vpTp#-Beq&gYPr((&cr{Q?b*yhz}V;HR9 zlU`^yAwyrvw$eiPV+qKr+=AhN+cpH6$gl;#RzWY%!YWud=axp;y zx*g9|I&zcc^m{!Q7sc{$(iW}@P8yF2t9fLa29nQ9eO37;M$^?<&crx%I!EDN1deb2 zakx^P4?+;}}Y|x?R-eI$W1;oT|%hLd}6n-+`ZJB_k zB?%Fu!hIg&RH(;+1SylH>_Rel1CBdT(X7NB=Y33pd9Uispi&8wk}pN&|b8)FNO2Gg83}}Qy)F5|A_|cwi_G1-E)!i z5$UjAXeZ`kSAu3Rvaa62x6(Zv74Bd!JPOA>j_0U1&$u(gY%<32b6}O5!$0tlAQig| zAM5cmp`W0)6F7B!mf%bFxLr)*UXTX!{{iDzPv(M2IXJ$D Date: Fri, 4 Dec 2020 21:05:32 +0000 Subject: [PATCH 019/115] sysv_386: make stack aligned in stackman_call Incoming stack pointer must be adjusted to make this happen. Also adjust old stack pointer to make it correspond to incoming stack pointer. --- lib/sysv_i386/libstackman.a | Bin 2674 -> 2690 bytes src/platforms/switch_x86_gcc.S | 11 +++++++---- src/platforms/switch_x86_gcc.h | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/sysv_i386/libstackman.a b/lib/sysv_i386/libstackman.a index a13b31a2c3fe7563bd464dc747507a44fd2ca084..e91aa0c5fdfcd7818ec2bb89e829c997310e93f7 100644 GIT binary patch delta 251 zcmew)(j>YefsM(;V&WnV#)Qe;Y>L)WoyR(__r|CQbjGM~9CuM+VE}?o8jIQ>fygn!pMzPQ0wn?aXZ~&8$o= zhaHbO9(O#-!@{Bfl=c8(zsbeyi+Mq+g%}taB)}rd9G4mMCckD@W?VFxpG6%^icgN> z6kuHhl-HV^&#BCK1}Gywc@?JskhPmro$=4)$3W6#GB=kx(-p?a8(739dvOU!@Gvnj N1Oqj}0LaB4004kp delta 242 zcmZn?{Uov>fsN64;zCWvfXUr#iV{4X$2zZfrl@cncTr(s0D?{%mH*c|k4(PECd$Y& z`8k`hgr%Obo`J5RL1|KHUP-BurUF=ifnl;KyQ-!mNRJ~QM=O&PFRODqa~n%DYx!Zv zV~)oikMgjvFem_}JwQq(H?uG11*sNdU}TU0ix_iUW=x#?npv4~>STTvbucMDIg3+( zbt+I^b#gtYGUG0wjQHeToC1t{CZFb1XM8jHGmuo7EX}3PbcAv81{Sf&QCtENe;64U Mf`OV~0LTRc03Z80zW@LL diff --git a/src/platforms/switch_x86_gcc.S b/src/platforms/switch_x86_gcc.S index d244493..ca3ef00 100644 --- a/src/platforms/switch_x86_gcc.S +++ b/src/platforms/switch_x86_gcc.S @@ -82,22 +82,25 @@ stackman_call: # 108 "switch_x86_gcc.h" 1 movl %esp, %ebx # 0 "" 2 -# 109 "switch_x86_gcc.h" 1 - movl %esp, %eax +# 110 "switch_x86_gcc.h" 1 + leal 4(%esp), %eax # 0 "" 2 #NO_APP movl 16(%ebp), %edx #APP -# 112 "switch_x86_gcc.h" 1 +# 113 "switch_x86_gcc.h" 1 movl %edx, %esp # 0 "" 2 +# 115 "switch_x86_gcc.h" 1 + subl $4, %esp +# 0 "" 2 #NO_APP pushl %eax pushl $2 pushl 12(%ebp) call *8(%ebp) #APP -# 116 "switch_x86_gcc.h" 1 +# 119 "switch_x86_gcc.h" 1 movl %ebx, %esp # 0 "" 2 #NO_APP diff --git a/src/platforms/switch_x86_gcc.h b/src/platforms/switch_x86_gcc.h index 1f8e43e..b5989c6 100644 --- a/src/platforms/switch_x86_gcc.h +++ b/src/platforms/switch_x86_gcc.h @@ -106,10 +106,13 @@ void *stackman_call(stackman_cb_t callback, void *context, void *stack_pointer) /* sp = store stack pointer in ebx */ __asm__ ("movl %%esp, %%ebx" : : : "ebx"); - __asm__ ("movl %%esp, %[sp]" : [sp] "=r" (old_sp)); + /* save old stack pointer at same offset as new stack pointer */ + __asm__ ("leal 4(%%esp), %[sp]" : [sp] "=r" (old_sp)); /* set stack pointer from provided using assembly */ __asm__ ("movl %[sp], %%esp" :: [sp] "r" (stack_pointer)); + /* subtract 4 bytes to make it 16 byte alighed after pushing 3 args */ + __asm__ ("subl $4, %esp"); result = callback(context, STACKMAN_OP_CALL, old_sp); /* restore stack pointer */ From 42fbc4661578983edea1c3c743a84ba6a9eb4d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 10:05:36 +0000 Subject: [PATCH 020/115] rename test.c to gen_asm.c --- .gitignore | 1 + README.md | 3 ++- lib/sysv_i386/libstackman.a | Bin 2690 -> 2698 bytes src/platforms/{test.c => gen_asm.c} | 10 ++++------ src/platforms/switch_aarch64_gcc.S | 6 +++--- src/platforms/switch_aarch64_gcc.h | 6 +++--- src/platforms/switch_arm_gcc.S | 6 +++--- src/platforms/switch_arm_gcc.h | 8 ++++---- src/platforms/switch_x86_64_gcc.S | 6 +++--- src/platforms/switch_x86_gcc.S | 6 +++--- 10 files changed, 26 insertions(+), 26 deletions(-) rename src/platforms/{test.c => gen_asm.c} (58%) diff --git a/.gitignore b/.gitignore index 966beb3..446be5a 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ dkms.conf # custom bin/ +gen_asm.s # Visual Studio noise # Visual Studio 2015/2017 cache/options directory diff --git a/README.md b/README.md index c854640..e8dbbd6 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,8 @@ behaviour on the C-stack level, could make use of simple, stable code, that can platforms as they come along. ## Cross-compilation -Linux on x86-64 can be used to cross compile for x86 and ARM targets. This is most useful to generate assembly code, e.g. when compiling src/platform/test.c +Linux on x86-64 can be used to cross compile for x86 and ARM targets. This is most useful to generate assembly code, e.g. when compiling +src/platform/gen_asm.c - x86 requires the -m32 flag to compilers and linkers. - arm32 requires to use the arm-linux-gnueabi-* tools, including cc and linker - aarch64 requires the aarch64-linux-gnu-* tools. diff --git a/lib/sysv_i386/libstackman.a b/lib/sysv_i386/libstackman.a index e91aa0c5fdfcd7818ec2bb89e829c997310e93f7..1a55eccb6593691a3d8a52cbf67af621af783567 100644 GIT binary patch delta 164 zcmZn??GoLPz{X^1HgS;#W5(oewk)1r7ZsN7P=U@X&2LyH|6#LYVqlnT${r}F$^Zn8 zd>pMzPQ0ux&CIcrr?byzRGn3zi_HC+Dw+_QfIouIC%q$*yJcK0SOVHMZq9Dpnwrd0|3g7C(Qr= delta 180 zcmeAYZ4%v(z{X@^F>#RwW5VQawk-C}2i>6pomVC^vRh5IV-FBiU;qL~K8{uh1d;%PGm|fKsx$pzocxDVjnQPXGM75j6~@UMSi~l?u?a}<0F?zp6oN^RP7nY9 DA#x+g diff --git a/src/platforms/test.c b/src/platforms/gen_asm.c similarity index 58% rename from src/platforms/test.c rename to src/platforms/gen_asm.c index a4f8fb1..9858b27 100644 --- a/src/platforms/test.c +++ b/src/platforms/gen_asm.c @@ -1,16 +1,14 @@ /* function to test the generation * of assembly code under e.g. Gcc. * use by calling, for example: - * cc -S -m32 -fcf-protection=none test.c + * cc -S -m32 -fcf-protection=none gen_asm.c * and examinine the generated test.s assembly code. * -m32 selects 32 bit mode, use other directives to select a different platform. - * The -fcf-protection - * flag disables generation of intel CET compatible code, but stack switching - * is not compatible with the proposed shadow stack. + * The -fcf-protection flag disables generation of intel CET compatible code, but stack switching + * is not compatible with the proposed shadow stack. Only the latest compilers have it. */ #define STACKMAN_VERBOSE -#define STACKMAN_SWITCH_IMPL #define STACKMAN_INLINE_ASM 1 #define STACKMAN_BUILD_LIB /* so that we don´t generate indirection shims */ -#include "platform.h" +#include "../stackman_impl.h" diff --git a/src/platforms/switch_aarch64_gcc.S b/src/platforms/switch_aarch64_gcc.S index 70fba4b..642ec58 100644 --- a/src/platforms/switch_aarch64_gcc.S +++ b/src/platforms/switch_aarch64_gcc.S @@ -5,12 +5,12 @@ * implementation that is independent of subtleties of inline * assembly code which may change with compiler versions. * The file is generated using - * "aarch64-linux-gnu-gcc -DSTACKMAN_SWITCH_IMPL -S test.c" - * and then copying the code from test.s into this file. + * "aarch64-linux-gnu-gcc -S gen_asm.c" + * and then copying the code from gen_asm.s into this file. * */ .arch armv8-a - .file "test.c" + .file "gen_asm.c" .text .align 2 .global stackman_switch diff --git a/src/platforms/switch_aarch64_gcc.h b/src/platforms/switch_aarch64_gcc.h index 2ace4bd..8bd3aa9 100644 --- a/src/platforms/switch_aarch64_gcc.h +++ b/src/platforms/switch_aarch64_gcc.h @@ -23,9 +23,9 @@ #if !__ASSEMBLER__ && !defined(STACKMAN_ASSEMBLY_SRC) /* - * To test this, #include this file in a file, test.c and - * gcc -S -DSTACKMAN_SWITCH_IMPL test.c - * then examine test.s for the result. + * To test this, compile with appropriate cross platform flags, e.g. + * "arm-linux-gnueabi-gcc -S gen_asm.c" + * then examine gen_asm.s for the result. * We instruct optimizer to not omit frame pointers, -fno-omit_frame_pointer * and not use local stack vars, -O1. * option is applied with an __attribute__. diff --git a/src/platforms/switch_arm_gcc.S b/src/platforms/switch_arm_gcc.S index b48923d..a10b063 100644 --- a/src/platforms/switch_arm_gcc.S +++ b/src/platforms/switch_arm_gcc.S @@ -3,8 +3,8 @@ * dependable, such as with clang on linux x86_64 or if * STACKMAN_INLINE_ASM is false * The file is generated using - * "arm-linux-gnueabi-gcc -DSTACKMAN_SWITCH_IMPL -S test.c" and then copying the code - * from test.s into this file. + * "arm-linux-gnueabi-gcc -S gen_asm.c" and then copying the code + * from gen_asm.s into this file. * */ .arch armv5t @@ -17,7 +17,7 @@ .eabi_attribute 30, 6 .eabi_attribute 34, 0 .eabi_attribute 18, 4 - .file "test.c" + .file "gen_asm.c" .text .align 2 .global stackman_switch diff --git a/src/platforms/switch_arm_gcc.h b/src/platforms/switch_arm_gcc.h index de8254c..1dafafb 100644 --- a/src/platforms/switch_arm_gcc.h +++ b/src/platforms/switch_arm_gcc.h @@ -29,10 +29,10 @@ * stack pointer on function exit, thereby invalidating our changes * to the stack pointer. * To arrive at reasonable assembler, follow some approach similar to: - * cp switch_arm_gcc.h test.c - * gcc -S -O -DSTACKMAN_SWITCH_IMPL test.c - * mv test.s switch_arm_gcc.s - * assembly code which can then be modified for actual use. Simple optimized + * "gcc -S gen_asm.c" + * to generate gen_asm.s which can then be + * modified for actual use. + * Simple optimized * version is better than no-optimized because the latter uses stack * variables for arguments. And it turns out that this version actually * runs because it does not use fp for restoring the stack pointer diff --git a/src/platforms/switch_x86_64_gcc.S b/src/platforms/switch_x86_64_gcc.S index fc146ef..413cce7 100644 --- a/src/platforms/switch_x86_64_gcc.S +++ b/src/platforms/switch_x86_64_gcc.S @@ -5,11 +5,11 @@ * implementation that is independent of subtleties of inline * assembly code which may change with compiler versions. * The file is generated using - * "gcc -DSTACKMAN_SWITCH_IMPL -S -fcf-protection=none test.c" - * and then copying the code from test.s into this file. + * "gcc -S -fcf-protection=none gen_asm.c" + * and then copying the code from gen_asm.s into this file. * */ - .file "test.c" + .file "gen_asm.c" .text .globl stackman_switch .type stackman_switch, @function diff --git a/src/platforms/switch_x86_gcc.S b/src/platforms/switch_x86_gcc.S index ca3ef00..c5b5862 100644 --- a/src/platforms/switch_x86_gcc.S +++ b/src/platforms/switch_x86_gcc.S @@ -5,11 +5,11 @@ * implementation that is independent of subtleties of inline * assembly code which may change with compiler versions. * The file is generated using - * "gcc -DSTACKMAN_SWITCH_IMPL -S -m32 -fcf-protection=none test.c" - * and then copying the code from test.s into this file. + * "gcc -S -m32 -fcf-protection=none gen_asm.c" + * and then copying the code from gen_asm.s into this file. * */ - .file "test.c" + .file "gen_asm.c" .text .globl stackman_switch .type stackman_switch, @function From d66de648f88596f5c08dfcee8a1a36855527f3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 10:44:54 +0000 Subject: [PATCH 021/115] Fix stack alignment for sysv_386 --- lib/sysv_i386/libstackman.a | Bin 2698 -> 2702 bytes src/platforms/switch_x86_gcc.S | 16 ++++++++-------- src/platforms/switch_x86_gcc.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/sysv_i386/libstackman.a b/lib/sysv_i386/libstackman.a index 1a55eccb6593691a3d8a52cbf67af621af783567..e89bb6d03a1c61182cfd80aa84c856d99a480b53 100644 GIT binary patch delta 121 zcmeAY?GxRQz{X@|FmaIvW6tDmHbq96$!pmx8D%y Date: Sat, 5 Dec 2020 10:45:23 +0000 Subject: [PATCH 022/115] Assert stack alignment in test callbacks. --- tests/test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test.c b/tests/test.c index 55eba16..a3efd23 100644 --- a/tests/test.c +++ b/tests/test.c @@ -7,6 +7,8 @@ #include +#define assert_align(p) assert((intptr_t)(p) == STACKMAN_SP_ALIGN(p)) + /* simple test ithout modifying stack pointers. * test that the callback is called wiht valid * stackpoiners and the stage member in the @@ -83,6 +85,7 @@ void restore_stack(void *sp, void *buf, size_t size) void *jmp_cb(void* context, int opcode, void *sp) { + assert_align(sp); jmp *c = (jmp*)context; c->log[c->counter++] = c->val; if (c->val == 0) { @@ -191,6 +194,7 @@ void test_03(void *stack_marker) void *test_04_cb(void* context, int _opcode, void *old_sp) { + assert_align(old_sp); ctxt01 *c = (ctxt01*)context; stackman_op_t opcode = (stackman_op_t)_opcode; assert(opcode == STACKMAN_OP_CALL || opcode == 100); From 4cf72d517f7995f1e6c1313dc9f4e60cb322763e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 10:50:37 +0000 Subject: [PATCH 023/115] rebuils sysv_x86_64 --- lib/sysv_amd64/libstackman.a | Bin 3758 -> 3766 bytes src/platforms/switch_x86_64_gcc.S | 18 +++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/sysv_amd64/libstackman.a b/lib/sysv_amd64/libstackman.a index 765c9d70d800441405819210a2dba658e5720296..6d668b6f96772901441cc24e4d79ec1fc2786a29 100644 GIT binary patch delta 102 zcmZ1{yG?e(5e_CpqshlO3>Y;wf9DWqV&tC8&n>Pj&A`AQ#K6dq45UFo2SPD0q^IV^ sCl=@GB{NJ6kYfRfZcgS-W@210`8aPoqvm9PK6B0sOc2!}ll^(*0b0%!#Q*>R delta 86 zcmdlcyH0k)5e`O!i3<%G6*hn85NBfKn9R>Dt{}m{z#zoH$dC-AK|lvWF));*7MJKH jGfWJS+nmFl#Kbsb@_F9&$wq7nlgs!d7*9;@=Tip&Jt7n7 diff --git a/src/platforms/switch_x86_64_gcc.S b/src/platforms/switch_x86_64_gcc.S index 413cce7..02304df 100644 --- a/src/platforms/switch_x86_64_gcc.S +++ b/src/platforms/switch_x86_64_gcc.S @@ -39,12 +39,12 @@ stackman_switch: movq %rdi, %rax movq %rsi, %rcx #APP -# 56 "switch_x86_64_gcc.h" 1 +# 56 "../platforms/switch_x86_64_gcc.h" 1 fstcw 10(%rsp) stmxcsr 12(%rsp) # 0 "" 2 -# 62 "switch_x86_64_gcc.h" 1 +# 62 "../platforms/switch_x86_64_gcc.h" 1 movq %rsp, %rbx # 0 "" 2 #NO_APP @@ -55,13 +55,13 @@ stackman_switch: movq %rax, %r14 call *%rax #APP -# 67 "switch_x86_64_gcc.h" 1 +# 67 "../platforms/switch_x86_64_gcc.h" 1 movq %rax, %rsp # 0 "" 2 #NO_APP subq %rbx, %rax #APP -# 68 "switch_x86_64_gcc.h" 1 +# 68 "../platforms/switch_x86_64_gcc.h" 1 addq %rax, %rbp # 0 "" 2 #NO_APP @@ -70,7 +70,7 @@ stackman_switch: movq %r15, %rdi call *%r14 #APP -# 72 "switch_x86_64_gcc.h" 1 +# 72 "../platforms/switch_x86_64_gcc.h" 1 ldmxcsr 12(%rsp) fldcw 10(%rsp) @@ -110,13 +110,13 @@ stackman_call: movq %rdi, %rax movq %rsi, %rdi #APP -# 92 "switch_x86_64_gcc.h" 1 +# 92 "../platforms/switch_x86_64_gcc.h" 1 movq %rsp, %rbx # 0 "" 2 -# 93 "switch_x86_64_gcc.h" 1 +# 93 "../platforms/switch_x86_64_gcc.h" 1 movq %rsp, %rcx # 0 "" 2 -# 96 "switch_x86_64_gcc.h" 1 +# 96 "../platforms/switch_x86_64_gcc.h" 1 movq %rdx, %rsp # 0 "" 2 #NO_APP @@ -124,7 +124,7 @@ stackman_call: movl $2, %esi call *%rax #APP -# 100 "switch_x86_64_gcc.h" 1 +# 100 "../platforms/switch_x86_64_gcc.h" 1 movq %rbx, %rsp # 0 "" 2 #NO_APP From 4c1aed542839cdcbf155e415189500523c89a304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 15:35:53 +0000 Subject: [PATCH 024/115] cross-compile for ARM and ARM64 --- Makefile | 33 +++++++++++++++++------------ README.md | 19 ++++++++++++++++- lib/aarch64/libstackman.a | Bin 0 -> 3902 bytes lib/arm32/libstackman.a | Bin 0 -> 2722 bytes src/platforms/switch_aarch64_gcc.h | 3 ++- 5 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 lib/aarch64/libstackman.a create mode 100644 lib/arm32/libstackman.a diff --git a/Makefile b/Makefile index 93b0fef..ada91bc 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,24 @@ -CPPFLAGS += -Isrc $(PLATFORM) -CFLAGS += -fPIC -g $(PLATFORM) -CXXFLAGS += -fPIC -g $(PLATFORM) -LDFLAGS += -L$(LIB) -g $(PLATFORM) +CPPFLAGS += -Isrc $(PLATFORMFLAGS) +CFLAGS += -fPIC -g $(PLATFORMFLAGS) +CXXFLAGS += -fPIC -g $(PLATFORMFLAGS) +LDFLAGS += -L$(LIB) -g $(PLATFORMFLAGS) # add flag to disable Intel CET NO_CET := $(shell ./disable_cet $(CC)) CFLAGS += $(NO_CET) CXXFLAGS += $(NO_CET) +OLDCC := $(CC) +ifdef PLATFORM_PREFIX +CC = $(PLATFORM_PREFIX)gcc +CXX = $(PLATFORM_PREFIX)g++ +LD = $(PLATFORM_PREFIX)ld +AR = $(PLATFORM_PREFIX)ar +endif # run c preprocessor with any cflags to get cross compilation result, then run regular compile in native -ABI := $(shell mkdir -p bin; $(CC) -E $(CFLAGS) $(CPPFLAGS) -o bin/get_abi.c get_abi.c && $(CC) -o bin/get_abi bin/get_abi.c && bin/get_abi) +ABI := $(shell set -x; mkdir -p bin; $(CC) -E $(CFLAGS) $(CPPFLAGS) -o bin/get_abi.c get_abi.c && $(OLDCC) -o bin/get_abi bin/get_abi.c && bin/get_abi) ifndef ABI $(error Could not determine platform) else @@ -41,10 +48,10 @@ DEBUG = #-DDEBUG_DUMP .PHONY: test tests test: tests - bin/test - bin/test_cc - bin/test_static - bin/test_asm + $(EMULATOR) bin/test + $(EMULATOR) bin/test_cc + $(EMULATOR) bin/test_static + $(EMULATOR) bin/test_asm @echo "*** All test suites passed ***" tests: bin/test @@ -54,13 +61,13 @@ tests: bin/test_asm tests: LDLIBS := -lstackman bin/test: tests/test.o $(LIB)/libstackman.a - $(CC) $(LDFLAGS) -o $@ $< ${DEBUG} $(LDLIBS) + $(CC) $(LDFLAGS) -static -o $@ $< ${DEBUG} $(LDLIBS) bin/test_cc: tests/test_cc.o $(LIB)/libstackman.a - $(CXX) $(LDFLAGS) -o $@ $< ${DEBUG} $(LDLIBS) + $(CXX) $(LDFLAGS) -static -o $@ $< ${DEBUG} $(LDLIBS) bin/test_static: tests/test_static.o - $(CC) $(LDFLAGS) -o $@ $^ ${DEBUG} + $(CC) $(LDFLAGS) -static -o $@ $^ ${DEBUG} bin/test_asm: tests/test_asm.o tests/test_asm_s.o - $(CC) $(LDFLAGS) -o $@ $^ ${DEBUG} + $(CC) $(LDFLAGS) -static -o $@ $^ ${DEBUG} diff --git a/README.md b/README.md index e8dbbd6..46dd509 100644 --- a/README.md +++ b/README.md @@ -119,4 +119,21 @@ src/platform/gen_asm.c The x86 tools require the **gcc-multilib** and **g++-multilib** packages to be installed. They, however, can't co-exist with the **gcc-arm-linux-gnueabi** or **gcc-aarch64-linux-gnu** packages on some distributions, and so development for these -platforms may need to be done independently. \ No newline at end of file +platforms may need to be done independently. + +### Cross compiling for x86 (32 bit) on Linux + - install __gcc-multilib__ and __g++-multilib__ + - *compile* **gen_asm.c** using `gcc -m32` + - *make* using `make PLATFORMFLAGS=-m32 test` + +### Cross compiling for ARM (32 bit) on Linux + - install __gcc-arm-linux-gnueabi__ and __g++-arm-linux-gnueabi__ + - install __qemu-user__ for hardware emulation + - *compile* **gen_asm.c** using `arm-linux-gnueabi-gcc` + - *make* using `make PLATFORM_PREFIX=arm-linux-gnueabi- EMULATOR=qemu-armhf test` + +### Cross compiling for Arm64 on Linux + - install **gcc-aarch64-linux-gnu** and **g++-aarch64-linux-gnu** + - install __qemu-user__ for hardware emulation + - *compile* using `aarch64-linux-gnu-gcc` + - *make* using `make PLATFORM_PREFIX=aarch64-linux-gnu- EMULATOR=qemu-arm64 test` diff --git a/lib/aarch64/libstackman.a b/lib/aarch64/libstackman.a new file mode 100644 index 0000000000000000000000000000000000000000..e4874e12bedddfa8500ef019a513a84f6a8fca02 GIT binary patch literal 3902 zcmcImO>7%g5T5mVogXJ|(gXnt(2bPRM#5{mNmD>=<20oCZ5pK%A#rfl&c-qEt}A;} z0+C3ia_9|0`7N~SG0Bkwa6$-i;sR13{I)7^K?tFufKXILFthvKX8q!*Q4u5Wdo$ns zyxH0Dd$0AdUd&7%t&OSW6!(cP?;lmQ^8h!Ps0DxkK=mbhO17SvF?B0ddM;;Yroodl zdOq(-TESg!yH&b6JDudeL!o^&Y-~-r{I0|q}-sF=Gn}i0~1^bZ? zI&!t+R_E|+2n4H$lY>gmvH_$X({EJs=*4fo>PwLv(16h*XPY&BXxfDgVn5=mR> zeuM(hgkw;;9jONi2?c!cH*1x0S<9GIX~F){(`s)bp&rr>YH>Ac=5w~4H=>3$nbR$l z^>pq?{!CY=8qKQFsjVEzg1M6=vg1 zTIqSy*3+P2C%N-9=WJun25nNebXW=p*x?2{!!f@(4vg5sT zAH$E}EXE{Np6MTEGoM7;F;s{c*}lpgR5tTTv>ir8rThn2L3y5(KmE(a{8NaDF%g3I zXh3?l^c*IKE}4yZV^cp~a(#I6K$dU4U1=ficnx;}D#CNNTCu1CxmH|JVi6 z_e8Ermz%FN4PD&*TI1^tZ|r(A@>c!Zb(g~L)V^Dz3{)$FRmxCE8CH~$pmIW1Mgz)8 z>8TsnL!+USp^?yu&`@YNG!Pp6{)cbB`}&)&R_?W2|lX!@x=DwLp4p}<0q9Bl)o4G(Y=%V^L>Su5!a?T pU$FI6Hq%)|H*?W{yEEz*3mT(fK4RfKWV80J_5$ag4Dd3h~@;iK!>@t z{+^#BtdtiA#;+fxVLJ+14hOn?ZNpiwR-HG!y5~D?kN1B~B)!{p32nO@3+akRxR%D- zY>?g5ZH1y6H04@5>N{@RaksC(vyL{~TlZEHOE}}iO=S{CZAz17#caFRq)I351(lmg zn97etRB4BD^5Gpeg%+b8!mv&4x&5jjFHqGqPaeH!m%FzmFcvJyXFX;ZL?z7u~>*8oV z!8Cv@8t7%B`i_xg@QEa^C8Qv)k*4G&LDy>qjedJGjJ9LAGFdblNpL&w6^V%2 z0R|{QH;e)!V{Y=AajzHP;&~A+iihimi-II2@8SpVc|yu0Z1g3@KLecvme14dy2`on z1m>(4HO`#gUbt6)?k|YTaX2pDNE7!%$Yu;g`Vssh3!02Cgw8Ur zo#|)r_nD*`_AyJ{8{7>Ts|u2}2FIn3WkX-(6&Q_r2Qtp$Rv!1NQF1uOt7@p6J22db z_&k{FEq`wr%zI+a79xF#LHUd`aXF9jxZi;Lfd^Xd_r!7be@7hk zL8EtM8moW&zWa#$!O)_?aLySFsXTZ<*9SxU!eF@aq%tJ7-G?9c5->H`9)EZ5p?}4F zG`n->4>Pt<#(0e3IV|9zKj862$o@C?9!}I_=d8El`EJ$Mm3Ubh{?8gbSryG`sKc>| z3*4BVR--u&m{!4uaNAC4neQ#@)DEIek@oOxofe~l`}F@3&s0nQqZ-)3cNjAN4;EqI zoig|Ot^w%Y?BebkxEGFV8;{{VV`AKyOi~T|nCrS%R-#{xpnJwJT>|HGopJvr*Z%}= f2h8=2^Lwvczl%V;W Date: Sat, 5 Dec 2020 18:43:14 +0000 Subject: [PATCH 025/115] Add initial travis config --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..81c52ee --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: c +dist: bionic +script: make && make test \ No newline at end of file From a31ec0cf792021082f7c0ae29742f54fb3882f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 19:15:20 +0000 Subject: [PATCH 026/115] Add i386 build --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 81c52ee..6812352 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,9 @@ language: c dist: bionic -script: make && make test \ No newline at end of file +script: make && make test +jobs: + include: + - name: x86_64_gcc + - name: x86_gcc + before_install: sudo apt install -y gcc-multilib g++-multilib + env: PLATFORMFLAGS=-m32 \ No newline at end of file From 714eaad365a8ad9b21be7589fe5a4c7ff289f38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 20:25:46 +0000 Subject: [PATCH 027/115] Enable arm64 build --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6812352..a4e018e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,5 @@ jobs: - name: x86_64_gcc - name: x86_gcc before_install: sudo apt install -y gcc-multilib g++-multilib - env: PLATFORMFLAGS=-m32 \ No newline at end of file + env: PLATFORMFLAGS=-m32 + - arch: arm64 \ No newline at end of file From e9bc491b1746b497aaecf688233fb4f5d1e99134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 20:32:28 +0000 Subject: [PATCH 028/115] add arm support to travis. native aarch64 and emulated arm32 on x64 --- .travis.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a4e018e..25e2bf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,11 @@ jobs: - name: x86_gcc before_install: sudo apt install -y gcc-multilib g++-multilib env: PLATFORMFLAGS=-m32 - - arch: arm64 \ No newline at end of file + - arch: arm64 + - name: arm32_xcompile + before_install: + - sudo apt install -y gcc-arm-linux-gnueabi g++-aarch64-linux-gnu + - sudo apt install -y qemu-user + env: + - PLATFORM_PREFIX=aarch64-linux-gnu- + - EMULATOR=qemu-armhf \ No newline at end of file From d38b094aa87abad1b4432d3000f3f15fe60b01af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 20:39:20 +0000 Subject: [PATCH 029/115] Add travis build thingie to Readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 46dd509..0eae610 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/kristjanvalur/stackman.svg?branch=master)](https://travis-ci.org/kristjanvalur/stackman) + # stackman Simple low-level stack manipulation API and implementation for common platforms From 42b35fbe01a20ad67002b8f4be71a746cd51926e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 21:13:46 +0000 Subject: [PATCH 030/115] attempt to fix arm32 xcompile on travis --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25e2bf2..4863106 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,9 @@ jobs: - arch: arm64 - name: arm32_xcompile before_install: - - sudo apt install -y gcc-arm-linux-gnueabi g++-aarch64-linux-gnu + - sudo apt update + - sudo apt install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi - sudo apt install -y qemu-user env: - - PLATFORM_PREFIX=aarch64-linux-gnu- + - PLATFORM_PREFIX=arm-linux-gnueabi- - EMULATOR=qemu-armhf \ No newline at end of file From e4af9615b634b4abdb9b57e6337b12a4acb3d0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 5 Dec 2020 21:30:08 +0000 Subject: [PATCH 031/115] Use qemu-arm rather than the non-existant qemu-armhf for emulating arm on x86 --- .travis.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4863106..3e0a848 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,4 @@ jobs: - sudo apt install -y qemu-user env: - PLATFORM_PREFIX=arm-linux-gnueabi- - - EMULATOR=qemu-armhf \ No newline at end of file + - EMULATOR=qemu-arm \ No newline at end of file diff --git a/README.md b/README.md index 0eae610..1f88b33 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ platforms may need to be done independently. - install __gcc-arm-linux-gnueabi__ and __g++-arm-linux-gnueabi__ - install __qemu-user__ for hardware emulation - *compile* **gen_asm.c** using `arm-linux-gnueabi-gcc` - - *make* using `make PLATFORM_PREFIX=arm-linux-gnueabi- EMULATOR=qemu-armhf test` + - *make* using `make PLATFORM_PREFIX=arm-linux-gnueabi- EMULATOR=qemu-arm test` ### Cross compiling for Arm64 on Linux - install **gcc-aarch64-linux-gnu** and **g++-aarch64-linux-gnu** From 4711ccd68bdc7eba45ce1955e39eee61ef96a15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 13:13:31 +0000 Subject: [PATCH 032/115] Add windows builds for x64 and x86 --- .travis.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3e0a848..c7669c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,16 @@ jobs: - sudo apt install -y qemu-user env: - PLATFORM_PREFIX=arm-linux-gnueabi- - - EMULATOR=qemu-arm \ No newline at end of file + - EMULATOR=qemu-arm + - os: windows + name: x64_msvc + script: + - "/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat" + - msbuild vc2019/stackman.sln /p:Platform=x64 + - vc2019/x64/Debug/test.exe + - os: windows + name: x86_msvc + script: + - "/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat" + - msbuild vc2019/stackman.sln /p:Platform=x86 + - vc2019/win32/Debug/test.exe \ No newline at end of file From 36afd84350e1b54b5eac2d980bf63ad788bb4f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 13:21:17 +0000 Subject: [PATCH 033/115] Quote properly the bash script --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7669c0..e9504f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,12 +19,12 @@ jobs: - os: windows name: x64_msvc script: - - "/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat" - - msbuild vc2019/stackman.sln /p:Platform=x64 - - vc2019/x64/Debug/test.exe + - '"/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat"' + - msbuild.exe vs2019/stackman.sln /p:Platform=x64 + - vs2019/x64/Debug/test.exe - os: windows name: x86_msvc script: - - "/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat" - - msbuild vc2019/stackman.sln /p:Platform=x86 - - vc2019/win32/Debug/test.exe \ No newline at end of file + - '"/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat"' + - msbuild.exe vs2019/stackman.sln /p:Platform=x86 + - vs2019/win32/Debug/test.exe \ No newline at end of file From cf2145dd998d8d944c7641161918efd1c5b31bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 13:33:07 +0000 Subject: [PATCH 034/115] Batch file to build, since VS build commands don't work from Git BASH --- .gitignore | 8 -------- .travis.yml | 12 ++++++------ vs2019/build_x64.cmd | 3 +++ vs2019/build_x86.cmd | 3 +++ 4 files changed, 12 insertions(+), 14 deletions(-) create mode 100644 vs2019/build_x64.cmd create mode 100644 vs2019/build_x86.cmd diff --git a/.gitignore b/.gitignore index 446be5a..8af84ea 100644 --- a/.gitignore +++ b/.gitignore @@ -42,14 +42,6 @@ *.idb *.pdb -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf # custom bin/ diff --git a/.travis.yml b/.travis.yml index e9504f4..43a4914 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,12 +19,12 @@ jobs: - os: windows name: x64_msvc script: - - '"/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat"' - - msbuild.exe vs2019/stackman.sln /p:Platform=x64 - - vs2019/x64/Debug/test.exe + - cd vs2019 + - build_x64.cmd + - x64/Debug/test.exe - os: windows name: x86_msvc script: - - '"/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat"' - - msbuild.exe vs2019/stackman.sln /p:Platform=x86 - - vs2019/win32/Debug/test.exe \ No newline at end of file + - cd vs2019 + - build_x86.cmd + - Win32/Debug/test.exe \ No newline at end of file diff --git a/vs2019/build_x64.cmd b/vs2019/build_x64.cmd new file mode 100644 index 0000000..449fbf5 --- /dev/null +++ b/vs2019/build_x64.cmd @@ -0,0 +1,3 @@ +rem Build x64 with visualstudio2017buildtools +C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat +msbuild stackman.sln /p:Platform=x64 diff --git a/vs2019/build_x86.cmd b/vs2019/build_x86.cmd new file mode 100644 index 0000000..7c4bdbd --- /dev/null +++ b/vs2019/build_x86.cmd @@ -0,0 +1,3 @@ +rem Build x86 with visualstudio2017buildtools +C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat +msbuild stackman.sln /p:Platform=x86 From 918c9abfde28aa0778b0a6c37bceecb5196cc0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 13:37:35 +0000 Subject: [PATCH 035/115] fix --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 43a4914..6ebbead 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,11 +20,10 @@ jobs: name: x64_msvc script: - cd vs2019 - - build_x64.cmd - - x64/Debug/test.exe + - ./build_x64.cmd && x64/Debug/test.exe - os: windows name: x86_msvc script: - cd vs2019 - - build_x86.cmd + - ./build_x86.cmd - Win32/Debug/test.exe \ No newline at end of file From 6634c5ad3fc343779c8b3ff282a0c5b1a71d9a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 13:45:52 +0000 Subject: [PATCH 036/115] explicitly invoke cmd.exe --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ebbead..0d954b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,10 +20,10 @@ jobs: name: x64_msvc script: - cd vs2019 - - ./build_x64.cmd && x64/Debug/test.exe + - cmd "/C build_x64.cmd" && x64/Debug/test.exe - os: windows name: x86_msvc script: - cd vs2019 - - ./build_x86.cmd + - cmd "/C build_x86.cmd" - Win32/Debug/test.exe \ No newline at end of file From a55166cd288354db7a14cca8774b8f1727ea460b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 13:53:04 +0000 Subject: [PATCH 037/115] Quote the paths in the .cmd files --- .travis.yml | 4 ++-- vs2019/build_x64.cmd | 2 +- vs2019/build_x86.cmd | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d954b2..99180e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,10 +20,10 @@ jobs: name: x64_msvc script: - cd vs2019 - - cmd "/C build_x64.cmd" && x64/Debug/test.exe + - build_x64.cmd && x64/Debug/test.exe - os: windows name: x86_msvc script: - cd vs2019 - - cmd "/C build_x86.cmd" + - 'cmd "/C build_x86.cmd"' - Win32/Debug/test.exe \ No newline at end of file diff --git a/vs2019/build_x64.cmd b/vs2019/build_x64.cmd index 449fbf5..098b76d 100644 --- a/vs2019/build_x64.cmd +++ b/vs2019/build_x64.cmd @@ -1,3 +1,3 @@ rem Build x64 with visualstudio2017buildtools -C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat +"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" msbuild stackman.sln /p:Platform=x64 diff --git a/vs2019/build_x86.cmd b/vs2019/build_x86.cmd index 7c4bdbd..550d3a5 100644 --- a/vs2019/build_x86.cmd +++ b/vs2019/build_x86.cmd @@ -1,3 +1,3 @@ rem Build x86 with visualstudio2017buildtools -C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat +"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" msbuild stackman.sln /p:Platform=x86 From 0fa8304b37b3d907b155a4426342a0568c0c53c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 14:05:56 +0000 Subject: [PATCH 038/115] Call the batch file properly --- .travis.yml | 5 ++--- vs2019/build_x64.cmd | 2 +- vs2019/build_x86.cmd | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 99180e7..0780c76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,10 +20,9 @@ jobs: name: x64_msvc script: - cd vs2019 - - build_x64.cmd && x64/Debug/test.exe + - ./build_x64.cmd && x64/Debug/test.exe - os: windows name: x86_msvc script: - cd vs2019 - - 'cmd "/C build_x86.cmd"' - - Win32/Debug/test.exe \ No newline at end of file + - ./build_x86.cmd && Win32/Debug/test.exe \ No newline at end of file diff --git a/vs2019/build_x64.cmd b/vs2019/build_x64.cmd index 098b76d..2e03982 100644 --- a/vs2019/build_x64.cmd +++ b/vs2019/build_x64.cmd @@ -1,3 +1,3 @@ rem Build x64 with visualstudio2017buildtools -"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" msbuild stackman.sln /p:Platform=x64 diff --git a/vs2019/build_x86.cmd b/vs2019/build_x86.cmd index 550d3a5..500d52e 100644 --- a/vs2019/build_x86.cmd +++ b/vs2019/build_x86.cmd @@ -1,3 +1,3 @@ rem Build x86 with visualstudio2017buildtools -"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" msbuild stackman.sln /p:Platform=x86 From e2f206855eebc63d9df20f74c170683a1af6617f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 14:32:48 +0000 Subject: [PATCH 039/115] Add a vc2017 version of the project, targeting build tools 141 --- vs2017/stackman.sln | 44 +++++ vs2017/stackman/stackman.vcxproj | 230 +++++++++++++++++++++++ vs2017/stackman/stackman.vcxproj.filters | 67 +++++++ vs2017/test/test.vcxproj | 152 +++++++++++++++ vs2017/test/test.vcxproj.filters | 22 +++ 5 files changed, 515 insertions(+) create mode 100644 vs2017/stackman.sln create mode 100644 vs2017/stackman/stackman.vcxproj create mode 100644 vs2017/stackman/stackman.vcxproj.filters create mode 100644 vs2017/test/test.vcxproj create mode 100644 vs2017/test/test.vcxproj.filters diff --git a/vs2017/stackman.sln b/vs2017/stackman.sln new file mode 100644 index 0000000..6dff39b --- /dev/null +++ b/vs2017/stackman.sln @@ -0,0 +1,44 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}" + ProjectSection(ProjectDependencies) = postProject + {BF7D0638-AC4F-4206-B426-66CDDD468281} = {BF7D0638-AC4F-4206-B426-66CDDD468281} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stackman", "stackman\stackman.vcxproj", "{BF7D0638-AC4F-4206-B426-66CDDD468281}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM.ActiveCfg = Debug|ARM + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM.Build.0 = Debug|ARM + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM64.Build.0 = Debug|ARM64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x64.ActiveCfg = Debug|x64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x64.Build.0 = Debug|x64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x86.ActiveCfg = Debug|Win32 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x86.Build.0 = Debug|Win32 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM.ActiveCfg = Debug|ARM + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM.Build.0 = Debug|ARM + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM64.Build.0 = Debug|ARM64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x64.ActiveCfg = Debug|x64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x64.Build.0 = Debug|x64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x86.ActiveCfg = Debug|Win32 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x86.Build.0 = Debug|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A71982F0-A89C-45AB-9F23-149A1983A11B} + EndGlobalSection +EndGlobal diff --git a/vs2017/stackman/stackman.vcxproj b/vs2017/stackman/stackman.vcxproj new file mode 100644 index 0000000..95fc13d --- /dev/null +++ b/vs2017/stackman/stackman.vcxproj @@ -0,0 +1,230 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + + 16.0 + Win32Proj + {bf7d0638-ac4f-4206-b426-66cddd468281} + stackman + 10.0.17763.0 + stackman + + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + true + v141 + Unicode + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)\..\lib\win_x86\ + $(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\..\lib\win_x64\ + + + true + $(SolutionDir)\..\lib\win_arm\ + + + true + $(SolutionDir)\..\lib\win_arm64\ + + + + Level3 + true + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + + + + + + + + + + + + + false + Default + + + AssemblyCode + AssemblyCode + AssemblyCode + false + false + false + Default + Default + Default + false + false + false + true + true + false + true + + + + + false + true + true + true + + + Document + true + true + true + + + true + true + true + + + true + true + true + + + + + + + + \ No newline at end of file diff --git a/vs2017/stackman/stackman.vcxproj.filters b/vs2017/stackman/stackman.vcxproj.filters new file mode 100644 index 0000000..6db744f --- /dev/null +++ b/vs2017/stackman/stackman.vcxproj.filters @@ -0,0 +1,67 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + + + Source Files + + + Source Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/vs2017/test/test.vcxproj b/vs2017/test/test.vcxproj new file mode 100644 index 0000000..4dc2870 --- /dev/null +++ b/vs2017/test/test.vcxproj @@ -0,0 +1,152 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + + 16.0 + Win32Proj + {cafdbd3e-9d0d-4e90-bb6d-6c2a19f5ef53} + test + 10.0 + + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + true + + + true + + + true + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\src + + + Console + true + ..\..\lib\win_x86;%(AdditionalLibraryDirectories) + stackman.lib;%(AdditionalDependencies) + + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\src + + + Console + true + stackman.lib;%(AdditionalDependencies) + ..\..\lib\win_x64;%(AdditionalLibraryDirectories) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\src + + + Console + true + stackman.lib;%(AdditionalDependencies) + ..\..\lib\win_arm;%(AdditionalLibraryDirectories) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\src + + + Console + true + stackman.lib;%(AdditionalDependencies) + ..\..\lib\win_arm64;%(AdditionalLibraryDirectories) + + + + + + + + + \ No newline at end of file diff --git a/vs2017/test/test.vcxproj.filters b/vs2017/test/test.vcxproj.filters new file mode 100644 index 0000000..154d04b --- /dev/null +++ b/vs2017/test/test.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file From 14fc52252bd6afc17f0a51dbce2d1acc88278afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 14:34:13 +0000 Subject: [PATCH 040/115] Move build files, use vs2017 for travis --- .travis.yml | 4 ++-- {vs2019 => vs2017}/build_x64.cmd | 0 {vs2019 => vs2017}/build_x86.cmd | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {vs2019 => vs2017}/build_x64.cmd (100%) rename {vs2019 => vs2017}/build_x86.cmd (100%) diff --git a/.travis.yml b/.travis.yml index 0780c76..c8fca22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,10 +19,10 @@ jobs: - os: windows name: x64_msvc script: - - cd vs2019 + - cd vs2017 - ./build_x64.cmd && x64/Debug/test.exe - os: windows name: x86_msvc script: - - cd vs2019 + - cd vs2017 - ./build_x86.cmd && Win32/Debug/test.exe \ No newline at end of file diff --git a/vs2019/build_x64.cmd b/vs2017/build_x64.cmd similarity index 100% rename from vs2019/build_x64.cmd rename to vs2017/build_x64.cmd diff --git a/vs2019/build_x86.cmd b/vs2017/build_x86.cmd similarity index 100% rename from vs2019/build_x86.cmd rename to vs2017/build_x86.cmd From a3b2d7ad20ee2b99e22d535be09adf6c0d20f53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 16:48:42 +0000 Subject: [PATCH 041/115] Change targeted winsdk version to match Travis windows environment. --- vs2017/stackman/stackman.vcxproj | 2 +- vs2017/test/test.vcxproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vs2017/stackman/stackman.vcxproj b/vs2017/stackman/stackman.vcxproj index 95fc13d..052065d 100644 --- a/vs2017/stackman/stackman.vcxproj +++ b/vs2017/stackman/stackman.vcxproj @@ -23,7 +23,7 @@ Win32Proj {bf7d0638-ac4f-4206-b426-66cddd468281} stackman - 10.0.17763.0 + 10.0.18362.0 stackman diff --git a/vs2017/test/test.vcxproj b/vs2017/test/test.vcxproj index 4dc2870..9a03733 100644 --- a/vs2017/test/test.vcxproj +++ b/vs2017/test/test.vcxproj @@ -23,7 +23,7 @@ Win32Proj {cafdbd3e-9d0d-4e90-bb6d-6c2a19f5ef53} test - 10.0 + 10.0.18362.0 From 031e817efd6875dba452cc873caaa69080b5ac81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 18:05:21 +0000 Subject: [PATCH 042/115] Enable cross compilation of Visual Studio ARM and ARM64 targets --- .travis.yml | 14 +++++++++++++- vs2017/build.cmd | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 vs2017/build.cmd diff --git a/.travis.yml b/.travis.yml index c8fca22..39db314 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,4 +25,16 @@ jobs: name: x86_msvc script: - cd vs2017 - - ./build_x86.cmd && Win32/Debug/test.exe \ No newline at end of file + - ./build_x86.cmd && Win32/Debug/test.exe + - os: windows + name: arm_msvc + before_install: choco install --force VisualStudio2017-workload-vctools --params"--add Microsoft.VisualStudio.Component.VC.Tools.ARM" + script: + - cd vs2017 + - ./build.cmd ARM + - os: windows + name: arm64_msvc + before_install: choco install --force VisualStudio2017-workload-vctools --params"--add Microsoft.VisualStudio.Component.VC.Tools.ARM64" + script: + - cd vs2017 + - ./build.cmd ARM64 \ No newline at end of file diff --git a/vs2017/build.cmd b/vs2017/build.cmd new file mode 100644 index 0000000..c3d551c --- /dev/null +++ b/vs2017/build.cmd @@ -0,0 +1,4 @@ +rem Build with visualstudio2017buildtools +echo Building %1 +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" +msbuild stackman.sln /p:Platform=%1 From 05ad061eb16550688b4e94e3d4c88d354e6a0be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 20:23:29 +0000 Subject: [PATCH 043/115] Fix armasm64 syntax, immediate constants require #. --- src/platforms/switch_arm64_msvc.asm | 54 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/platforms/switch_arm64_msvc.asm b/src/platforms/switch_arm64_msvc.asm index 96a0f32..3095592 100644 --- a/src/platforms/switch_arm64_msvc.asm +++ b/src/platforms/switch_arm64_msvc.asm @@ -13,21 +13,21 @@ ; args "callback", "context" are in x0, x1 ; push non-volatile x18-x28 registers, in addition to fp,rl pair. ; x29 is fp, x30 is lr. - stp x29, x30, [sp, -176]! ; store fp,lr pair, allocate stack space + stp x29, x30, [sp, #-176]! ; store fp,lr pair, allocate stack space mov x29, sp ; and set fp pointing to old fp on stack ; push non-volatile registers 18-x28 and fp regs d8-d15) ; also fpcr (fp control register) mrs x2,fpcr - stp x2, x18, [sp, 16] - stp x19, x20, [sp, 32] - stp x21, x22, [sp, 48] - stp x23, x24, [sp, 64] - stp x25, x26, [sp, 80] - stp x27, x28, [sp, 96] - stp d8, d9, [sp, 112] - stp d10, d11, [sp, 128] - stp d12, d13, [sp, 144] - stp d14, d15, [sp, 160] + stp x2, x18, [sp, #16] + stp x19, x20, [sp, #32] + stp x21, x22, [sp, #48] + stp x23, x24, [sp, #64] + stp x25, x26, [sp, #80] + stp x27, x28, [sp, #96] + stp d8, d9, [sp, #112] + stp d10, d11, [sp, #128] + stp d12, d13, [sp, #144] + stp d14, d15, [sp, #160] ; args are x0=callback, x1=context ; shuffle calling arguments into r0, r1 and r2 @@ -50,19 +50,19 @@ blr x18 ;second callback ; restore registers from stack - ldp x2, x18, [sp, 16] - ldp x19, x20, [sp, 32] - ldp x21, x22, [sp, 48] - ldp x23, x24, [sp, 64] - ldp x25, x26, [sp, 80] - ldp x27, x28, [sp, 96] - ldp d8, d9, [sp, 112] - ldp d10, d11, [sp, 128] - ldp d12, d13, [sp, 144] - ldp d14, d15, [sp, 160] - msr fpcr,x2 + ldp x2, x18, [sp, #16] + ldp x19, x20, [sp, #32] + ldp x21, x22, [sp, #48] + ldp x23, x24, [sp, #64] + ldp x25, x26, [sp, #80] + ldp x27, x28, [sp, #96] + ldp d8, d9, [sp, #112] + ldp d10, d11, [sp, #128] + ldp d12, d13, [sp, #144] + ldp d14, d15, [sp, #160] + msr fpcr, x2 ;return - ldp x29, x30, [sp], 176 + ldp x29, x30, [sp], #176 ret ENDP @@ -72,10 +72,10 @@ ; args "callback", "context" are in x0, x1 ; push non-volatile x18-x28 registers, in addition to fp,rl pair. ; x29 is fp, x30 is lr. - stp x29, x30, [sp, -32]! ; store fp,lr pair, allocate stack space + stp x29, x30, [sp, #-32]! ; store fp,lr pair, allocate stack space mov x29, sp ; and set fp pointing to old fp on stack ; push non-volatile register 18 - str x18, [sp, 16] + str x18, [sp, #16] ; args are x0 = callback, x1 = context, x2=stack mov x3, x0 @@ -94,8 +94,8 @@ mov sp, x18 ; return - ldr x18, [sp, 16] - ldp x29, x30, [sp], 32 + ldr x18, [sp, #16] + ldp x29, x30, [sp], #32 ret ENDP From 2d9f5b3573073830f31ac50459e5ea19562cf7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 20:49:42 +0000 Subject: [PATCH 044/115] disable template.c from the build. --- vs2017/stackman/stackman.vcxproj | 2 +- vs2017/stackman/template.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 vs2017/stackman/template.c diff --git a/vs2017/stackman/stackman.vcxproj b/vs2017/stackman/stackman.vcxproj index 052065d..ef5a64e 100644 --- a/vs2017/stackman/stackman.vcxproj +++ b/vs2017/stackman/stackman.vcxproj @@ -194,7 +194,7 @@ false true true - false + true true diff --git a/vs2017/stackman/template.c b/vs2017/stackman/template.c new file mode 100644 index 0000000..ca9b63f --- /dev/null +++ b/vs2017/stackman/template.c @@ -0,0 +1,15 @@ +#include "..\..\src\stackman.h" + +/* + * template file to create assembly code (template.asm) to modify and add to real assembler. + */ + +void* stackman_call_templ(stackman_cb_t callback, void* context, void* stack) +{ + // We use this variabl here for the template generation. Int the modified assembly + // code, we will store the ebp (base pointer) in that place on the stack, + // before storing the original unmodified stack pointer there. + void* localvar = stack; + return callback(context, 2, localvar); + +} \ No newline at end of file From ac24664e3f7e66779c19b72601d001c9ab9d1387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 6 Dec 2020 21:08:03 +0000 Subject: [PATCH 045/115] remove redundant winodows build scripts --- .travis.yml | 4 ++-- vs2017/build_x64.cmd | 3 --- vs2017/build_x86.cmd | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 vs2017/build_x64.cmd delete mode 100644 vs2017/build_x86.cmd diff --git a/.travis.yml b/.travis.yml index 39db314..18997f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,12 +20,12 @@ jobs: name: x64_msvc script: - cd vs2017 - - ./build_x64.cmd && x64/Debug/test.exe + - ./build.cmd x64 && x64/Debug/test.exe - os: windows name: x86_msvc script: - cd vs2017 - - ./build_x86.cmd && Win32/Debug/test.exe + - ./build.cmd x86 && Win32/Debug/test.exe - os: windows name: arm_msvc before_install: choco install --force VisualStudio2017-workload-vctools --params"--add Microsoft.VisualStudio.Component.VC.Tools.ARM" diff --git a/vs2017/build_x64.cmd b/vs2017/build_x64.cmd deleted file mode 100644 index 2e03982..0000000 --- a/vs2017/build_x64.cmd +++ /dev/null @@ -1,3 +0,0 @@ -rem Build x64 with visualstudio2017buildtools -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" -msbuild stackman.sln /p:Platform=x64 diff --git a/vs2017/build_x86.cmd b/vs2017/build_x86.cmd deleted file mode 100644 index 500d52e..0000000 --- a/vs2017/build_x86.cmd +++ /dev/null @@ -1,3 +0,0 @@ -rem Build x86 with visualstudio2017buildtools -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" -msbuild stackman.sln /p:Platform=x86 From 9a537aa53fe6eab92a499d2ed7012f9ce25e7bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 26 Dec 2020 11:20:14 +0000 Subject: [PATCH 046/115] A dedicated script to find the abiname --- .gitignore | 6 +++++- Makefile | 4 ++-- abiname.sh | 23 +++++++++++++++++++++++ get_abi.c => src/abiname.c | 0 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100755 abiname.sh rename get_abi.c => src/abiname.c (100%) diff --git a/.gitignore b/.gitignore index 446be5a..8854428 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ dkms.conf # custom bin/ +tmp/ gen_asm.s # Visual Studio noise @@ -64,4 +65,7 @@ gen_asm.s # Allow our release libraries !lib/**/*.lib -!lib/**/*.a \ No newline at end of file +!lib/**/*.a + +# vs code +.vscode/ \ No newline at end of file diff --git a/Makefile b/Makefile index 93b0fef..5acd3e1 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ CFLAGS += $(NO_CET) CXXFLAGS += $(NO_CET) # run c preprocessor with any cflags to get cross compilation result, then run regular compile in native -ABI := $(shell mkdir -p bin; $(CC) -E $(CFLAGS) $(CPPFLAGS) -o bin/get_abi.c get_abi.c && $(CC) -o bin/get_abi bin/get_abi.c && bin/get_abi) +ABI := $(shell ./abiname.sh "$(CC)" "$(CFLAGS)") ifndef ABI $(error Could not determine platform) else @@ -34,7 +34,7 @@ lib: clean: rm -f src/*.o tests/*.o - rm -f bin/* + rm -f bin/* tmp DEBUG = #-DDEBUG_DUMP diff --git a/abiname.sh b/abiname.sh new file mode 100755 index 0000000..8894471 --- /dev/null +++ b/abiname.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# this script compiles and runs src/abiname.c which merely prints +# out the name of the abi. This can be used by makefiles to identify +# the correct library path to use to link the library +# Instead of just compiling and running, we will use the provided compiler +# and flags to just invoke the pre-processor. We then use the default +# compiler and linker to compile and link it. This ensures that the +# script works in cross-compilation environments and can actually +# run the provided code. +set -eu +here=$(dirname "$0") +mkdir -p "${here}/tmp" +tmp=$(mktemp "${here}/tmp/abinameXXX.c") + +#1 create the preprocessed file +CC=${1:-cc} +CFLAGS=${2:-} +${CC} ${CFLAGS} -E -I "${here}/src" -o "${tmp}" "${here}/src/abiname.c" +#2 compile resulting file +cc -o "${tmp}.out" "${tmp}" +#3 run it +"${tmp}.out" \ No newline at end of file diff --git a/get_abi.c b/src/abiname.c similarity index 100% rename from get_abi.c rename to src/abiname.c From dd3c5689aa81040ebde9465f34c0363ce672f548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sat, 26 Dec 2020 11:44:20 +0000 Subject: [PATCH 047/115] create bin folder from Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f868f1e..e9b8e68 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ $(LIB)/libstackman.a: lib $(obj) .PHONY: lib clean lib: - mkdir -p $(LIB) + mkdir -p $(LIB) bin clean: rm -f src/*.o tests/*.o From 6892258ad496badb4f06b82fa1ccdcd71f1dfb2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 27 Dec 2020 16:24:16 +0000 Subject: [PATCH 048/115] Fix some problems with macros --- Makefile | 3 ++- src/stackman.h | 4 ++-- tests/test.c | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e9b8e68..14e3240 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,8 @@ lib: clean: rm -f src/*.o tests/*.o - rm -f bin/* tmp + rm -f bin/* + rm -rf tmp DEBUG = #-DDEBUG_DUMP diff --git a/src/stackman.h b/src/stackman.h index defd15f..4a2bf78 100644 --- a/src/stackman.h +++ b/src/stackman.h @@ -72,7 +72,7 @@ #define STACKMAN_SP_ALIGN_UP(a) (((intptr_t)((a)+STACKMAN_STACK_ALIGN-1) & ~(STACKMAN_STACK_ALIGN-1))) #if STACKMAN_STACK_DIR == 0 -#define STACKMAN_SP_FURTHEST ((void*) ^(intptr_t)-1) +#define STACKMAN_SP_FURTHEST ((void*) (intptr_t) -STACKMAN_STACK_ALIGN) #define STACKMAN_SP_NEAREST ((void*) 0) #define STACKMAN_SP_LS(a, b) ((void*)(a) < (void*)(b)) /* to compare stack position */ #define STACKMAN_SP_LE(a, b) ((void*)(a) <= (void*)(b)) /* to compare stack position */ @@ -82,7 +82,7 @@ #else /* upwards growing stacks */ #define STACKMAN_SP_FURTHEST ((void*) 0) -#define STACKMAN_SP_NEAREST ((void*) ^(intptr_t)-1) +#define STACKMAN_SP_NEAREST ((void*) (intptr_t) -STACKMAN_STACK_ALIGN) #define STACKMAN_SP_LS(a, b) ((void*)(a) > (void*)(b)) /* to compare stack position */ #define STACKMAN_SP_LE(a, b) ((void*)(a) >= (void*)(b)) /* to compare stack position */ #define STACKMAN_SP_ADD(a, b) ((a) - (b)) /* to add offset to stack pointer */ diff --git a/tests/test.c b/tests/test.c index a3efd23..6ed3cb0 100644 --- a/tests/test.c +++ b/tests/test.c @@ -254,6 +254,24 @@ void test_04(void) #endif +/* Test our various macros */ +void test_05() +{ + + int local=0; + void *away = STACKMAN_SP_FURTHEST; + void *close = STACKMAN_SP_NEAREST; + assert(STACKMAN_SP_LE(&local, away)); + assert(STACKMAN_SP_LS(&local, away)); + assert(STACKMAN_SP_LE(close, &local)); + assert(STACKMAN_SP_LS(close, &local)); + + assert(STACKMAN_SP_LE(&local, &local)); + assert(!STACKMAN_SP_LS(&local, &local)); + + assert((void*)STACKMAN_SP_ALIGN(away) == away); + +} int main(int argc, char*argv[]) { @@ -269,5 +287,7 @@ int main(int argc, char*argv[]) test_04(); printf("test_04 ok\n"); #endif + test_05(); + printf("test_05 ok\n"); return 0; } From b9527f04a9dda7efb7eea9136c5a38edd7843c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 5 Apr 2021 11:15:47 +0000 Subject: [PATCH 049/115] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f88b33..ec09feb 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Later projects, like *gevent/greenlet* have taken that idea and provided additio with a different implementation, making the switching code itself incompatible. Our work on additional stack-manipulating libraries prompted us to try to distill this functionality in its -rawest form into a separate, low-level, library. Such that any project, withing to implement *co-routine*-like +rawest form into a separate, low-level, library. Such that any project, wishing to implement *co-routine*-like behaviour on the C-stack level, could make use of simple, stable code, that can be easily extended for additional platforms as they come along. From 49e8dbc5d27b504db70faa8dd0923ae525f948ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 5 Apr 2021 12:08:24 +0000 Subject: [PATCH 050/115] use lf line endings for source files --- .gitattributes | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3340c6f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +# use unix lf line ending for everything except windows bat files +* text=auto eol=lf +*.asm text eol=lf +*.h text eol=lf +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf From 958731e86f596d659dd5f82f5dab47fea539b6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 5 Apr 2021 12:38:46 +0000 Subject: [PATCH 051/115] renormalize line endings --- src/platforms/switch_x64_msvc.asm | 268 +++++++++++++++--------------- src/platforms/switch_x64_msvc.h | 16 +- src/platforms/switch_x86_msvc.asm | 124 +++++++------- src/platforms/switch_x86_msvc.h | 76 ++++----- 4 files changed, 242 insertions(+), 242 deletions(-) diff --git a/src/platforms/switch_x64_msvc.asm b/src/platforms/switch_x64_msvc.asm index f4bd70f..f2351af 100644 --- a/src/platforms/switch_x64_msvc.asm +++ b/src/platforms/switch_x64_msvc.asm @@ -1,135 +1,135 @@ -; -; stack switching code for MASM on x64 -; Kristjan Valur Jonsson, apr 2011 -; Modified for stackman, dec 2019 -; Added stackman_call, dec 2020 -; - -include macamd64.inc - -pop_reg MACRO reg - pop reg -ENDM - -load_xmm128 macro Reg, Offset - movdqa Reg, Offset[rsp] -endm - -.code - -;arguments callback, context, are passed in rcx, rdx, respectively -;stackman_switch PROC FRAME -NESTED_ENTRY stackman_switch, _TEXT$00 - ; save all registers that the x64 ABI specifies as non-volatile. - ; This includes some mmx registers. May not always be necessary, - ; unless our application is doing 3D, but better safe than sorry. - alloc_stack 168; 10 * 16 bytes, plus 8 bytes to make stack 16 byte aligned - save_xmm128 xmm15, 144 - save_xmm128 xmm14, 128 - save_xmm128 xmm13, 112 - save_xmm128 xmm12, 96 - save_xmm128 xmm11, 80 - save_xmm128 xmm10, 64 - save_xmm128 xmm9, 48 - save_xmm128 xmm8, 32 - save_xmm128 xmm7, 16 - save_xmm128 xmm6, 0 - - push_reg r15 - push_reg r14 - push_reg r13 - push_reg r12 - - push_reg rbp - push_reg rbx - push_reg rdi - push_reg rsi - - sub rsp, 20h ;allocate shadow stack space for callee arguments - .allocstack 20h -.endprolog - - ;save argments in nonvolatile registers - mov r12, rcx ;callback - mov r13, rdx ;context - - ; load stack base that we are saving minus the callee argument - ; shadow stack. We don't want that clobbered - mov rcx, r13 ;arg1, context - mov rdx, 0 ;arg2, opcode STACKMAN_OP_SAVE - lea r8, [rsp+20h] ;arg3, stack pointer - mov rbx, rsp; ; keep old stack pointer - call r12 ; - - ;actual stack switch (and re-allocating the shadow stack): - lea rsp, [rax-20h] - ;re-adjust base pointer - sub rbx, rsp; - sub rbp, rbx; - - mov rcx, r13 ;arg1, context - mov rdx, 1 ;arg2, opcode STACKMAN_OP_RESTORE - mov r8, rax ;arg3, new stack pointer - call r12 - ;return the rax - - add rsp, 20h - pop_reg rsi - pop_reg rdi - pop_reg rbx - pop_reg rbp - - pop_reg r12 - pop_reg r13 - pop_reg r14 - pop_reg r15 - - load_xmm128 xmm15, 144 - load_xmm128 xmm14, 128 - load_xmm128 xmm13, 112 - load_xmm128 xmm12, 96 - load_xmm128 xmm11, 80 - load_xmm128 xmm10, 64 - load_xmm128 xmm9, 48 - load_xmm128 xmm8, 32 - load_xmm128 xmm7, 16 - load_xmm128 xmm6, 0 - add rsp, 168 - ret - -NESTED_END stackman_switch, _TEXT$00 -;stackman_switch ENDP - -; based on template from https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=msvc-160 -stackman_call PROC FRAME - push rbp - .pushreg rbp - ; now our stack is 16 byte aligned. don't need additional spacle - ;sub rsp, 040h - ;.allocstack 040h - lea rbp, [rsp+00h] - .setframe rbp, 00h - .endprolog - - ; suffle arguments into volatile registers - mov rax, rcx ; callback - mov rcx, rdx ; context into first arg - mov r9, r8 ; and stack pointer in volatile registers - - ; set up call - mov r8, rsp - mov edx, 2 - ; rcx already set up with context - - ; modify stack pointer before call - mov rsp, r9 - sub rsp, 32 ;pre-allocate parameter stack for the callee - call rax - - ; officialepilog - lea rsp, [rbp+0h] - pop rbp - ret 0 -stackman_call ENDP - +; +; stack switching code for MASM on x64 +; Kristjan Valur Jonsson, apr 2011 +; Modified for stackman, dec 2019 +; Added stackman_call, dec 2020 +; + +include macamd64.inc + +pop_reg MACRO reg + pop reg +ENDM + +load_xmm128 macro Reg, Offset + movdqa Reg, Offset[rsp] +endm + +.code + +;arguments callback, context, are passed in rcx, rdx, respectively +;stackman_switch PROC FRAME +NESTED_ENTRY stackman_switch, _TEXT$00 + ; save all registers that the x64 ABI specifies as non-volatile. + ; This includes some mmx registers. May not always be necessary, + ; unless our application is doing 3D, but better safe than sorry. + alloc_stack 168; 10 * 16 bytes, plus 8 bytes to make stack 16 byte aligned + save_xmm128 xmm15, 144 + save_xmm128 xmm14, 128 + save_xmm128 xmm13, 112 + save_xmm128 xmm12, 96 + save_xmm128 xmm11, 80 + save_xmm128 xmm10, 64 + save_xmm128 xmm9, 48 + save_xmm128 xmm8, 32 + save_xmm128 xmm7, 16 + save_xmm128 xmm6, 0 + + push_reg r15 + push_reg r14 + push_reg r13 + push_reg r12 + + push_reg rbp + push_reg rbx + push_reg rdi + push_reg rsi + + sub rsp, 20h ;allocate shadow stack space for callee arguments + .allocstack 20h +.endprolog + + ;save argments in nonvolatile registers + mov r12, rcx ;callback + mov r13, rdx ;context + + ; load stack base that we are saving minus the callee argument + ; shadow stack. We don't want that clobbered + mov rcx, r13 ;arg1, context + mov rdx, 0 ;arg2, opcode STACKMAN_OP_SAVE + lea r8, [rsp+20h] ;arg3, stack pointer + mov rbx, rsp; ; keep old stack pointer + call r12 ; + + ;actual stack switch (and re-allocating the shadow stack): + lea rsp, [rax-20h] + ;re-adjust base pointer + sub rbx, rsp; + sub rbp, rbx; + + mov rcx, r13 ;arg1, context + mov rdx, 1 ;arg2, opcode STACKMAN_OP_RESTORE + mov r8, rax ;arg3, new stack pointer + call r12 + ;return the rax + + add rsp, 20h + pop_reg rsi + pop_reg rdi + pop_reg rbx + pop_reg rbp + + pop_reg r12 + pop_reg r13 + pop_reg r14 + pop_reg r15 + + load_xmm128 xmm15, 144 + load_xmm128 xmm14, 128 + load_xmm128 xmm13, 112 + load_xmm128 xmm12, 96 + load_xmm128 xmm11, 80 + load_xmm128 xmm10, 64 + load_xmm128 xmm9, 48 + load_xmm128 xmm8, 32 + load_xmm128 xmm7, 16 + load_xmm128 xmm6, 0 + add rsp, 168 + ret + +NESTED_END stackman_switch, _TEXT$00 +;stackman_switch ENDP + +; based on template from https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=msvc-160 +stackman_call PROC FRAME + push rbp + .pushreg rbp + ; now our stack is 16 byte aligned. don't need additional spacle + ;sub rsp, 040h + ;.allocstack 040h + lea rbp, [rsp+00h] + .setframe rbp, 00h + .endprolog + + ; suffle arguments into volatile registers + mov rax, rcx ; callback + mov rcx, rdx ; context into first arg + mov r9, r8 ; and stack pointer in volatile registers + + ; set up call + mov r8, rsp + mov edx, 2 + ; rcx already set up with context + + ; modify stack pointer before call + mov rsp, r9 + sub rsp, 32 ;pre-allocate parameter stack for the callee + call rax + + ; officialepilog + lea rsp, [rbp+0h] + pop rbp + ret 0 +stackman_call ENDP + END \ No newline at end of file diff --git a/src/platforms/switch_x64_msvc.h b/src/platforms/switch_x64_msvc.h index 0b4d1c5..d1dc6ac 100644 --- a/src/platforms/switch_x64_msvc.h +++ b/src/platforms/switch_x64_msvc.h @@ -1,8 +1,8 @@ -/* The actual stack saving function, which just stores the stack, - * this declared in an .asm file - */ -#ifndef STACKMAN_ASSEMBLY_SRC -#define STACKMAN_ASSEMBLY_SRC switch_x64_msvc.asm -#define STACKMAN_HAVE_CALL 1 -#define STACKMAN_STACK_ALIGN 16 -#endif +/* The actual stack saving function, which just stores the stack, + * this declared in an .asm file + */ +#ifndef STACKMAN_ASSEMBLY_SRC +#define STACKMAN_ASSEMBLY_SRC switch_x64_msvc.asm +#define STACKMAN_HAVE_CALL 1 +#define STACKMAN_STACK_ALIGN 16 +#endif diff --git a/src/platforms/switch_x86_msvc.asm b/src/platforms/switch_x86_msvc.asm index ce5a42b..1884987 100644 --- a/src/platforms/switch_x86_msvc.asm +++ b/src/platforms/switch_x86_msvc.asm @@ -1,62 +1,62 @@ - -.386 -.model flat, c - -.code - -stackman_switch_raw PROC callback:DWORD, context:DWORD - ;Assembler has already pushed the basepointer and saved it. - ;save registers. EAX ECX and EDX are available for function use and thus - ;do not have to be stored. - push ebx - push esi - push edi - - mov esi, callback ; /* save 'callback' for later */ - mov edi, context ; /* save 'context' for later */ - - mov eax, esp - - push eax ; /* arg 3: current (old) stack pointer */ - push 0; /* arg 2: opcode STACKMAN_OP_SAVE */ - push edi ; /* arg 1: context */ - call esi ; /* call callback() */ - add esp, 12; - - mov ecx, eax; /* change stack pointer to eax, preserving */ - sub ecx, esp; /* base pointer offset from esp */ - mov esp, eax; - add ebp, ecx; - - - push eax ; /* arg 3: current (new) stack pointer */ - push 1; /* arg 2: opcode STACKMAN_OP_RESTORE */ - push edi ; /* arg 1: context */ - call esi ; /* call callback() */ - add esp, 12 - - pop edi - pop esi - pop ebx - ret -stackman_switch_raw ENDP - - -stackman_call PROC callback:DWORD, context:DWORD, stack_pointer:DWORD - ;enter prolog has pushed ebp and saved esp in ebp - - mov eax, callback - mov ecx, context - mov edx, stack_pointer - - ; switch stack pointer - mov esp, stack_pointer - push ebp ;old stack pointer - push 2 ;STACKMAN_OP_CALL - push ecx ;context - call eax ;callback - ret ; this assembles a LEAVE instruction which restores esp to ebp, then pops the ebp -stackman_call ENDP - - -end + +.386 +.model flat, c + +.code + +stackman_switch_raw PROC callback:DWORD, context:DWORD + ;Assembler has already pushed the basepointer and saved it. + ;save registers. EAX ECX and EDX are available for function use and thus + ;do not have to be stored. + push ebx + push esi + push edi + + mov esi, callback ; /* save 'callback' for later */ + mov edi, context ; /* save 'context' for later */ + + mov eax, esp + + push eax ; /* arg 3: current (old) stack pointer */ + push 0; /* arg 2: opcode STACKMAN_OP_SAVE */ + push edi ; /* arg 1: context */ + call esi ; /* call callback() */ + add esp, 12; + + mov ecx, eax; /* change stack pointer to eax, preserving */ + sub ecx, esp; /* base pointer offset from esp */ + mov esp, eax; + add ebp, ecx; + + + push eax ; /* arg 3: current (new) stack pointer */ + push 1; /* arg 2: opcode STACKMAN_OP_RESTORE */ + push edi ; /* arg 1: context */ + call esi ; /* call callback() */ + add esp, 12 + + pop edi + pop esi + pop ebx + ret +stackman_switch_raw ENDP + + +stackman_call PROC callback:DWORD, context:DWORD, stack_pointer:DWORD + ;enter prolog has pushed ebp and saved esp in ebp + + mov eax, callback + mov ecx, context + mov edx, stack_pointer + + ; switch stack pointer + mov esp, stack_pointer + push ebp ;old stack pointer + push 2 ;STACKMAN_OP_CALL + push ecx ;context + call eax ;callback + ret ; this assembles a LEAVE instruction which restores esp to ebp, then pops the ebp +stackman_call ENDP + + +end diff --git a/src/platforms/switch_x86_msvc.h b/src/platforms/switch_x86_msvc.h index ca176d0..e30824e 100644 --- a/src/platforms/switch_x86_msvc.h +++ b/src/platforms/switch_x86_msvc.h @@ -1,38 +1,38 @@ -/* The actual stack saving function, which just stores the stack, - * this declared in an .asm file - * The C function defined here, saves and restores the structured - * exception handling state. - */ -#if !defined(STACKMAN_ASSEMBLY_SRC) -#define STACKMAN_ASSEMBLY_SRC switch_x86_msvc.asm -#define STACKMAN_SWITCH_C 1 /* contains a C implementation */ -#define STACKMAN_HAVE_CALL 1 -#define STACKMAN_STACK_ALIGN 4 -#endif - - -#ifdef STACKMAN_SWITCH_IMPL -#include "../stackman_switch.h" - -extern void *stackman_switch_raw(stackman_cb_t callback, void *context); - -#define WIN32_LEAN_AND_MEAN -#include - -/* Store any other runtime information on the local stack */ -#pragma optimize("", off) /* so that autos are stored on the stack */ -#pragma warning(disable:4733) /* disable warning about modifying FS[0] */ - -STACKMAN_LINKAGE_SWITCH -void *stackman_switch(stackman_cb_t callback, void *context) -{ - /* store the structured exception state for this stack */ - DWORD seh_state = __readfsdword(FIELD_OFFSET(NT_TIB, ExceptionList)); - void * result = stackman_switch_raw(callback, context); - __writefsdword(FIELD_OFFSET(NT_TIB, ExceptionList), seh_state); - return result; -} -#pragma warning(default:4733) /* disable warning about modifying FS[0] */ -#pragma optimize("", on) - -#endif +/* The actual stack saving function, which just stores the stack, + * this declared in an .asm file + * The C function defined here, saves and restores the structured + * exception handling state. + */ +#if !defined(STACKMAN_ASSEMBLY_SRC) +#define STACKMAN_ASSEMBLY_SRC switch_x86_msvc.asm +#define STACKMAN_SWITCH_C 1 /* contains a C implementation */ +#define STACKMAN_HAVE_CALL 1 +#define STACKMAN_STACK_ALIGN 4 +#endif + + +#ifdef STACKMAN_SWITCH_IMPL +#include "../stackman_switch.h" + +extern void *stackman_switch_raw(stackman_cb_t callback, void *context); + +#define WIN32_LEAN_AND_MEAN +#include + +/* Store any other runtime information on the local stack */ +#pragma optimize("", off) /* so that autos are stored on the stack */ +#pragma warning(disable:4733) /* disable warning about modifying FS[0] */ + +STACKMAN_LINKAGE_SWITCH +void *stackman_switch(stackman_cb_t callback, void *context) +{ + /* store the structured exception state for this stack */ + DWORD seh_state = __readfsdword(FIELD_OFFSET(NT_TIB, ExceptionList)); + void * result = stackman_switch_raw(callback, context); + __writefsdword(FIELD_OFFSET(NT_TIB, ExceptionList), seh_state); + return result; +} +#pragma warning(default:4733) /* disable warning about modifying FS[0] */ +#pragma optimize("", on) + +#endif From ccda28ef4fe66fc60f5bdc59a925b67f0a95e801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 6 Apr 2021 16:38:19 +0000 Subject: [PATCH 052/115] Rename 'src' folder to 'stackman' This allows client libraries to avoid include ambiguities by adding an include path for the root, and then include the libraries using #include --- Makefile | 6 ++--- abiname.sh | 4 +-- {src => stackman}/abiname.c | 0 {src => stackman}/extras/slp_switch.h | 0 {src => stackman}/platforms/gen_asm.c | 0 {src => stackman}/platforms/platform.h | 0 .../platforms/switch_aarch64_gcc.S | 0 .../platforms/switch_aarch64_gcc.h | 0 .../platforms/switch_arm64_msvc.asm | 0 .../platforms/switch_arm64_msvc.h | 0 {src => stackman}/platforms/switch_arm_gcc.S | 0 {src => stackman}/platforms/switch_arm_gcc.h | 0 .../platforms/switch_arm_msvc.asm | 0 {src => stackman}/platforms/switch_arm_msvc.h | 0 {src => stackman}/platforms/switch_template.h | 0 .../platforms/switch_x64_msvc.asm | 0 {src => stackman}/platforms/switch_x64_msvc.h | 0 .../platforms/switch_x86_64_gcc.S | 0 .../platforms/switch_x86_64_gcc.h | 0 {src => stackman}/platforms/switch_x86_gcc.S | 0 {src => stackman}/platforms/switch_x86_gcc.h | 0 .../platforms/switch_x86_msvc.asm | 0 {src => stackman}/platforms/switch_x86_msvc.h | 0 {src => stackman}/stackman.c | 0 {src => stackman}/stackman.h | 0 {src => stackman}/stackman_impl.h | 0 {src => stackman}/stackman_s.S | 0 {src => stackman}/stackman_s.asm | 0 {src => stackman}/stackman_switch.h | 0 vs2017/stackman/stackman.vcxproj | 26 +++++++++---------- vs2017/stackman/stackman.vcxproj.filters | 26 +++++++++---------- vs2017/stackman/template.c | 2 +- vs2019/stackman/stackman.vcxproj | 26 +++++++++---------- vs2019/stackman/stackman.vcxproj.filters | 26 +++++++++---------- vs2019/stackman/template.c | 2 +- 35 files changed, 59 insertions(+), 59 deletions(-) rename {src => stackman}/abiname.c (100%) rename {src => stackman}/extras/slp_switch.h (100%) rename {src => stackman}/platforms/gen_asm.c (100%) rename {src => stackman}/platforms/platform.h (100%) rename {src => stackman}/platforms/switch_aarch64_gcc.S (100%) rename {src => stackman}/platforms/switch_aarch64_gcc.h (100%) rename {src => stackman}/platforms/switch_arm64_msvc.asm (100%) rename {src => stackman}/platforms/switch_arm64_msvc.h (100%) rename {src => stackman}/platforms/switch_arm_gcc.S (100%) rename {src => stackman}/platforms/switch_arm_gcc.h (100%) rename {src => stackman}/platforms/switch_arm_msvc.asm (100%) rename {src => stackman}/platforms/switch_arm_msvc.h (100%) rename {src => stackman}/platforms/switch_template.h (100%) rename {src => stackman}/platforms/switch_x64_msvc.asm (100%) rename {src => stackman}/platforms/switch_x64_msvc.h (100%) rename {src => stackman}/platforms/switch_x86_64_gcc.S (100%) rename {src => stackman}/platforms/switch_x86_64_gcc.h (100%) rename {src => stackman}/platforms/switch_x86_gcc.S (100%) rename {src => stackman}/platforms/switch_x86_gcc.h (100%) rename {src => stackman}/platforms/switch_x86_msvc.asm (100%) rename {src => stackman}/platforms/switch_x86_msvc.h (100%) rename {src => stackman}/stackman.c (100%) rename {src => stackman}/stackman.h (100%) rename {src => stackman}/stackman_impl.h (100%) rename {src => stackman}/stackman_s.S (100%) rename {src => stackman}/stackman_s.asm (100%) rename {src => stackman}/stackman_switch.h (100%) diff --git a/Makefile b/Makefile index 14e3240..d688059 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -CPPFLAGS += -Isrc $(PLATFORMFLAGS) +CPPFLAGS += -Istackman $(PLATFORMFLAGS) CFLAGS += -fPIC -g $(PLATFORMFLAGS) CXXFLAGS += -fPIC -g $(PLATFORMFLAGS) LDFLAGS += -L$(LIB) -g $(PLATFORMFLAGS) @@ -29,7 +29,7 @@ LIB := lib/$(ABI) all: $(LIB)/libstackman.a -obj = src/stackman.o src/stackman_s.o +obj = stackman/stackman.o stackman/stackman_s.o $(LIB)/libstackman.a: lib $(obj) @@ -40,7 +40,7 @@ lib: mkdir -p $(LIB) bin clean: - rm -f src/*.o tests/*.o + rm -f stackman/*.o tests/*.o rm -f bin/* rm -rf tmp diff --git a/abiname.sh b/abiname.sh index 8894471..390d9ae 100755 --- a/abiname.sh +++ b/abiname.sh @@ -1,6 +1,6 @@ #!/bin/sh -# this script compiles and runs src/abiname.c which merely prints +# this script compiles and runs stackman/abiname.c which merely prints # out the name of the abi. This can be used by makefiles to identify # the correct library path to use to link the library # Instead of just compiling and running, we will use the provided compiler @@ -16,7 +16,7 @@ tmp=$(mktemp "${here}/tmp/abinameXXX.c") #1 create the preprocessed file CC=${1:-cc} CFLAGS=${2:-} -${CC} ${CFLAGS} -E -I "${here}/src" -o "${tmp}" "${here}/src/abiname.c" +${CC} ${CFLAGS} -E -o "${tmp}" "${here}/stackman/abiname.c" #2 compile resulting file cc -o "${tmp}.out" "${tmp}" #3 run it diff --git a/src/abiname.c b/stackman/abiname.c similarity index 100% rename from src/abiname.c rename to stackman/abiname.c diff --git a/src/extras/slp_switch.h b/stackman/extras/slp_switch.h similarity index 100% rename from src/extras/slp_switch.h rename to stackman/extras/slp_switch.h diff --git a/src/platforms/gen_asm.c b/stackman/platforms/gen_asm.c similarity index 100% rename from src/platforms/gen_asm.c rename to stackman/platforms/gen_asm.c diff --git a/src/platforms/platform.h b/stackman/platforms/platform.h similarity index 100% rename from src/platforms/platform.h rename to stackman/platforms/platform.h diff --git a/src/platforms/switch_aarch64_gcc.S b/stackman/platforms/switch_aarch64_gcc.S similarity index 100% rename from src/platforms/switch_aarch64_gcc.S rename to stackman/platforms/switch_aarch64_gcc.S diff --git a/src/platforms/switch_aarch64_gcc.h b/stackman/platforms/switch_aarch64_gcc.h similarity index 100% rename from src/platforms/switch_aarch64_gcc.h rename to stackman/platforms/switch_aarch64_gcc.h diff --git a/src/platforms/switch_arm64_msvc.asm b/stackman/platforms/switch_arm64_msvc.asm similarity index 100% rename from src/platforms/switch_arm64_msvc.asm rename to stackman/platforms/switch_arm64_msvc.asm diff --git a/src/platforms/switch_arm64_msvc.h b/stackman/platforms/switch_arm64_msvc.h similarity index 100% rename from src/platforms/switch_arm64_msvc.h rename to stackman/platforms/switch_arm64_msvc.h diff --git a/src/platforms/switch_arm_gcc.S b/stackman/platforms/switch_arm_gcc.S similarity index 100% rename from src/platforms/switch_arm_gcc.S rename to stackman/platforms/switch_arm_gcc.S diff --git a/src/platforms/switch_arm_gcc.h b/stackman/platforms/switch_arm_gcc.h similarity index 100% rename from src/platforms/switch_arm_gcc.h rename to stackman/platforms/switch_arm_gcc.h diff --git a/src/platforms/switch_arm_msvc.asm b/stackman/platforms/switch_arm_msvc.asm similarity index 100% rename from src/platforms/switch_arm_msvc.asm rename to stackman/platforms/switch_arm_msvc.asm diff --git a/src/platforms/switch_arm_msvc.h b/stackman/platforms/switch_arm_msvc.h similarity index 100% rename from src/platforms/switch_arm_msvc.h rename to stackman/platforms/switch_arm_msvc.h diff --git a/src/platforms/switch_template.h b/stackman/platforms/switch_template.h similarity index 100% rename from src/platforms/switch_template.h rename to stackman/platforms/switch_template.h diff --git a/src/platforms/switch_x64_msvc.asm b/stackman/platforms/switch_x64_msvc.asm similarity index 100% rename from src/platforms/switch_x64_msvc.asm rename to stackman/platforms/switch_x64_msvc.asm diff --git a/src/platforms/switch_x64_msvc.h b/stackman/platforms/switch_x64_msvc.h similarity index 100% rename from src/platforms/switch_x64_msvc.h rename to stackman/platforms/switch_x64_msvc.h diff --git a/src/platforms/switch_x86_64_gcc.S b/stackman/platforms/switch_x86_64_gcc.S similarity index 100% rename from src/platforms/switch_x86_64_gcc.S rename to stackman/platforms/switch_x86_64_gcc.S diff --git a/src/platforms/switch_x86_64_gcc.h b/stackman/platforms/switch_x86_64_gcc.h similarity index 100% rename from src/platforms/switch_x86_64_gcc.h rename to stackman/platforms/switch_x86_64_gcc.h diff --git a/src/platforms/switch_x86_gcc.S b/stackman/platforms/switch_x86_gcc.S similarity index 100% rename from src/platforms/switch_x86_gcc.S rename to stackman/platforms/switch_x86_gcc.S diff --git a/src/platforms/switch_x86_gcc.h b/stackman/platforms/switch_x86_gcc.h similarity index 100% rename from src/platforms/switch_x86_gcc.h rename to stackman/platforms/switch_x86_gcc.h diff --git a/src/platforms/switch_x86_msvc.asm b/stackman/platforms/switch_x86_msvc.asm similarity index 100% rename from src/platforms/switch_x86_msvc.asm rename to stackman/platforms/switch_x86_msvc.asm diff --git a/src/platforms/switch_x86_msvc.h b/stackman/platforms/switch_x86_msvc.h similarity index 100% rename from src/platforms/switch_x86_msvc.h rename to stackman/platforms/switch_x86_msvc.h diff --git a/src/stackman.c b/stackman/stackman.c similarity index 100% rename from src/stackman.c rename to stackman/stackman.c diff --git a/src/stackman.h b/stackman/stackman.h similarity index 100% rename from src/stackman.h rename to stackman/stackman.h diff --git a/src/stackman_impl.h b/stackman/stackman_impl.h similarity index 100% rename from src/stackman_impl.h rename to stackman/stackman_impl.h diff --git a/src/stackman_s.S b/stackman/stackman_s.S similarity index 100% rename from src/stackman_s.S rename to stackman/stackman_s.S diff --git a/src/stackman_s.asm b/stackman/stackman_s.asm similarity index 100% rename from src/stackman_s.asm rename to stackman/stackman_s.asm diff --git a/src/stackman_switch.h b/stackman/stackman_switch.h similarity index 100% rename from src/stackman_switch.h rename to stackman/stackman_switch.h diff --git a/vs2017/stackman/stackman.vcxproj b/vs2017/stackman/stackman.vcxproj index ef5a64e..b27234a 100644 --- a/vs2017/stackman/stackman.vcxproj +++ b/vs2017/stackman/stackman.vcxproj @@ -165,17 +165,17 @@ - - - - - - - - + + + + + + + + - + false Default @@ -199,24 +199,24 @@ - + false true true true - + Document true true true - + true true true - + true true true diff --git a/vs2017/stackman/stackman.vcxproj.filters b/vs2017/stackman/stackman.vcxproj.filters index 6db744f..9f57a1f 100644 --- a/vs2017/stackman/stackman.vcxproj.filters +++ b/vs2017/stackman/stackman.vcxproj.filters @@ -15,33 +15,33 @@ - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Source Files @@ -49,18 +49,18 @@ - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/vs2017/stackman/template.c b/vs2017/stackman/template.c index ca9b63f..2fe7dbd 100644 --- a/vs2017/stackman/template.c +++ b/vs2017/stackman/template.c @@ -1,4 +1,4 @@ -#include "..\..\src\stackman.h" +#include "..\..\stackman\stackman.h" /* * template file to create assembly code (template.asm) to modify and add to real assembler. diff --git a/vs2019/stackman/stackman.vcxproj b/vs2019/stackman/stackman.vcxproj index 1d48cb8..5a6a77a 100644 --- a/vs2019/stackman/stackman.vcxproj +++ b/vs2019/stackman/stackman.vcxproj @@ -165,17 +165,17 @@ - - - - - - - - + + + + + + + + - + false Default @@ -199,24 +199,24 @@ - + false true true true - + Document true true true - + true true true - + true true true diff --git a/vs2019/stackman/stackman.vcxproj.filters b/vs2019/stackman/stackman.vcxproj.filters index 6db744f..9f57a1f 100644 --- a/vs2019/stackman/stackman.vcxproj.filters +++ b/vs2019/stackman/stackman.vcxproj.filters @@ -15,33 +15,33 @@ - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Source Files @@ -49,18 +49,18 @@ - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/vs2019/stackman/template.c b/vs2019/stackman/template.c index ca9b63f..2fe7dbd 100644 --- a/vs2019/stackman/template.c +++ b/vs2019/stackman/template.c @@ -1,4 +1,4 @@ -#include "..\..\src\stackman.h" +#include "..\..\stackman\stackman.h" /* * template file to create assembly code (template.asm) to modify and add to real assembler. From 4a96e0f8197ad8cbd9e22ffaab59ce910d92a755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 6 Apr 2021 22:41:44 +0000 Subject: [PATCH 053/115] Add workflow --- .github/workflows/test.yml | 74 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2c64813 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,74 @@ +name: C/C++ CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test-amd64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: make + run: make && make test + + test-linux-x86: + runs-on: ubuntu-latest + strategy: + matrix: + platformflags: ["", "-m32"] + env: + PLATFORMFLAGS: ${{platformflags}} + steps: + - uses: actions/checkout@v2 + - name: install multilib + run: sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib + - name: make + run: make && make test + + test-linux-arm: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - arch: arm + emulator: qemu-arm + abi: arm-linux-gnueabi + - arch: aarch64 + emulator: qemu-aarch64 + abi: aarch64-linux-gnu + env: + PLATFORM_PREFIX: ${{matrix.abi}}- + EMULATOR: ${{matrix.emulator}} + steps: + - uses: actions/checkout@v2 + - name: install qemu + run: sudo apt-get install --no-install-recommends -y qemu-user + - name: install abi lib + run: sudo apt-get install --no-install-recommends -y gcc-${{matrix.abi}} g++-${{matrix.abi}} + - name: make + run: make && make test + + test-windows: + runs-on: windows-2019 + strategy: + matrix: + platform: [x86, x64, ARM, ARM64] + include: + - platform: x86 + folder: Win32 + native: yes + - platform: x64 + folder: x64 + native: yes + steps: + - uses: actions/checkout@v2 + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.2 + - name: build + run: msbuild.exe vs2019\stackman.sln /p:Platform=${{matrix.platform}} + - name: test + if: ${{ matrix.native == 'yes' }} + run: vs2019\${{matrix.folder}}\Debug\test.exe From 34e56103ee6bd65f073cb7d90cd3d2166f243f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 6 Apr 2021 22:42:12 +0000 Subject: [PATCH 054/115] Fix documentation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ec09feb..30c1706 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ platforms as they come along. ## Cross-compilation Linux on x86-64 can be used to cross compile for x86 and ARM targets. This is most useful to generate assembly code, e.g. when compiling -src/platform/gen_asm.c +stackman/platform/gen_asm.c - x86 requires the -m32 flag to compilers and linkers. - arm32 requires to use the arm-linux-gnueabi-* tools, including cc and linker - aarch64 requires the aarch64-linux-gnu-* tools. @@ -138,4 +138,4 @@ platforms may need to be done independently. - install **gcc-aarch64-linux-gnu** and **g++-aarch64-linux-gnu** - install __qemu-user__ for hardware emulation - *compile* using `aarch64-linux-gnu-gcc` - - *make* using `make PLATFORM_PREFIX=aarch64-linux-gnu- EMULATOR=qemu-arm64 test` + - *make* using `make PLATFORM_PREFIX=aarch64-linux-gnu- EMULATOR=qemu-aarch64 test` From c917cd8f619b156b5b7d7d7f0b384c1649388a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 6 Apr 2021 22:45:01 +0000 Subject: [PATCH 055/115] Remove travis, migrating to GH Actions. --- .travis.yml | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 18997f7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -language: c -dist: bionic -script: make && make test -jobs: - include: - - name: x86_64_gcc - - name: x86_gcc - before_install: sudo apt install -y gcc-multilib g++-multilib - env: PLATFORMFLAGS=-m32 - - arch: arm64 - - name: arm32_xcompile - before_install: - - sudo apt update - - sudo apt install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi - - sudo apt install -y qemu-user - env: - - PLATFORM_PREFIX=arm-linux-gnueabi- - - EMULATOR=qemu-arm - - os: windows - name: x64_msvc - script: - - cd vs2017 - - ./build.cmd x64 && x64/Debug/test.exe - - os: windows - name: x86_msvc - script: - - cd vs2017 - - ./build.cmd x86 && Win32/Debug/test.exe - - os: windows - name: arm_msvc - before_install: choco install --force VisualStudio2017-workload-vctools --params"--add Microsoft.VisualStudio.Component.VC.Tools.ARM" - script: - - cd vs2017 - - ./build.cmd ARM - - os: windows - name: arm64_msvc - before_install: choco install --force VisualStudio2017-workload-vctools --params"--add Microsoft.VisualStudio.Component.VC.Tools.ARM64" - script: - - cd vs2017 - - ./build.cmd ARM64 \ No newline at end of file From 4da83cd36c97c6a58a6866c16d10d17875fe9a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 6 Apr 2021 22:58:23 +0000 Subject: [PATCH 056/115] Fix workflow --- .github/workflows/test.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c64813..026130b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,20 +7,19 @@ on: branches: [ master ] jobs: - test-amd64: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: make - run: make && make test - + test-linux-x86: runs-on: ubuntu-latest strategy: matrix: - platformflags: ["", "-m32"] + include: + - platformflags: "" + name: "AMD64" + - platformflags: -m32 + name: "i386" + name: test-linux-x86 (${{matrix.name}}) env: - PLATFORMFLAGS: ${{platformflags}} + PLATFORMFLAGS: ${{matrix.platformflags}} steps: - uses: actions/checkout@v2 - name: install multilib @@ -39,6 +38,7 @@ jobs: - arch: aarch64 emulator: qemu-aarch64 abi: aarch64-linux-gnu + name: test-linux-arm (${{matrix.arch}}) env: PLATFORM_PREFIX: ${{matrix.abi}}- EMULATOR: ${{matrix.emulator}} From 518aff7b712d87cb49ced4433db2f8437be86a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 6 Apr 2021 23:17:59 +0000 Subject: [PATCH 057/115] Fix include path on windows --- vs2017/test/test.vcxproj | 8 ++++---- vs2019/test/test.vcxproj | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/vs2017/test/test.vcxproj b/vs2017/test/test.vcxproj index 9a03733..9d14c4b 100644 --- a/vs2017/test/test.vcxproj +++ b/vs2017/test/test.vcxproj @@ -88,7 +88,7 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\src + ..\..\stackman Console @@ -104,7 +104,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\src + ..\..\stackman Console @@ -119,7 +119,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\src + ..\..\stackman Console @@ -134,7 +134,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\src + ..\..\stackman Console diff --git a/vs2019/test/test.vcxproj b/vs2019/test/test.vcxproj index 2559e40..93dc2cf 100644 --- a/vs2019/test/test.vcxproj +++ b/vs2019/test/test.vcxproj @@ -88,7 +88,7 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\src + ..\..\stackman Console @@ -104,7 +104,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\src + ..\..\stackman Console @@ -119,7 +119,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\src + ..\..\stackman Console @@ -134,7 +134,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - ..\..\src + ..\..\stackman Console From 2fbe1a75722d0efe01243178a4d994b2a3825c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Wed, 7 Apr 2021 13:45:36 +0000 Subject: [PATCH 058/115] update line ending attributes --- .gitattributes | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index 3340c6f..85dd98f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,23 @@ # use unix lf line ending for everything except windows bat files * text=auto eol=lf -*.asm text eol=lf -*.h text eol=lf -*.{cmd,[cC][mM][dD]} text eol=crlf -*.{bat,[bB][aA][tT]} text eol=crlf + +# libraries are bin +*.o binary +*.obj binary +*.a binary +*.so binary +*.lib binary +*.dll binary +*.pdb binary + + +# source files explicitly +*.{c,h,asm,S} text eol=lf + +*.cmd text eol=crlf +*.bat text eol=crlf + +# Visulal studio is happier with crlf +*.sln text eol=crlf +*.vcxproj text eol=crlf +*.vcxproj.filters text eol=crlf From e7878f9ebc21f50b19aba3937d2aadecc3d8b683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 16:00:13 +0000 Subject: [PATCH 059/115] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 026130b..45a401b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: C/C++ CI on: push: - branches: [ master ] + branches: [ master, dev ] pull_request: branches: [ master ] From 82d424ed6e13abb4223d3b66e981138aa350b819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 13:59:38 +0000 Subject: [PATCH 060/115] Update documentation --- README.md | 102 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 74 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 30c1706..1ff9766 100644 --- a/README.md +++ b/README.md @@ -30,16 +30,13 @@ platforms so that no assembly steps are required by users. ## Features - Simple api - - `stackman_switch()` is the main function. + - `stackman_switch()` and `stackman_call()` are the only functions. - The caller provides a callback and context pointer to customize behaviour. - - The callback can save the stack and provide the new stack pointer. - - After the switch, the callback can restore contents of new stack. - - Application behaviour is entirely defined by the callback. -- Simple implementation + Simple implementation - The code involving assembly is as simple as possible, allowing for straightforward implementation on most platforms. - Complex logic and branching is delegated to the C callback. - - Custom platform code must only do three things: + - Custom platform assembly code must only do three things: 1. Save and restore volatile registers and stack state on the stack 2. Call the callback twice with the current stack pointer 3. Set the stack pointer to the value returned by the first callback. @@ -62,6 +59,7 @@ standardizing the api. A number of ABI specifications is supported, meaning arc calling convention, plus archive format: - win_x86 (32 bits) - win_x64 + - win_ARM64 (experimental) - sysv_i386 (linux) - sysv_amd64 (linux) - AAPCS (32 bit arm) @@ -75,13 +73,46 @@ Supported toolchains: Other platforms can be easily adapted from both existing implementations for other projects as well as from example code provided. -### Intel CET -Intel's Conontrol-Flow Enforcement Technology is incompatible with stack switching -because it imploys a secondary Shadow Stack, that the user-mode program cannot -modify. Unexpected return flow after a stack switch would cause the processor -to fault. Because of this, we need to mark any assembly code as not CET compatible. Modern compilers are beginning to generate CET compatible objects and -once supporting CPUs start to arrive, processes which consist entirely of CET compatible code may be run in such a protected environment. See https://software.intel.com/content/www/us/en/develop/articles/technical-look-control-flow-enforcement-technology.html for more information - +## API +There are two functions that make up the stackman library: `stakman_switch()` and `stackman_call()` who +both take a `stackman_cb_t` callback: +```C +typedef void *(*stackman_cb_t)( + void *context, int opcode, void *stack_pointer); +void *stackman_switch(stackman_cb_t callback, void *context); +void *stackman_call(stackman_cb_t callback, void *context, void *stack); +``` +### stackman_switch() +This is the main _stack manipulation_ API. When called, it will call `callback` function twice: +1. First it calls it with the current opcode `STACKMAN_OP_SAVE`, passing the current `stack_pointer` to +the callback. This gives the callback the opportunity to _save_ the stack data somewhere. The callback +can then return a **different** stack pointer. +2. It takes the returned value from the calback and replaces the CPU _stack pointer_ with it. +3. It calls the callback a second time, with the opcode `STACKMAN_OP_RESTORE` and the new stack pointer. +This gives the callback the opportunity to replace the data on the stack with previously saved data. +4. It returns the return value from the second call to the callback function. + +The `context` pointer is passed as-is to the callback, allowing it access to user-defined data. + +Depending on how the callback function is implemented, this API can be used for a number of things, like +saving a copy of the stack, perform a stack switch, query the stack pointer, and so on. + +### stackman_call() +This is a helper function to call a callback function, optionally providing it with a different stack to +use. +1. It saves the current CPU stack pointer. If `stack` is non-zero, it will replace the stackpointer +with that value. +2. It calls the callback function with the opcode `STACKMAN_OP_CALL`. +3. It replaces the stack pointer with the previously saved value and returns the return value from the callback. + +This function is useful for at least three things: +- To move the call chain into a custom stack area, some heap-allocated block, for example. +- To query the current stack pointer +- To enforce an actual function call with stack pointer information. + +The last feature is useful to bypass any in-lining that a compiler may do, when one really wants +a proper function call with stack, for example, when setting up a new stack entry point. + ## Usage - Include `stackman.h` for a decleration of the `stackman_switch()` function and the definition of various platform specific macros. See the documentation @@ -100,19 +131,15 @@ There are two basic ways to add the library to your project: In the case of inlined code, it can be specified to prefer in-line assembly and static linkage over separate assembly language source. -## History -This works was originally inspired by *Stackless Python* by [Christian Tismer](https://github.com/ctismer), where the original switching code was -developed. - -Later projects, like *gevent/greenlet* have taken that idea and provided additional platform compatibility but -with a different implementation, making the switching code itself incompatible. - -Our work on additional stack-manipulating libraries prompted us to try to distill this functionality in its -rawest form into a separate, low-level, library. Such that any project, wishing to implement *co-routine*-like -behaviour on the C-stack level, could make use of simple, stable code, that can be easily extended for additional -platforms as they come along. +## Development +### Adding new platforms +1. Modify `platform.h` to identif the platform environment. Define an ABI name and + include custom header files. +2. Use the `switch_template.h` to help build a `switch_ABI.h` file for your ABI. +3. Provide an assembler version, `switch_ABI.S` by compiling the `gen_asm.c` file for your platform. +4. Provide cross-compilation tools for linux if possible, by modifying the `Makefile` -## Cross-compilation +### Cross-compilation Linux on x86-64 can be used to cross compile for x86 and ARM targets. This is most useful to generate assembly code, e.g. when compiling stackman/platform/gen_asm.c - x86 requires the -m32 flag to compilers and linkers. @@ -123,19 +150,38 @@ The x86 tools require the **gcc-multilib** and **g++-multilib** packages to be i **gcc-aarch64-linux-gnu** packages on some distributions, and so development for these platforms may need to be done independently. -### Cross compiling for x86 (32 bit) on Linux +#### Cross compiling for x86 (32 bit) on Linux - install __gcc-multilib__ and __g++-multilib__ - *compile* **gen_asm.c** using `gcc -m32` - *make* using `make PLATFORMFLAGS=-m32 test` -### Cross compiling for ARM (32 bit) on Linux +#### Cross compiling for ARM (32 bit) on Linux - install __gcc-arm-linux-gnueabi__ and __g++-arm-linux-gnueabi__ - install __qemu-user__ for hardware emulation - *compile* **gen_asm.c** using `arm-linux-gnueabi-gcc` - *make* using `make PLATFORM_PREFIX=arm-linux-gnueabi- EMULATOR=qemu-arm test` -### Cross compiling for Arm64 on Linux +#### Cross compiling for Arm64 on Linux - install **gcc-aarch64-linux-gnu** and **g++-aarch64-linux-gnu** - install __qemu-user__ for hardware emulation - *compile* using `aarch64-linux-gnu-gcc` - *make* using `make PLATFORM_PREFIX=aarch64-linux-gnu- EMULATOR=qemu-aarch64 test` + +## A note about Intel CET +Intel's Conontrol-Flow Enforcement Technology is incompatible with stack switching +because it imploys a secondary Shadow Stack, that the user-mode program cannot +modify. Unexpected return flow after a stack switch would cause the processor +to fault. Because of this, we need to mark any assembly code as not CET compatible. Modern compilers are beginning to generate CET compatible objects and +once supporting CPUs start to arrive, processes which consist entirely of CET compatible code may be run in such a protected environment. See https://software.intel.com/content/www/us/en/develop/articles/technical-look-control-flow-enforcement-technology.html for more information + +## History +This works was originally inspired by *Stackless Python* by [Christian Tismer](https://github.com/ctismer), where the original switching code was +developed. + +Later projects, like *gevent/greenlet* have taken that idea and provided additional platform compatibility but +with a different implementation, making the switching code itself incompatible. + +Our work on additional stack-manipulating libraries prompted us to try to distill this functionality in its +rawest form into a separate, low-level, library. Such that any project, wishing to implement *co-routine*-like +behaviour on the C-stack level, could make use of simple, stable code, that can be easily extended for additional +platforms as they come along. \ No newline at end of file From 89dc67c311fb0c9513e5a15440a2b10d69d5741f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 17:00:01 +0000 Subject: [PATCH 061/115] Add test case for calling stackman_call() with null pointer --- tests/test.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/test.c b/tests/test.c index 6ed3cb0..e6b726e 100644 --- a/tests/test.c +++ b/tests/test.c @@ -206,6 +206,8 @@ void *test_04_cb(void* context, int _opcode, void *old_sp) c->sp[1] = old_sp; return 0; } + +/* test stackman_call() with a non-null stack pointer */ void test_04(void) { char *block, *stack, *stack2; @@ -247,15 +249,32 @@ void test_04(void) for(i=0; i<64; i++) cnt += stack2[-i] == '\x7f'; assert(cnt != 64); +} + +/* test stackman_call() with a null stack pointer */ +void test_05(void) +{ + char *block, *stack, *stack2; + int i, cnt; + ctxt01 ctxt; + + assert(STACKMAN_STACK_FULL_DESCENDING); + /* perform the call */ + stackman_call(test_04_cb, &ctxt, 0); + /* verify that it was passed a stack */ + assert(ctxt.sp[1]); + assert(STACKMAN_SP_LE(ctxt.sp[0], ctxt.sp[1])); + /* and that it was passed valid lower stack pointer */ + assert(STACKMAN_SP_LE(ctxt.sp[1], &ctxt)); } #endif /* Test our various macros */ -void test_05() +void test_06() { int local=0; @@ -286,8 +305,10 @@ int main(int argc, char*argv[]) #ifdef TEST_04 test_04(); printf("test_04 ok\n"); -#endif test_05(); printf("test_05 ok\n"); +#endif + test_06(); + printf("test_06 ok\n"); return 0; } From 9c8b64a21b8e0509ca69d4d6057a0655e50bd8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 17:01:05 +0000 Subject: [PATCH 062/115] Add stackman_call to switch_template.h --- stackman/platforms/switch_template.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/stackman/platforms/switch_template.h b/stackman/platforms/switch_template.h index d3f11d4..149209f 100644 --- a/stackman/platforms/switch_template.h +++ b/stackman/platforms/switch_template.h @@ -44,6 +44,25 @@ void *STACKMAN_SWITCH_INASM_NAME(stackman_cb_t callback, void *context) /* __asm__("pop volatile registers") */ return stack_pointer; } + +STACKMAN_LINKAGE_SWITCH +void *stackman_call(stackman_cb_t callback, void *context, void *stack_pointer) +{ + void *old_sp, *result; + /* sp = store stack pointer in rbx */ + /*__asm__ ("movq %%rsp, %%rbx" : : : "rbx");*/ + /*__asm__ ("movq %%rsp, %[sp]" : [sp] "=r" (old_sp));*/ + + /* if non-null, set stack pointer as provided using assembly */ + if (stack_pointer != 0) + /*__asm__ ("movq %[sp], %%rsp" :: [sp] "r" (stack_pointer))*/; + + result = callback(context, STACKMAN_OP_CALL, old_sp); + /* restore stack pointer */ + /*__asm__ ("movq %%rbx, %%rsp" :::); */ + + return result; +} #endif #if __ASSEMBLER__ && defined(STACKMAN_ASSEMBLY_SRC) From 182c35b85e38041aff549a1eeedc4b2f8bf7b8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 17:01:32 +0000 Subject: [PATCH 063/115] stackman_call-nullptr for x64-linux --- stackman/platforms/switch_x86_64_gcc.S | 11 ++++++++--- stackman/platforms/switch_x86_64_gcc.h | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/stackman/platforms/switch_x86_64_gcc.S b/stackman/platforms/switch_x86_64_gcc.S index 02304df..aca7168 100644 --- a/stackman/platforms/switch_x86_64_gcc.S +++ b/stackman/platforms/switch_x86_64_gcc.S @@ -116,15 +116,20 @@ stackman_call: # 93 "../platforms/switch_x86_64_gcc.h" 1 movq %rsp, %rcx # 0 "" 2 -# 96 "../platforms/switch_x86_64_gcc.h" 1 +#NO_APP + testq %rdx, %rdx + je .L4 +#APP +# 97 "../platforms/switch_x86_64_gcc.h" 1 movq %rdx, %rsp # 0 "" 2 #NO_APP +.L4: movq %rcx, %rdx movl $2, %esi call *%rax #APP -# 100 "../platforms/switch_x86_64_gcc.h" 1 +# 101 "../platforms/switch_x86_64_gcc.h" 1 movq %rbx, %rsp # 0 "" 2 #NO_APP @@ -136,5 +141,5 @@ stackman_call: .cfi_endproc .LFE1: .size stackman_call, .-stackman_call - .ident "GCC: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0" + .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" .section .note.GNU-stack,"",@progbits diff --git a/stackman/platforms/switch_x86_64_gcc.h b/stackman/platforms/switch_x86_64_gcc.h index a958f93..50f566a 100644 --- a/stackman/platforms/switch_x86_64_gcc.h +++ b/stackman/platforms/switch_x86_64_gcc.h @@ -93,7 +93,8 @@ void *stackman_call(stackman_cb_t callback, void *context, void *stack_pointer) __asm__ ("movq %%rsp, %[sp]" : [sp] "=r" (old_sp)); /* set stack pointer from provided using assembly */ - __asm__ ("movq %[sp], %%rsp" :: [sp] "r" (stack_pointer)); + if (stack_pointer != 0) + __asm__ ("movq %[sp], %%rsp" :: [sp] "r" (stack_pointer)); result = callback(context, STACKMAN_OP_CALL, old_sp); /* restore stack pointer */ From 65eb17cd7d0d3344ae1e9dd833cea001a1473dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 17:05:39 +0000 Subject: [PATCH 064/115] disable fail-fast on matrix jobs --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 45a401b..2086164 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,7 @@ jobs: test-linux-x86: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: include: - platformflags: "" @@ -24,12 +25,14 @@ jobs: - uses: actions/checkout@v2 - name: install multilib run: sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib + if: ${{ matrix.name == 'i386' }} - name: make run: make && make test test-linux-arm: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: include: - arch: arm @@ -54,6 +57,7 @@ jobs: test-windows: runs-on: windows-2019 strategy: + fail-fast: false matrix: platform: [x86, x64, ARM, ARM64] include: @@ -72,3 +76,4 @@ jobs: - name: test if: ${{ matrix.native == 'yes' }} run: vs2019\${{matrix.folder}}\Debug\test.exe + From 71e02069e3212b24f64e52008a4c88f5154a4280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 17:43:08 +0000 Subject: [PATCH 065/115] add zero-stack arg support for linux x86 --- lib/sysv_amd64/libstackman.a | Bin 3766 -> 3838 bytes lib/sysv_i386/libstackman.a | Bin 2702 -> 2774 bytes stackman/platforms/gen_asm.c | 2 +- stackman/platforms/switch_x86_gcc.S | 25 +++++++++++++------------ stackman/platforms/switch_x86_gcc.h | 17 ++++++++++++----- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/sysv_amd64/libstackman.a b/lib/sysv_amd64/libstackman.a index 6d668b6f96772901441cc24e4d79ec1fc2786a29..242351971c987a86d26aca3ceeef286a659c8cc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Z`s|9m2ri?(A%(pb@H?RGL>(3UZB}fv%x>DVS?mXJnvfV4?{T2Ks3- zKa2R}ee7?K_G5s&)`5(&Bd8a$}&&k6u2N8D9 zWLx$?L3N<37##UHTA7@9SzVf$<0sE&pUKme1W(d1QZ8jLIxPs?-hGB7ak!~%(&iC-cZnI`)(s&c#g zg(^538Y-CUnNFU_s5ki|qnHvyaZ$2iC@;_Dq#)8TGZ0d{#lg)u-$>eyp+X5V& zk9%EISh_<6IVyoC2)NfjYG&Uk1ut1dH);od5up CK3uf` diff --git a/stackman/platforms/gen_asm.c b/stackman/platforms/gen_asm.c index 9858b27..bd5785a 100644 --- a/stackman/platforms/gen_asm.c +++ b/stackman/platforms/gen_asm.c @@ -2,7 +2,7 @@ * of assembly code under e.g. Gcc. * use by calling, for example: * cc -S -m32 -fcf-protection=none gen_asm.c - * and examinine the generated test.s assembly code. + * and examinine the generated gen_asm.s assembly code. * -m32 selects 32 bit mode, use other directives to select a different platform. * The -fcf-protection flag disables generation of intel CET compatible code, but stack switching * is not compatible with the proposed shadow stack. Only the latest compilers have it. diff --git a/stackman/platforms/switch_x86_gcc.S b/stackman/platforms/switch_x86_gcc.S index fc4689f..671a6b5 100644 --- a/stackman/platforms/switch_x86_gcc.S +++ b/stackman/platforms/switch_x86_gcc.S @@ -76,31 +76,32 @@ stackman_call: movl %esp, %ebp .cfi_def_cfa_register 5 pushl %ebx - subl $8, %esp + subl $4, %esp .cfi_offset 3, -12 + movl 16(%ebp), %eax #APP # 108 "../platforms/switch_x86_gcc.h" 1 movl %esp, %ebx # 0 "" 2 -# 110 "../platforms/switch_x86_gcc.h" 1 - leal 4(%esp), %eax +# 111 "../platforms/switch_x86_gcc.h" 1 + movl %esp, %edx # 0 "" 2 #NO_APP - movl 16(%ebp), %edx + testl %eax, %eax + je .L4 #APP -# 113 "../platforms/switch_x86_gcc.h" 1 - movl %edx, %esp -# 0 "" 2 -# 115 "../platforms/switch_x86_gcc.h" 1 - subl $4, %esp +# 117 "../platforms/switch_x86_gcc.h" 1 + movl %eax, %esp # 0 "" 2 #NO_APP - pushl %eax +.L4: + subl $4, %esp + pushl %edx pushl $2 pushl 12(%ebp) call *8(%ebp) #APP -# 119 "../platforms/switch_x86_gcc.h" 1 +# 124 "../platforms/switch_x86_gcc.h" 1 movl %ebx, %esp # 0 "" 2 #NO_APP @@ -113,5 +114,5 @@ stackman_call: .cfi_endproc .LFE1: .size stackman_call, .-stackman_call - .ident "GCC: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0" + .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" .section .note.GNU-stack,"",@progbits diff --git a/stackman/platforms/switch_x86_gcc.h b/stackman/platforms/switch_x86_gcc.h index 1a1635c..38fbee8 100644 --- a/stackman/platforms/switch_x86_gcc.h +++ b/stackman/platforms/switch_x86_gcc.h @@ -107,12 +107,19 @@ void *stackman_call(stackman_cb_t callback, void *context, void *stack_pointer) /* sp = store stack pointer in ebx */ __asm__ ("movl %%esp, %%ebx" : : : "ebx"); /* save old stack pointer at same offset as new stack pointer */ - __asm__ ("leal 4(%%esp), %[sp]" : [sp] "=r" (old_sp)); - + /* (adjustment of stack pointer not required now) + /*__asm__ ("leal 4(%%esp), %[sp]" : [sp] "=r" (old_sp)); */ + __asm__ ("movl %%esp, %[sp]" : [sp] "=r" (old_sp)); + + /* set stack pointer from provided using assembly */ - __asm__ ("movl %[sp], %%esp" :: [sp] "r" (stack_pointer)); - /* subtract 4 bytes to make it 16 byte alighed after pushing 3 args */ - __asm__ ("subl $4, %esp"); + if (stack_pointer != 0) + { + __asm__ ("movl %[sp], %%esp" :: [sp] "r" (stack_pointer)); + /* subtract 4 bytes to make it 16 byte alighed after pushing 3 args */ + /* (adjustment of stack pointer not required now) + /* __asm__ ("subl $4, %esp"); */ + } result = callback(context, STACKMAN_OP_CALL, old_sp); /* restore stack pointer */ From 1c3cfc1a2085a12d958e078137c76cd1090eecc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 17:58:16 +0000 Subject: [PATCH 066/115] add nullptr support for x86 msvc --- stackman/platforms/switch_x86_msvc.asm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stackman/platforms/switch_x86_msvc.asm b/stackman/platforms/switch_x86_msvc.asm index 1884987..2f28cf9 100644 --- a/stackman/platforms/switch_x86_msvc.asm +++ b/stackman/platforms/switch_x86_msvc.asm @@ -50,7 +50,10 @@ stackman_call PROC callback:DWORD, context:DWORD, stack_pointer:DWORD mov edx, stack_pointer ; switch stack pointer + test edx, edx + je nullptr mov esp, stack_pointer +nullptr: push ebp ;old stack pointer push 2 ;STACKMAN_OP_CALL push ecx ;context From dc8cd2e408254e1bd67aba916b233b484aa4dec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 18:07:22 +0000 Subject: [PATCH 067/115] add nullptr support for stackman_call, msvc-amd64 --- stackman/platforms/switch_x64_msvc.asm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stackman/platforms/switch_x64_msvc.asm b/stackman/platforms/switch_x64_msvc.asm index f2351af..5143276 100644 --- a/stackman/platforms/switch_x64_msvc.asm +++ b/stackman/platforms/switch_x64_msvc.asm @@ -122,7 +122,10 @@ stackman_call PROC FRAME ; rcx already set up with context ; modify stack pointer before call + test r9, r9 + je nullptr mov rsp, r9 +nullptr: sub rsp, 32 ;pre-allocate parameter stack for the callee call rax From 0da13232845aa4a3d12ae5fe5829cb9c56118063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 18:15:26 +0000 Subject: [PATCH 068/115] stackman_call nullptr support for ARM --- stackman/platforms/switch_arm_gcc.S | 28 +++++++++++++++++----------- stackman/platforms/switch_arm_gcc.h | 3 ++- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/stackman/platforms/switch_arm_gcc.S b/stackman/platforms/switch_arm_gcc.S index a10b063..8e11645 100644 --- a/stackman/platforms/switch_arm_gcc.S +++ b/stackman/platforms/switch_arm_gcc.S @@ -32,7 +32,7 @@ stackman_switch: mov r3, r0 mov r0, r1 .syntax divided -@ 82 "switch_arm_gcc.h" 1 +@ 84 "../platforms/switch_arm_gcc.h" 1 mov r2, sp @ 0 "" 2 .arm @@ -43,7 +43,7 @@ stackman_switch: blx r3 mov r2, r0 .syntax divided -@ 86 "switch_arm_gcc.h" 1 +@ 88 "../platforms/switch_arm_gcc.h" 1 mov sp, r0 @ 0 "" 2 .arm @@ -64,30 +64,36 @@ stackman_call: @ frame_needed = 1, uses_anonymous_args = 0 push {r4, r5, fp, lr} add fp, sp, #12 - mov r3, r0 + mov r5, r0 mov r0, r1 - mov r1, r2 + mov r3, r2 .syntax divided -@ 102 "switch_arm_gcc.h" 1 +@ 104 "../platforms/switch_arm_gcc.h" 1 mov r4, sp @ 0 "" 2 -@ 103 "switch_arm_gcc.h" 1 +@ 105 "../platforms/switch_arm_gcc.h" 1 mov r2, sp @ 0 "" 2 -@ 106 "switch_arm_gcc.h" 1 - mov sp, r1 + .arm + .syntax unified + cmp r3, #0 + beq .L4 + .syntax divided +@ 109 "../platforms/switch_arm_gcc.h" 1 + mov sp, r3 @ 0 "" 2 .arm .syntax unified +.L4: mov r1, #2 - blx r3 + blx r5 .syntax divided -@ 110 "switch_arm_gcc.h" 1 +@ 113 "../platforms/switch_arm_gcc.h" 1 mov sp, r4 @ 0 "" 2 .arm .syntax unified pop {r4, r5, fp, pc} .size stackman_call, .-stackman_call - .ident "GCC: (Ubuntu 9.3.0-10ubuntu1) 9.3.0" + .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" .section .note.GNU-stack,"",%progbits diff --git a/stackman/platforms/switch_arm_gcc.h b/stackman/platforms/switch_arm_gcc.h index 1dafafb..5fd867c 100644 --- a/stackman/platforms/switch_arm_gcc.h +++ b/stackman/platforms/switch_arm_gcc.h @@ -105,7 +105,8 @@ void *stackman_call(stackman_cb_t callback, void *context, void *stack_pointer) __asm__ ("mov %[var], sp" : [var] "=r" (old_sp)); /* set stack pointer from provided using assembly */ - __asm__ ("mov sp, %[var]" :: [var] "r" (stack_pointer)); + if (stack_pointer != 0) + __asm__ ("mov sp, %[var]" :: [var] "r" (stack_pointer)); result = callback(context, STACKMAN_OP_CALL, old_sp); /* restore stack pointer */ From 9f60afd3a153073b3c60d211a009c3fdeebd8f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 18:18:49 +0000 Subject: [PATCH 069/115] stackman_call nullptr support for AARCH64 --- stackman/platforms/switch_aarch64_gcc.S | 26 ++++++++++++++----------- stackman/platforms/switch_aarch64_gcc.h | 3 ++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/stackman/platforms/switch_aarch64_gcc.S b/stackman/platforms/switch_aarch64_gcc.S index 642ec58..5b0406a 100644 --- a/stackman/platforms/switch_aarch64_gcc.S +++ b/stackman/platforms/switch_aarch64_gcc.S @@ -53,7 +53,7 @@ stackman_switch: mov x3, x0 mov x0, x1 #APP -// 57 "switch_aarch64_gcc.h" 1 +// 59 "../platforms/switch_aarch64_gcc.h" 1 mov x2, sp // 0 "" 2 #NO_APP @@ -63,7 +63,7 @@ stackman_switch: blr x3 mov x2, x0 #APP -// 61 "switch_aarch64_gcc.h" 1 +// 63 "../platforms/switch_aarch64_gcc.h" 1 mov sp, x0 // 0 "" 2 #NO_APP @@ -118,24 +118,28 @@ stackman_call: mov x29, sp str x19, [sp, 16] .cfi_offset 19, -16 - mov x3, x0 + mov x4, x0 mov x0, x1 - mov x1, x2 + mov x3, x2 #APP -// 77 "switch_aarch64_gcc.h" 1 +// 78 "../platforms/switch_aarch64_gcc.h" 1 mov x19, sp // 0 "" 2 -// 78 "switch_aarch64_gcc.h" 1 +// 79 "../platforms/switch_aarch64_gcc.h" 1 mov x2, sp // 0 "" 2 -// 82 "switch_aarch64_gcc.h" 1 - mov sp, x1 +#NO_APP + cbz x3, .L4 +#APP +// 84 "../platforms/switch_aarch64_gcc.h" 1 + mov sp, x3 // 0 "" 2 #NO_APP +.L4: mov w1, 2 - blr x3 + blr x4 #APP -// 86 "switch_aarch64_gcc.h" 1 +// 88 "../platforms/switch_aarch64_gcc.h" 1 mov sp, x19 // 0 "" 2 #NO_APP @@ -149,5 +153,5 @@ stackman_call: .cfi_endproc .LFE1: .size stackman_call, .-stackman_call - .ident "GCC: (Ubuntu 9.3.0-10ubuntu1) 9.3.0" + .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" .section .note.GNU-stack,"",@progbits diff --git a/stackman/platforms/switch_aarch64_gcc.h b/stackman/platforms/switch_aarch64_gcc.h index b6e7739..87d2a45 100644 --- a/stackman/platforms/switch_aarch64_gcc.h +++ b/stackman/platforms/switch_aarch64_gcc.h @@ -80,7 +80,8 @@ void *stackman_call(stackman_cb_t callback, void *context, void *stack_pointer) /* set stack pointer from provided using assembly */ - __asm__ ("mov sp, %[var]" :: [var] "r" (stack_pointer)); + if(stack_pointer != 0) + __asm__ ("mov sp, %[var]" :: [var] "r" (stack_pointer)); result = callback(context, STACKMAN_OP_CALL, old_sp); /* restore stack pointer */ From aab9dc57597cb088dddaa213da9ca489ca6eb393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 18:32:27 +0000 Subject: [PATCH 070/115] Add stackman_call() nullptr support for msvc arm/aarch64 --- stackman/platforms/switch_arm64_msvc.asm | 9 ++++++--- stackman/platforms/switch_arm_msvc.asm | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/stackman/platforms/switch_arm64_msvc.asm b/stackman/platforms/switch_arm64_msvc.asm index 3095592..b4b1f13 100644 --- a/stackman/platforms/switch_arm64_msvc.asm +++ b/stackman/platforms/switch_arm64_msvc.asm @@ -83,12 +83,15 @@ mov x1, x2 ;stack ; store current sp in nv register mov x18, sp - mov x2, sp ; new stack - ; change stack + mov x2, sp ; old stack + + ; change stack, if provided non-zero + cbz x1, nullptr mov sp, x1 +nullptr mov x1, #2 ; callback opcode - blr x3 ; call callback, with context, opcode, new stack + blr x3 ; call callback, with context, opcode, old stack ; restore stack (could do: sub sp, fp #12) mov sp, x18 diff --git a/stackman/platforms/switch_arm_msvc.asm b/stackman/platforms/switch_arm_msvc.asm index 84fa732..f002dfa 100644 --- a/stackman/platforms/switch_arm_msvc.asm +++ b/stackman/platforms/switch_arm_msvc.asm @@ -54,12 +54,15 @@ mov r1, r2 ;stack ; store current sp in nv register mov r4, sp - mov r2, sp ; new stack + mov r2, sp ; old stack - ; change stack + ; change stack if non-zero + cmp r1, #0 + beq nullptr mov sp, r1 +nullptr mov r1, #2 ; callback opcode - blx r3 ; call callback, with context, opcode, new stack + blx r3 ; call callback, with context, opcode, old stack ; restore stack (could do: sub sp, fp #12) mov sp, r4 ; return From 71bf16d9f88e5d0b0d4043506253a8f18d163349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 19:17:26 +0000 Subject: [PATCH 071/115] Ad build workflow --- .github/workflows/buildcommit.yml | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/buildcommit.yml diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml new file mode 100644 index 0000000..1d2e568 --- /dev/null +++ b/.github/workflows/buildcommit.yml @@ -0,0 +1,88 @@ +name: build and commit + +on: + push: + branches: [ master, dev ] + + workflow_dispatch: + +jobs: + + build-linux-x86: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - platformflags: "" + name: "AMD64" + - platformflags: -m32 + name: "i386" + name: test-linux-x86 (${{matrix.name}}) + env: + PLATFORMFLAGS: ${{matrix.platformflags}} + steps: + - uses: actions/checkout@v2 + - name: install multilib + run: sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib + if: ${{ matrix.name == 'i386' }} + - name: make + run: make all + - name: Commit libraries + run: | + git config --global user.name 'Build Runner' + git config --global user.email 'buildrunner@users.noreply.github.com' + git add lib/*.a + git commit -m "Automated build" + git push + + build-linux-arm: + if: 0 + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - arch: arm + emulator: qemu-arm + abi: arm-linux-gnueabi + - arch: aarch64 + emulator: qemu-aarch64 + abi: aarch64-linux-gnu + name: test-linux-arm (${{matrix.arch}}) + env: + PLATFORM_PREFIX: ${{matrix.abi}}- + EMULATOR: ${{matrix.emulator}} + steps: + - uses: actions/checkout@v2 + - name: install qemu + run: sudo apt-get install --no-install-recommends -y qemu-user + - name: install abi lib + run: sudo apt-get install --no-install-recommends -y gcc-${{matrix.abi}} g++-${{matrix.abi}} + - name: make + run: make && make test + + build-windows: + if: 0 + runs-on: windows-2019 + strategy: + fail-fast: false + matrix: + platform: [x86, x64, ARM, ARM64] + include: + - platform: x86 + folder: Win32 + native: yes + - platform: x64 + folder: x64 + native: yes + steps: + - uses: actions/checkout@v2 + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.2 + - name: build + run: msbuild.exe vs2019\stackman.sln /p:Platform=${{matrix.platform}} + - name: test + if: ${{ matrix.native == 'yes' }} + run: vs2019\${{matrix.folder}}\Debug\test.exe + From f1fb0c892a0ec0886135cb0e2f68b25633ed119d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 19:21:02 +0000 Subject: [PATCH 072/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 1d2e568..3f1fc44 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -29,7 +29,7 @@ jobs: - name: make run: make all - name: Commit libraries - run: | + run: | git config --global user.name 'Build Runner' git config --global user.email 'buildrunner@users.noreply.github.com' git add lib/*.a From 6b8c7a43a7afbacaa293bd990ca6204367097d01 Mon Sep 17 00:00:00 2001 From: Build Runner Date: Sun, 11 Apr 2021 19:21:13 +0000 Subject: [PATCH 073/115] Automated build --- lib/sysv_amd64/libstackman.a | Bin 3838 -> 3854 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/sysv_amd64/libstackman.a b/lib/sysv_amd64/libstackman.a index 242351971c987a86d26aca3ceeef286a659c8ccc..3025f8151273979fa68938024aa0871fd4eec71a 100644 GIT binary patch delta 158 zcmew-+b1`{oAng~1IMe$6S?Ik<{2^?PUhh>VszMeIe}3!BR@A)zo;}XFSSU&JijPg zzqlkZIXgEoZ?Y|u@8q>y>6{0hiC!8o~*No?{y r9)ZbP91@HtCOdQ3bG~3=00W-M>-o$%7cfJ3{gc=8$Zvkdp~40LB5*46 From 573c15a7ee84920b48e71ba845ab0faf2e39fa9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 19:33:27 +0000 Subject: [PATCH 074/115] Update buildcommit.yml Update buildcommit.yml Update buildcommit.yml --- .github/workflows/buildcommit.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 3f1fc44..1da69e7 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -28,6 +28,8 @@ jobs: if: ${{ matrix.name == 'i386' }} - name: make run: make all + - name: test + run: make test - name: Commit libraries run: | git config --global user.name 'Build Runner' @@ -37,10 +39,9 @@ jobs: git push build-linux-arm: - if: 0 runs-on: ubuntu-latest strategy: - fail-fast: false + fail-fast: true matrix: include: - arch: arm @@ -60,13 +61,21 @@ jobs: - name: install abi lib run: sudo apt-get install --no-install-recommends -y gcc-${{matrix.abi}} g++-${{matrix.abi}} - name: make - run: make && make test + run: make all + - name: test + run: make test + - name: Commit libraries + run: | + git config --global user.name 'Build Runner' + git config --global user.email 'buildrunner@users.noreply.github.com' + git add lib/*.a + git commit -m "Automated build" + git push build-windows: - if: 0 runs-on: windows-2019 strategy: - fail-fast: false + fail-fast: true matrix: platform: [x86, x64, ARM, ARM64] include: @@ -85,4 +94,11 @@ jobs: - name: test if: ${{ matrix.native == 'yes' }} run: vs2019\${{matrix.folder}}\Debug\test.exe + - name: Commit libraries + run: | + git config --global user.name 'Build Runner' + git config --global user.email 'buildrunner@users.noreply.github.com' + git add lib/*.lib + git commit -m "Automated build" + git push From 69ad2c53864c043b2e2cd5a675e5c2f2dfce4082 Mon Sep 17 00:00:00 2001 From: Build Runner Date: Sun, 11 Apr 2021 19:33:51 +0000 Subject: [PATCH 075/115] Automated build --- lib/sysv_i386/libstackman.a | Bin 2774 -> 2790 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/sysv_i386/libstackman.a b/lib/sysv_i386/libstackman.a index c71c0c7bd7c1595a322dab03887ada12110a951b..d5e977120323b9c8dc373f67db9902697b342880 100644 GIT binary patch delta 121 zcmV-<0EYk873LL?O9h4i00xGUP)`CiFq5eUDFIxu%U1yzXm4$0FLHHmZe?;WcW-iQ zFLQKZV{2_;Zj&qmMw9&qPqV-R4gvv`lg|Wq0mPF>1ycdwlbZ!20h^P*1t$W=0h2HU b7L)!35CO=O4+bXzh?6%4Cjrc}Uj}ys10X2+ delta 107 zcmV-x0F?jc71kAyO9gfS00wrEP)`FiI5d;G1}FhcvCCHh3U_aEYjbd6V`X!bI|4?N z4hT-O&;kwu0fdv^1a|?nlUD^(0nwAI1tS5Blg|Yw0=EH^Km-<(4h9ebxRW0SCjoeq NM+PSWyt8ixcLZ7*A*cWV From e1cec3b7f4da6331eb31d636cf6e443e5bebbc99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 11 Apr 2021 19:46:34 +0000 Subject: [PATCH 076/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 1da69e7..f04036c 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -35,7 +35,7 @@ jobs: git config --global user.name 'Build Runner' git config --global user.email 'buildrunner@users.noreply.github.com' git add lib/*.a - git commit -m "Automated build" + git diff-index --quiet HEAD || git commit -m "Automated build" git push build-linux-arm: @@ -69,7 +69,7 @@ jobs: git config --global user.name 'Build Runner' git config --global user.email 'buildrunner@users.noreply.github.com' git add lib/*.a - git commit -m "Automated build" + git diff-index --quiet HEAD || git commit -m "Automated build" git push build-windows: @@ -99,6 +99,6 @@ jobs: git config --global user.name 'Build Runner' git config --global user.email 'buildrunner@users.noreply.github.com' git add lib/*.lib - git commit -m "Automated build" + git diff-index --quiet HEAD || git commit -m "Automated build" git push From d252a4d45cefd1157ab19bb2c85c0920307a9359 Mon Sep 17 00:00:00 2001 From: Build Runner Date: Sun, 11 Apr 2021 19:47:05 +0000 Subject: [PATCH 077/115] Automated build --- lib/aarch64/libstackman.a | Bin 3902 -> 3990 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/aarch64/libstackman.a b/lib/aarch64/libstackman.a index e4874e12bedddfa8500ef019a513a84f6a8fca02..a2316bd9d5f35c8a4aec2547e6848b4b9d240317 100644 GIT binary patch delta 607 zcmdldH%)$mH|r|~298$~1N@l`4JR%%WO87cc%_Gtd2%A7s(f)tVsdtFVxB&Xp_k0y z?iZ@yY-p}vsb@TSBBN$~a++>IQGQ8ka!F=>o^4)!UaEp_T4Hf!UUEiJeqMfQv2JNz zd1hXUZb@QNPHHhw5^NYuQ+|!n^Aj1&iLIwtRXJ;z~jnJghypmFoAe$G;7ey1_zIivZITI5H^W-nA`xs|T-ptm{czg1E zUiryU>=K--fVx3I8!R%5U4rQ<<77i7vB`S80+VmCOEBJ;{F&XJ^9K_|8PDYVeCC`R zm?6CW$?`yBW^ouZT1-C2VZgXy@_&xiicgpsRy|;5T=kflY1LwNZ{5m0Z0fV=?! DK}M;t delta 474 zcmbOxzfW$0H|s10298-11N@l`j3+KMWct87@k$RP)8s@(Rc?2`Pz7g0Lj`j^)5%L2 zH77BN#V`~XCF>WLBqnF)Cg$lSGw5gJ=cejs7iAWgWF_Y5r)QSHWf>UUot>=|G(wX~ z^GZtfeKPYBi}FEc=^5x6mx2Wi>kKXQ3`{g3qLV+e$Zej*(PJ_*dpl$Elh|Y_ z4h_bR$<7@1j4LKL1IdKRhdH7c4JONR8URK7IakX*W@cFRfSGaCLuRH`pP3mZJ_2HU z28M}_3=KgElcl*d1P!1*&{VM0GuAU;V3-`i)hA*DvdfWAVJ^!&W~a$a-uLca<^y_5 zX7Vhigvn*x3m9!Si}T1cG9H<1&TG!Z0&&hPRt*?aicMtlEnX2$7O1mTfu4|`EXF6n qqzO?Q#VRm4j86jS*nB>FMuo}if#ikB?}6lp$@={Ei~*DL`PBhW4S68| From cf5d06e270d99873027b9cb3b91fdfde07a9c6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 10:29:19 +0000 Subject: [PATCH 078/115] makefile can echo the abiname --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d688059..1120222 100644 --- a/Makefile +++ b/Makefile @@ -21,18 +21,22 @@ endif ABI := $(shell ./abiname.sh "$(CC)" "$(CFLAGS)") ifndef ABI $(error Could not determine platform) -else -$(info ABI is $(ABI)) endif LIB := lib/$(ABI) all: $(LIB)/libstackman.a +# echo the abiname, for build tools. +.PHONY: abiname +abiname: + @echo $(ABI) + obj = stackman/stackman.o stackman/stackman_s.o $(LIB)/libstackman.a: lib $(obj) + $(info ABI is $(ABI)) $(AR) $(ARFLAGS) -s $@ $(obj) .PHONY: lib clean From d43e84a1cc8211f66d9bb4443e4046b5cbe3c100 Mon Sep 17 00:00:00 2001 From: Build Runner Date: Mon, 12 Apr 2021 10:31:16 +0000 Subject: [PATCH 079/115] Automated build --- lib/arm32/libstackman.a | Bin 2722 -> 2774 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/arm32/libstackman.a b/lib/arm32/libstackman.a index e2b3efb0bb87c1ca22b1a876c2ac0c33ef381bcf..ce4199d5e791616603e51ac93b275c510600e043 100644 GIT binary patch delta 553 zcmZ1^dQEhKH|s412DV!h0|J;VOeVi#(_rkFcv_yzm4ShQhZjgFPW%$V$UNDXQPs7$ zBr!QVH!)8i#?VV<(9g)vP1P?d&C5$I(l5_1%7#nA84T`zp$g81<_ea2#(D;mdl^;h za}$el6?B1Qa)vFCS!Pyj1R?h_R0n7{(5VatKnwy)fLMF-aiFU6Kvm+Rph#tAU?>2|fxvkn eM)>Q`WNR*UrZtR{53q<$26~G12GFcfkQV_Pu delta 393 zcmca6x=3__H|sVA2DWVz0|J;#EGF}@YcQrvJT1?~%fP_ElLsVfCw_@wWSZ>Ds4DI5 z7pmZFXsBSWXR2qQpqraml$>FkSd?34S~7V%qbhs4f^J%Xr}JbUCaK8cqGbKzlEmcf z+{8S+WCs0={M=Oi?4r!#lB~o${q)QdxGV#MyR);Ef<|akXov#Vw0`d1Q=T)L z519lOJmhr%Vg(@o0+|2Uc=CF71r7tKOD5lCcb?qGPL}6VXFA9**@sPy@y+CXE}$gPp*oZ2vney4 Jn7p4$8~|(|czyr? From cdef453a2aeb52f652dd42b43a11aa429829bea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 11:45:40 +0000 Subject: [PATCH 080/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 72384fc..850a174 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -23,10 +23,10 @@ jobs: - name: arm platformtools: arm-linux-gnueabi emulator: qemu-arm - name: build-linux-gnu (${{matrix.name}}) + # name: build-linux-gnu (${{matrix.name}}) env: PLATFORMFLAGS: ${{matrix.platformflags}} - PLATFORM_PREFIX: ${{matrix.platformtools}}- + PLATFORM_PREFIX: ${{matrix.platformtools}} EMULATOR: ${{matrix.emulator}} steps: - uses: actions/checkout@v2 @@ -52,7 +52,7 @@ jobs: path: lib/${{ env.abiname }}/libstackman.a build-linux-arm: - if: 0 + if: false runs-on: ubuntu-latest strategy: fail-fast: true @@ -87,7 +87,7 @@ jobs: git push build-windows: - if: 0 + if: false runs-on: windows-2019 strategy: fail-fast: true From 464c90fa08aa7ff1bb1953912c68bf813f558348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 10:39:01 +0000 Subject: [PATCH 081/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index f04036c..fec0fba 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -18,7 +18,7 @@ jobs: name: "AMD64" - platformflags: -m32 name: "i386" - name: test-linux-x86 (${{matrix.name}}) + name: build-linux-x86 (${{matrix.name}}) env: PLATFORMFLAGS: ${{matrix.platformflags}} steps: @@ -30,15 +30,16 @@ jobs: run: make all - name: test run: make test - - name: Commit libraries - run: | - git config --global user.name 'Build Runner' - git config --global user.email 'buildrunner@users.noreply.github.com' - git add lib/*.a - git diff-index --quiet HEAD || git commit -m "Automated build" - git push + - name: set abi name + run: echo abiname=$(make abiname) >> $GITHUB_ENV + - name: Upload build artifacts + uses: actions/upload-artifact@v2 + with: + name: ${{ env.abiname }} + path: lib/${{ env.abiname }}/libstackman.a build-linux-arm: + if: 0 runs-on: ubuntu-latest strategy: fail-fast: true @@ -73,6 +74,7 @@ jobs: git push build-windows: + if: 0 runs-on: windows-2019 strategy: fail-fast: true From 66de59a56191336d90f944e0291ae72a62f251ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 11:56:50 +0000 Subject: [PATCH 082/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 850a174..f8757e7 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -14,9 +14,6 @@ jobs: fail-fast: false matrix: name: [AMD64, i386, arm] - platformflags: [""] - platformtools: [""] - emulator: [""] include: - name: i386 platformflags: -m32 From 390006ae02c2ad9723cf601329032d82bdfc1a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 11:27:57 +0000 Subject: [PATCH 083/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index fec0fba..9326858 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -8,24 +8,36 @@ on: jobs: - build-linux-x86: + build-linux-gnu: runs-on: ubuntu-latest strategy: fail-fast: false matrix: + name: [AMD64, i386, arm] + platformflags: ["", "-m32"] + platformtools: ["", "", "arm-linux-gnueabi"] + emulator: ["", "", "qemu-arm"] include: - platformflags: "" name: "AMD64" - platformflags: -m32 name: "i386" - name: build-linux-x86 (${{matrix.name}}) + name: build-linux-gnu (${{matrix.name}}) env: PLATFORMFLAGS: ${{matrix.platformflags}} + PLATFORM_PREFIX: ${{matrix.platformtools}}- + EMULATOR: ${{matrix.emulator}} steps: - uses: actions/checkout@v2 - name: install multilib run: sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib if: ${{ matrix.name == 'i386' }} + - name: install qemu + if: matrix.emulator + run: sudo apt-get install --no-install-recommends -y qemu-user + - name: install abi lib + if: matrix.platformtools + run: sudo apt-get install --no-install-recommends -y gcc-${{matrix.platformtools}} g++-${{matrix.platformtools}} - name: make run: make all - name: test From 004a2483a0bd3a135f2c8e41926347144a65f7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 12:07:14 +0000 Subject: [PATCH 084/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 63 ++++++++----------------------- 1 file changed, 16 insertions(+), 47 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index f8757e7..07871ba 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -13,13 +13,16 @@ jobs: strategy: fail-fast: false matrix: - name: [AMD64, i386, arm] + name: [AMD64, i386, arm, aarch64] include: - name: i386 platformflags: -m32 - name: arm platformtools: arm-linux-gnueabi emulator: qemu-arm + - name: aarch64 + platformtools: aarch64-linux-gnue + emulator: qemu-aarch64 # name: build-linux-gnu (${{matrix.name}}) env: PLATFORMFLAGS: ${{matrix.platformflags}} @@ -48,48 +51,13 @@ jobs: name: ${{ env.abiname }} path: lib/${{ env.abiname }}/libstackman.a - build-linux-arm: - if: false - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - include: - - arch: arm - emulator: qemu-arm - abi: arm-linux-gnueabi - - arch: aarch64 - emulator: qemu-aarch64 - abi: aarch64-linux-gnu - name: test-linux-arm (${{matrix.arch}}) - env: - PLATFORM_PREFIX: ${{matrix.abi}}- - EMULATOR: ${{matrix.emulator}} - steps: - - uses: actions/checkout@v2 - - name: install qemu - run: sudo apt-get install --no-install-recommends -y qemu-user - - name: install abi lib - run: sudo apt-get install --no-install-recommends -y gcc-${{matrix.abi}} g++-${{matrix.abi}} - - name: make - run: make all - - name: test - run: make test - - name: Commit libraries - run: | - git config --global user.name 'Build Runner' - git config --global user.email 'buildrunner@users.noreply.github.com' - git add lib/*.a - git diff-index --quiet HEAD || git commit -m "Automated build" - git push - build-windows: if: false runs-on: windows-2019 strategy: fail-fast: true matrix: - platform: [x86, x64, ARM, ARM64] + platform: [x86, x64, arm, arm64] include: - platform: x86 folder: Win32 @@ -97,20 +65,21 @@ jobs: - platform: x64 folder: x64 native: yes + - platform: arm + folder: arm + - platform: arm64 + folder: arm64 + steps: - uses: actions/checkout@v2 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 + - uses: microsoft/setup-msbuild@v1.0.2 - name: build run: msbuild.exe vs2019\stackman.sln /p:Platform=${{matrix.platform}} - name: test if: ${{ matrix.native == 'yes' }} run: vs2019\${{matrix.folder}}\Debug\test.exe - - name: Commit libraries - run: | - git config --global user.name 'Build Runner' - git config --global user.email 'buildrunner@users.noreply.github.com' - git add lib/*.lib - git diff-index --quiet HEAD || git commit -m "Automated build" - git push - + - name: Upload build artifacts + uses: actions/upload-artifact@v2 + with: + name: win-${{ matrix.platform }} + path: vs2019/${{matrix.folder}}/Debug/stackman.lib From 5b8dbac03d592baebf6639a1099938b8ab7fbf73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 11:33:37 +0000 Subject: [PATCH 085/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 9326858..72384fc 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -14,14 +14,15 @@ jobs: fail-fast: false matrix: name: [AMD64, i386, arm] - platformflags: ["", "-m32"] - platformtools: ["", "", "arm-linux-gnueabi"] - emulator: ["", "", "qemu-arm"] + platformflags: [""] + platformtools: [""] + emulator: [""] include: - - platformflags: "" - name: "AMD64" - - platformflags: -m32 - name: "i386" + - name: i386 + platformflags: -m32 + - name: arm + platformtools: arm-linux-gnueabi + emulator: qemu-arm name: build-linux-gnu (${{matrix.name}}) env: PLATFORMFLAGS: ${{matrix.platformflags}} From 3fc91ae512506a33aa2fb85579e344f5278e14a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 12:08:45 +0000 Subject: [PATCH 086/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 07871ba..6b080ea 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -21,7 +21,7 @@ jobs: platformtools: arm-linux-gnueabi emulator: qemu-arm - name: aarch64 - platformtools: aarch64-linux-gnue + platformtools: aarch64-linux-gnu emulator: qemu-aarch64 # name: build-linux-gnu (${{matrix.name}}) env: @@ -52,7 +52,6 @@ jobs: path: lib/${{ env.abiname }}/libstackman.a build-windows: - if: false runs-on: windows-2019 strategy: fail-fast: true From e607b7e402e5db7e174ade6eda439d5dd5340c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 11:44:41 +0000 Subject: [PATCH 087/115] don't include final hyphen in PLATFORM_PREFIX --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1120222..6fea2f6 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,10 @@ CXXFLAGS += $(NO_CET) OLDCC := $(CC) ifdef PLATFORM_PREFIX -CC = $(PLATFORM_PREFIX)gcc -CXX = $(PLATFORM_PREFIX)g++ -LD = $(PLATFORM_PREFIX)ld -AR = $(PLATFORM_PREFIX)ar +CC = $(PLATFORM_PREFIX)-gcc +CXX = $(PLATFORM_PREFIX)-g++ +LD = $(PLATFORM_PREFIX)-ld +AR = $(PLATFORM_PREFIX)-ar endif # run c preprocessor with any cflags to get cross compilation result, then run regular compile in native ABI := $(shell ./abiname.sh "$(CC)" "$(CFLAGS)") From ea143175b4e2f27d0ba286fe9b189368722793ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 12:13:36 +0000 Subject: [PATCH 088/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 6b080ea..b3b6573 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -80,5 +80,5 @@ jobs: - name: Upload build artifacts uses: actions/upload-artifact@v2 with: - name: win-${{ matrix.platform }} - path: vs2019/${{matrix.folder}}/Debug/stackman.lib + name: win_${{ matrix.platform }} + path: lib/win_${{matrix.platform}}/stackman.lib From d77e9d559f6b08cad8870eaa311dfb81dce2951c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 15:21:18 +0000 Subject: [PATCH 089/115] Move the abiname discovery stuff into "tools" --- Makefile | 4 ++-- {stackman => tools}/abiname.c | 0 abiname.sh => tools/abiname.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename {stackman => tools}/abiname.c (100%) rename abiname.sh => tools/abiname.sh (91%) mode change 100755 => 100644 diff --git a/Makefile b/Makefile index 6fea2f6..a7c1309 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ LD = $(PLATFORM_PREFIX)-ld AR = $(PLATFORM_PREFIX)-ar endif # run c preprocessor with any cflags to get cross compilation result, then run regular compile in native -ABI := $(shell ./abiname.sh "$(CC)" "$(CFLAGS)") +ABI := $(shell tools/abiname.sh "$(CC)" "$(CFLAGS)") ifndef ABI $(error Could not determine platform) endif @@ -46,7 +46,7 @@ lib: clean: rm -f stackman/*.o tests/*.o rm -f bin/* - rm -rf tmp + rm -rf tmp tools/tmp DEBUG = #-DDEBUG_DUMP diff --git a/stackman/abiname.c b/tools/abiname.c similarity index 100% rename from stackman/abiname.c rename to tools/abiname.c diff --git a/abiname.sh b/tools/abiname.sh old mode 100755 new mode 100644 similarity index 91% rename from abiname.sh rename to tools/abiname.sh index 390d9ae..e899f05 --- a/abiname.sh +++ b/tools/abiname.sh @@ -16,7 +16,7 @@ tmp=$(mktemp "${here}/tmp/abinameXXX.c") #1 create the preprocessed file CC=${1:-cc} CFLAGS=${2:-} -${CC} ${CFLAGS} -E -o "${tmp}" "${here}/stackman/abiname.c" +${CC} ${CFLAGS} -I${here}/../stackman -E -o "${tmp}" "${here}/abiname.c" #2 compile resulting file cc -o "${tmp}.out" "${tmp}" #3 run it From b1f01c2c0f2c1ad8620535e95bf29884aa42faa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 12:25:44 +0000 Subject: [PATCH 090/115] Update buildcommit.yml --- .github/workflows/buildcommit.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index b3b6573..39520ac 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -82,3 +82,20 @@ jobs: with: name: win_${{ matrix.platform }} path: lib/win_${{matrix.platform}}/stackman.lib + + commit-artifacts: + runs-on: ubuntu-latest + needs: [build-linux-gnu, build-windows] + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + path: lib + + - name: Commit changes + run: | + git config --global user.name 'Automation tool' + git config --global user.email 'automation-tool@users.noreply.github.com' + git add lib/*.a lib/*.lib + git diff-index --quiet HEAD || git commit -m "Automated build" + From bde6ceb4e9bcb2ea2b38ac97ed984c1cfba0575a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 15:21:54 +0000 Subject: [PATCH 091/115] A tool to strip timestamps from windows .lib files --- tools/strip-lib.py | 266 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 tools/strip-lib.py diff --git a/tools/strip-lib.py b/tools/strip-lib.py new file mode 100644 index 0000000..8d8ee6f --- /dev/null +++ b/tools/strip-lib.py @@ -0,0 +1,266 @@ +# nulls the timestamp filed in a windows .lib archive, +# making the lib reproducable. +# the time is the TimeDateStamp in the COFF file header, four bytes at offset 4 +# See https://blog.conan.io/2019/09/02/Deterministic-builds-with-C-C++.html +# also: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#archive-library-file-format + +import sys +import struct + +libheader = b"!\n" + +def main(): + infilename = sys.argv[1] + if len(sys.argv) > 2: + outfilename = sys.argv[2] + else: + outfilename = infilename + + with open(infilename, "rb") as fp: + lib = read_lib(fp, True) + strip_lib_timestamp(lib) + with open(outfilename, "wb") as fp: + write_lib(fp, lib) + + +def read_lib(fp, verbose=False): + """ + read microsoft .lib file, + """ + # lib file header + h = fp.read(len(libheader)) + assert h == libheader + + # read first and second link members + h1 = header_read(fp) + p = fp.tell() + if verbose: + print("header", h1) + m1 = first_lm_read(fp) + assert fp.tell() - p == h1["size"] + if verbose: + print("first linker member", m1) + + h2 = header_read(fp) + if verbose: + print("header", h2) + p = fp.tell() + m2 = second_lm_read(fp) + assert fp.tell() - p == h2["size"] + if verbose: + print("second linker member", m2) + + result = { + "h1": h1, + "m1": m1, + "h2": h2, + "m2": m2, + "hl": None, + "longnames": [], + "ho": [], + "o": [], + } + + # now we might have an optional longnames member + h = header_read(fp) + if not h: + return result + + if h['name'] == "//": + result["hl"] = h + p = fp.tell() + while fp.tell() < p + h["size"]: + result["longnames"].append(readcstr(fp)) + h = None + if verbose: + print('header', h) + print('longnames', result['longnames']) + + # now read the headers, possibly we alread read one above. + while True: + if h is None: + h = header_read(fp) + if h is None: + return result + + result["ho"].append(h) + result["o"].append(fp.read(h['size'])) + if verbose: + print("header:", result['ho'][-1]) + print("coff:", len(result['o'][-1])) + h = None + + return result + + +def write_lib(fp, lib): + fp.write(libheader) + header_write(fp, lib["h1"]) + first_lm_write(fp, lib["m1"]) + header_write(fp, lib["h2"]) + second_lm_write(fp, lib["m2"]) + + if lib["hl"]: + header_write(fp, lib["hl"]) + for s in lib["longnames"]: + writecstr(fp, s) + + for h, c in zip(lib["ho"], lib["o"]): + header_write(fp, h) + fp.write(c) + +def strip_lib_timestamp(lib): + def fix_header(h): + h['date'] = "-1" + fix_header(lib['h1']) + fix_header(lib['h2']) + if lib['hl']: + fix_header(lib['hl']) + for h in lib['ho']: + fix_header(h) + lib['o'] = [strip_coff_timestamp(c) for c in lib['o']] + + +def header_read(fp): + """ + read a header entry from a microsoft archive + """ + + #header can start with optional newline + optnl = read_optional_nl(fp) + + name = fp.read(16) + if len(name) < 16: + return None # eof + name = name.decode("ascii").strip() + date = fp.read(12).decode("ascii").strip() + uid = fp.read(6).decode("ascii").strip() + gid = fp.read(6).decode("ascii").strip() + mode = fp.read(8).decode("ascii").strip() + size = fp.read(10).decode("ascii").strip() + size = eval(size) + eoh = fp.read(2) + assert eoh == b"\x60\x0a" + return { + "optnl": optnl, + "name": name, + "date": date, + "uid": uid, + "gid": gid, + "mode": mode, + "size": size, + } + + +def header_write(fp, h): + def writestr(s, n): + """helper to write space padded string of fixed length""" + e = s.encode("ascii") + b" " * n + fp.write(e[:n]) + + if h["optnl"]: + fp.write(h['optnl']) + writestr(h["name"], 16) + writestr(h["date"], 12) + writestr(h["uid"], 6) + writestr(h["gid"], 6) + writestr(h["mode"], 8) + writestr(str(h["size"]), 10) + fp.write(b"\x60\x0a") + + +def first_lm_read(fp): + nos = fp.read(4) + nos = struct.unpack(">L", nos)[0] # unsigned long, big-endian + + offsets = [] + strings = [] + for i in range(nos): + offset = fp.read(4) + offsets.append(struct.unpack(">L", offset)[0]) + for i in range(nos): + strings.append(readcstr(fp)) + return {"offsets": offsets, "strings": strings} + # sometimes there is an extra \0a after the strings + p = peek(fp) + return zip(offsets, strings) + + +def first_lm_write(fp, lm): + nos = len(lm["offsets"]) + fp.write(struct.pack(">L", nos)) + for o in lm["offsets"]: + fp.write(struct.pack(">L", o)) + for s in lm["strings"]: + writecstr(fp, s) + + +def second_lm_read(fp): + # number of members + m = struct.unpack(" Date: Mon, 12 Apr 2021 15:24:02 +0000 Subject: [PATCH 092/115] Ad vscode devcontainer config --- .devcontainer/Dockerfile | 11 +++++++++++ .devcontainer/devcontainer.json | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..067d9a2 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,11 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/ubuntu/.devcontainer/base.Dockerfile + +# [Choice] Ubuntu version: bionic, focal +ARG VARIANT="focal" +FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} + +# [Optional] Uncomment this section to install additional OS packages. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends build-essential + + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..3521ef9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,29 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/ubuntu +{ + "name": "Ubuntu", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu version: focal, bionic + "args": { "VARIANT": "focal" } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vscode.cpptools" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "uname -a", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} \ No newline at end of file From 627c5f5ed61777ba39ef45b5ef4612adeba574bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 15:28:27 +0000 Subject: [PATCH 093/115] update build step to strip timestamps from libs --- .github/workflows/buildcommit.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 39520ac..9bde293 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -74,6 +74,10 @@ jobs: - uses: microsoft/setup-msbuild@v1.0.2 - name: build run: msbuild.exe vs2019\stackman.sln /p:Platform=${{matrix.platform}} + - name: strip timestamps from lib + run: python tools/strip-lib.py lib/win_${{matrix.platform}}/stackman.lib + - name: rebuild after stripping + run: msbuild.exe vs2019\stackman.sln /p:Platform=${{matrix.platform}} - name: test if: ${{ matrix.native == 'yes' }} run: vs2019\${{matrix.folder}}\Debug\test.exe From a4f499669f94bba54d88652a9b202c9a06fafb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 15:37:29 +0000 Subject: [PATCH 094/115] invoke shell on abiname.sh --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a7c1309..20518c2 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ LD = $(PLATFORM_PREFIX)-ld AR = $(PLATFORM_PREFIX)-ar endif # run c preprocessor with any cflags to get cross compilation result, then run regular compile in native -ABI := $(shell tools/abiname.sh "$(CC)" "$(CFLAGS)") +ABI := $(shell sh tools/abiname.sh "$(CC)" "$(CFLAGS)") ifndef ABI $(error Could not determine platform) endif From d82671354e35060d3efebbd3aff1dc2bdc0431ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 15:53:26 +0000 Subject: [PATCH 095/115] fix fix fix update workflows. Delete old 'test' and commit only on commit to main --- .github/workflows/buildcommit.yml | 8 ++-- .github/workflows/test.yml | 79 ------------------------------- 2 files changed, 5 insertions(+), 82 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 9bde293..6bef733 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -1,10 +1,11 @@ -name: build and commit +name: build test and commit on: push: branches: [ master, dev ] - workflow_dispatch: + pull_request: + branches: [ master ] jobs: @@ -90,6 +91,7 @@ jobs: commit-artifacts: runs-on: ubuntu-latest needs: [build-linux-gnu, build-windows] + if: ${{ github.event_name == 'push' }} steps: - uses: actions/checkout@v2 - uses: actions/download-artifact@v2 @@ -102,4 +104,4 @@ jobs: git config --global user.email 'automation-tool@users.noreply.github.com' git add lib/*.a lib/*.lib git diff-index --quiet HEAD || git commit -m "Automated build" - + git push diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 2086164..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: C/C++ CI - -on: - push: - branches: [ master, dev ] - pull_request: - branches: [ master ] - -jobs: - - test-linux-x86: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - platformflags: "" - name: "AMD64" - - platformflags: -m32 - name: "i386" - name: test-linux-x86 (${{matrix.name}}) - env: - PLATFORMFLAGS: ${{matrix.platformflags}} - steps: - - uses: actions/checkout@v2 - - name: install multilib - run: sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib - if: ${{ matrix.name == 'i386' }} - - name: make - run: make && make test - - test-linux-arm: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - arch: arm - emulator: qemu-arm - abi: arm-linux-gnueabi - - arch: aarch64 - emulator: qemu-aarch64 - abi: aarch64-linux-gnu - name: test-linux-arm (${{matrix.arch}}) - env: - PLATFORM_PREFIX: ${{matrix.abi}}- - EMULATOR: ${{matrix.emulator}} - steps: - - uses: actions/checkout@v2 - - name: install qemu - run: sudo apt-get install --no-install-recommends -y qemu-user - - name: install abi lib - run: sudo apt-get install --no-install-recommends -y gcc-${{matrix.abi}} g++-${{matrix.abi}} - - name: make - run: make && make test - - test-windows: - runs-on: windows-2019 - strategy: - fail-fast: false - matrix: - platform: [x86, x64, ARM, ARM64] - include: - - platform: x86 - folder: Win32 - native: yes - - platform: x64 - folder: x64 - native: yes - steps: - - uses: actions/checkout@v2 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 - - name: build - run: msbuild.exe vs2019\stackman.sln /p:Platform=${{matrix.platform}} - - name: test - if: ${{ matrix.native == 'yes' }} - run: vs2019\${{matrix.folder}}\Debug\test.exe - From b418d13a9bba850ae531457c71948a11d73aa0b0 Mon Sep 17 00:00:00 2001 From: Automation tool Date: Mon, 12 Apr 2021 15:55:15 +0000 Subject: [PATCH 096/115] Automated build --- lib/win_arm/stackman.lib | Bin 3002 -> 3110 bytes lib/win_arm64/stackman.lib | Bin 6178 -> 6338 bytes lib/win_x64/stackman.lib | Bin 5082 -> 5216 bytes lib/win_x86/stackman.lib | Bin 10042 -> 10160 bytes 4 files changed, 0 insert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%xEzAEw?2AYWcxD diff --git a/lib/win_arm64/stackman.lib b/lib/win_arm64/stackman.lib index 0ff4d9a422a1b3879c1fed9b8cb8d999b6348a1c..96c356e7aeb06cd295311988a1e20aede83f815d 100644 GIT binary patch delta 1537 zcmbW1TWk|o5Qb;H7i`Cl?SSnB+YmVkE=sek!9gTMAtWIp372qb714dba$E>_ZP!_= z6+#3M5=bDCFbFDz3I&N5gg`V^%L5X(7bK8)fR~`QgooaOn$}K5Us}>xdmRGdrjGV# z=bZD;*_k<*e z=&v!HVgmdbnzdrJ;Q_ZA;2V5ys4N?xr7mC`ny$584$FONII>#_$1z?!ACpBE+{U^v z!MY8jDjs1)?RAx{F6UknPe)BV_%|DHYKH<)$~mL-fMv#T*j>S#!A)F+Bc6`Ml4=U> z&`xd_`?xQhb+xrGN)vLSi_9nZW>Y2A86sUbcJdX>Nlfqo{viwSJr3~;c{@pe#_N25 zd4|96on?n8vhA&v?GilZQ59e=c!A0~E>wQWz`IB?>uY5O$Y5hhgLzF{ji!>R-o7Z_G`ZQjpoCwQ%&*R7O7zGXS!LSZa9aL) zo6J`1GXLp&rmMZDLml;m_IrTSqqiwmvIrox(nSFH7%Hp8&1CGY%Utur2^WNp-79CTI{4u~X^ zpZCU7DupceZCJClt$RyrryLSj$nEh+EZq~8(~7^mrW+>lRPmyv9YYP5gGW6@f8E%B zerLzFPbNmc{Jnp3{f>_thWd}4-qWo0U$dr2LP?6fJp{-^aTimGt8BvtyMW_vFFv>J zbuE>o& zrxCd~cV94}Cq=wjy|3~{0wEJ7?<*rm> zM=Gokf*BWZF0G*)HI}C#(3nG`kuoyk5|_{WHoovfcd29|c{X#f%6X@gb^K-=ceG#r m=%=R#?jHX4(dp&iuzSc*Tmi`mkKc5_Ja zHt24 zt%e2g0RLt|afs|Dtmb|}j<56_C#wyZTTg0jNc5&OY~ zKE%;-o3CEP7xEMPwWPdPNv0F~RT-T^&`Is(g<1igJ-}w)N;ZW1gfb_9mwexo>M;(_ z3kST>SgbUJDL+Kkf?=`6;-d!YC~+em6j!q2_?;LOCwPFnI4Ld{r$vB!_(TkHw=8(d z-QgLel8tjmslo%yj#o?$>#zz?Rv2Qvr;6G>rD&EC>BoaZtwPMxGvz*8HVs(qs|hDx6$cY09YmN=C!Gw&*;&cG^N*E{jKOOXdlV+uCM%J@zgs z8u@TdD4ZCORV@Iyw;N-V6tlbyDcC4A2)c!@?5#G#{beexYB*){;%>)Mmc~KH>T)9_ zXEOO{z+cl|Y`wzKo|gLtx_c4>ioa$%;A=6z!_hcE2u*zsBRw~;>% zbv5(`|9WxkdEb#Q^pn=5Nv4TIscz!%HfJaE;YH^tH!Wg^YecGz)kRBG6!KJ@HsPPH z7Iq2Oxr3%CQSJo8r(!_#Q?1*0(!F7R+UY2mG2rq1n|7G=luH&Oj($!49|>v+)@25w zp-_Szx^l()N8F_Ny9sgaOj(fq7vwd##k*)0vP8ipM8QN->r+0L6RE<H zn|M%wH!3x+EuyZY7a;gL)&5>JsesO8L86Nc0v&@$Y9i&BC@r8BH%rw;j#x_^!H=Z) z`+4E~Cog93&SGEKOeLS?j;``fY~bCGCd?0iKHud!>)NzsO1`XSsfWDGp~WToXZdi@ Lw~$5gYhUaQ714Sr diff --git a/lib/win_x64/stackman.lib b/lib/win_x64/stackman.lib index 6422336802506c79b8f5d113e7c0248ee403e6df..881bad84be7a5653437904f9be68f236b35ff62e 100644 GIT binary patch delta 1209 zcmZ`&ZAep57=F*)u5EXl?QVW8^CMm9mb-0W;=(MlqOxeEM8!p#bCl)gns+w(QiB;$ zl<`9JqY$GX{RpIjpkGEr5cQ*eR2T*I$EZM>RKE&(@AVp{cJ9aXoafwg&U4=Py>F{N zR1e*?-m(I40Kn+F94fo~{)WH4wys=j2ZWA66O93Q%>YFj1CW$xT5-qXdKbJn%39cI zG;me?aaw8+S8Cbm%j8})x-A6F*IJirnIK=1T|V8v0ckZ+(xCh-~P;df-7Du#RC zxnhQP<6-8-6Gor=lDfynHF8+)QNocUv2c7o!H33HW6)n4z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15:59:52 +0000 Subject: [PATCH 097/115] update status badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ff9766..713339c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/kristjanvalur/stackman.svg?branch=master)](https://travis-ci.org/kristjanvalur/stackman) +[![build test and commit](https://github.com/kristjanvalur/stackman/actions/workflows/buildcommit.yml/badge.svg)](https://github.com/kristjanvalur/stackman/actions/workflows/buildcommit.yml) # stackman Simple low-level stack manipulation API and implementation for common platforms From bc6dd501222e7afe96f9c373115d48f2b8f40de3 Mon Sep 17 00:00:00 2001 From: Automation tool Date: Mon, 12 Apr 2021 16:02:19 +0000 Subject: [PATCH 098/115] Automated build --- lib/win_arm64/stackman.lib | Bin 6338 -> 6338 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/win_arm64/stackman.lib b/lib/win_arm64/stackman.lib index 96c356e7aeb06cd295311988a1e20aede83f815d..47c1c3e4eb6e98de9d48e2dbeb4250adbb650b39 100644 GIT binary patch delta 16 YcmX?Pc*t;M1& delta 16 YcmX?Pc*t Date: Mon, 12 Apr 2021 17:15:19 +0000 Subject: [PATCH 099/115] Add features to the windows lib stripper. --- tools/strip-lib.py | 107 +++++++++++++++++++++++++++++++++------------ 1 file changed, 79 insertions(+), 28 deletions(-) diff --git a/tools/strip-lib.py b/tools/strip-lib.py index 8d8ee6f..a64aa97 100644 --- a/tools/strip-lib.py +++ b/tools/strip-lib.py @@ -3,12 +3,18 @@ # the time is the TimeDateStamp in the COFF file header, four bytes at offset 4 # See https://blog.conan.io/2019/09/02/Deterministic-builds-with-C-C++.html # also: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#archive-library-file-format +# +# There are some additional fixes added for reproducability, such as fixing the zero-padding of names in the coff +# section headers. import sys import struct +verbose = True + libheader = b"!\n" + def main(): infilename = sys.argv[1] if len(sys.argv) > 2: @@ -17,13 +23,13 @@ def main(): outfilename = infilename with open(infilename, "rb") as fp: - lib = read_lib(fp, True) + lib = read_lib(fp) strip_lib_timestamp(lib) with open(outfilename, "wb") as fp: write_lib(fp, lib) -def read_lib(fp, verbose=False): +def read_lib(fp): """ read microsoft .lib file, """ @@ -40,7 +46,7 @@ def read_lib(fp, verbose=False): assert fp.tell() - p == h1["size"] if verbose: print("first linker member", m1) - + h2 = header_read(fp) if verbose: print("header", h2) @@ -66,15 +72,15 @@ def read_lib(fp, verbose=False): if not h: return result - if h['name'] == "//": + if h["name"] == "//": result["hl"] = h p = fp.tell() while fp.tell() < p + h["size"]: result["longnames"].append(readcstr(fp)) - h = None if verbose: - print('header', h) - print('longnames', result['longnames']) + print("header", h) + print("longnames", result["longnames"]) + h = None # now read the headers, possibly we alread read one above. while True: @@ -84,10 +90,10 @@ def read_lib(fp, verbose=False): return result result["ho"].append(h) - result["o"].append(fp.read(h['size'])) + result["o"].append(fp.read(h["size"])) if verbose: - print("header:", result['ho'][-1]) - print("coff:", len(result['o'][-1])) + print("header:", result["ho"][-1]) + print("coff length:", len(result["o"][-1])) h = None return result @@ -109,16 +115,19 @@ def write_lib(fp, lib): header_write(fp, h) fp.write(c) + def strip_lib_timestamp(lib): def fix_header(h): - h['date'] = "-1" - fix_header(lib['h1']) - fix_header(lib['h2']) - if lib['hl']: - fix_header(lib['hl']) - for h in lib['ho']: + h["date"] = "-1" + + fix_header(lib["h1"]) + fix_header(lib["h2"]) + if lib["hl"]: + fix_header(lib["hl"]) + for h in lib["ho"]: fix_header(h) - lib['o'] = [strip_coff_timestamp(c) for c in lib['o']] + lib["o"] = [strip_coff_timestamp(c) for c in lib["o"]] + lib["o"] = [fix_coff_null_padding(c) for c in lib["o"]] def header_read(fp): @@ -126,7 +135,7 @@ def header_read(fp): read a header entry from a microsoft archive """ - #header can start with optional newline + # header can start with optional newline optnl = read_optional_nl(fp) name = fp.read(16) @@ -159,7 +168,7 @@ def writestr(s, n): fp.write(e[:n]) if h["optnl"]: - fp.write(h['optnl']) + fp.write(h["optnl"]) writestr(h["name"], 16) writestr(h["date"], 12) writestr(h["uid"], 6) @@ -193,7 +202,7 @@ def first_lm_write(fp, lm): fp.write(struct.pack(">L", o)) for s in lm["strings"]: writecstr(fp, s) - + def second_lm_read(fp): # number of members @@ -210,7 +219,7 @@ def second_lm_read(fp): strings = [] for i in range(n): strings.append(readcstr(fp)) - + return {"offsets": offsets, "indices": indices, "strings": strings} @@ -225,7 +234,7 @@ def second_lm_write(fp, lm): fp.write(struct.pack("= 0: + # everything after first null is null + shortname = name[:i] + namenew = (shortname + b"\0" * 8)[:8] + if name != namenew: + sections[n] = namenew + s[8:] + modified = True + if verbose: + print( + "Fixed null padding of COFF section header name %r" % shortname + ) + if modified: + start = header + b"".join(sections) + coff = start + coff[len(start) :] + return coff +if __name__ == "__main__": + main() From 689c45c576e619052feb796ddbb058201063f40e Mon Sep 17 00:00:00 2001 From: Automation tool Date: Mon, 12 Apr 2021 17:18:47 +0000 Subject: [PATCH 100/115] Automated build --- lib/win_arm/stackman.lib | Bin 3110 -> 3110 bytes lib/win_arm64/stackman.lib | Bin 6338 -> 6338 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/win_arm/stackman.lib b/lib/win_arm/stackman.lib index 0e1d687de8cb0213acb9999eb370390c8ce5d3a0..0713cfacf44ab54df4467e41af1908ce65542f9d 100644 GIT binary patch delta 17 XcmZ1`u}osaB1RSlAlST&v4IN!FMtHN delta 17 YcmZ1`u}osaB1V>Q&j{Pi%NQHD0647$?EnA( diff --git a/lib/win_arm64/stackman.lib b/lib/win_arm64/stackman.lib index 47c1c3e4eb6e98de9d48e2dbeb4250adbb650b39..96c356e7aeb06cd295311988a1e20aede83f815d 100644 GIT binary patch delta 16 YcmX?Pc*t;M1& From fe3e2c6f8b8c061f5bc6837932f1a87f421882e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 17:23:03 +0000 Subject: [PATCH 101/115] more info for git commit --- .github/workflows/buildcommit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 6bef733..cfc7faf 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -103,5 +103,6 @@ jobs: git config --global user.name 'Automation tool' git config --global user.email 'automation-tool@users.noreply.github.com' git add lib/*.a lib/*.lib + git status git diff-index --quiet HEAD || git commit -m "Automated build" git push From 63bb64b37d7720230e6579e3a266e62a1f66fe31 Mon Sep 17 00:00:00 2001 From: Anselm Kruis Date: Tue, 22 Jun 2021 23:23:08 +0200 Subject: [PATCH 102/115] Fix a typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30c1706..e63d8ad 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Other platforms can be easily adapted from both existing implementations for oth projects as well as from example code provided. ### Intel CET -Intel's Conontrol-Flow Enforcement Technology is incompatible with stack switching +Intel's Control-Flow Enforcement Technology is incompatible with stack switching because it imploys a secondary Shadow Stack, that the user-mode program cannot modify. Unexpected return flow after a stack switch would cause the processor to fault. Because of this, we need to mark any assembly code as not CET compatible. Modern compilers are beginning to generate CET compatible objects and From c572d4d07cc8507bc5a519dbab6e461f718547d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 12 Apr 2021 10:29:19 +0000 Subject: [PATCH 103/115] makefile can echo the abiname (cherry picked from commit cf5d06e270d99873027b9cb3b91fdfde07a9c6cc) --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d688059..1120222 100644 --- a/Makefile +++ b/Makefile @@ -21,18 +21,22 @@ endif ABI := $(shell ./abiname.sh "$(CC)" "$(CFLAGS)") ifndef ABI $(error Could not determine platform) -else -$(info ABI is $(ABI)) endif LIB := lib/$(ABI) all: $(LIB)/libstackman.a +# echo the abiname, for build tools. +.PHONY: abiname +abiname: + @echo $(ABI) + obj = stackman/stackman.o stackman/stackman_s.o $(LIB)/libstackman.a: lib $(obj) + $(info ABI is $(ABI)) $(AR) $(ARFLAGS) -s $@ $(obj) .PHONY: lib clean From 4606e73300507fb01ae8d468ba1981fc4487d01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 25 Jul 2021 17:48:44 +0000 Subject: [PATCH 104/115] Fix readme --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a7699a0..4ab8b04 100644 --- a/README.md +++ b/README.md @@ -168,11 +168,15 @@ platforms may need to be done independently. - *make* using `make PLATFORM_PREFIX=aarch64-linux-gnu- EMULATOR=qemu-aarch64 test` ## A note about Intel CET -Intel's Conontrol-Flow Enforcement Technology is incompatible with stack switching -because it imploys a secondary Shadow Stack, that the user-mode program cannot +Intel's *Control-Flow Enforcement Technology* is incompatible with stack switching +because it employs a secondary *Shadow Stack*, that the user-mode program cannot modify. Unexpected return flow after a stack switch would cause the processor -to fault. Because of this, we need to mark any assembly code as not CET compatible. Modern compilers are beginning to generate CET compatible objects and -once supporting CPUs start to arrive, processes which consist entirely of CET compatible code may be run in such a protected environment. See https://software.intel.com/content/www/us/en/develop/articles/technical-look-control-flow-enforcement-technology.html for more information +to fault. Because of this, we need to mark any assembly code as **not CET compatible** by +adding special compiler flags to supporting compilers (currently modern GNU C). +Modern compilers are beginning to generate CET compatible objects and +once supporting CPUs start to arrive, processes which consist entirely of CET compatible +code may be run in such a protected environment. +See https://software.intel.com/content/www/us/en/develop/articles/technical-look-control-flow-enforcement-technology.html for more information ## History This works was originally inspired by *Stackless Python* by [Christian Tismer](https://github.com/ctismer), where the original switching code was From fa40e7ec7cda3ad0b2d78557368f712dbd89fd64 Mon Sep 17 00:00:00 2001 From: Automation tool Date: Sun, 25 Jul 2021 17:50:53 +0000 Subject: [PATCH 105/115] Automated build --- lib/win_arm/stackman.lib | Bin 3110 -> 3978 bytes lib/win_arm64/stackman.lib | Bin 6338 -> 8066 bytes lib/win_x64/stackman.lib | Bin 5216 -> 6118 bytes lib/win_x86/stackman.lib | Bin 10160 -> 11040 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/win_arm/stackman.lib b/lib/win_arm/stackman.lib index 0713cfacf44ab54df4467e41af1908ce65542f9d..2b515b5ef4c3f3470456d7528f02ee271b48bd20 100644 GIT binary patch delta 655 zcmZ1`(Ivm(2otL;Ls%)}jZX7J!1m{WAn*%Y&MK$li#z-N#RccfsmkkkX^m3SCFfBMM8 z2(fCiKZl_bOhaNxPHtK<4t*|@eK^IDY_jFDlPXOvDp6wi_zBb9lY!EFrMW0}1BHZ& zGZKqZQ_zH6L>RcB?m>1dP`yZUK>;wlfVQAYs7)5(mYST*DLL7e%}NyJewc?r9{e=< zKZoz+3^sl~m@LG1lOs4)fSR;{zA@)!`1BDL=96Q&_E%`#GF9P1;o>UKIaC~lN-6RC-ZSDF@BzGz%60G0~Gr7u}M|* ygg3L`%c?f^{o%STi@D$KJnncoB?A=2AmEUkpIe}pnG#kyxq`a{l&0QsTL1tTjk;0* delta 374 zcmeB@Una5P2otLe!_5+g$tRg~nQoSB{=pQ+C}wDBX{G=M30y}QSr|Y-gne=fOBPcK z>*Nb8T1;QqCjVhszzf#OAj|+UVkN6BBiH2TtP|KR^o%Sm4GkvOvDq-XO@7a+J9z>V z4_`@Qa&~TFo?byp62qsDlRvTj;9z286$6<*S&l<{ax-@@T;~QJmC3ejR#H%tViHSo za?_GyGV_viN>fsm7(V`*{F>W$ax16!uF|de%e8wWcz`zQ`Y(UHo#9Bb@96)+7KkkD26+es9Fp^M U3-mHmZk9~G!&d?dx*&cF09GSpg#Z8m diff --git a/lib/win_arm64/stackman.lib b/lib/win_arm64/stackman.lib index 96c356e7aeb06cd295311988a1e20aede83f815d..68c06e032ad94c4fc53776b089e24794a9b111ee 100644 GIT binary patch delta 1464 zcmbW0T}V@57{}kU?QA<|=WKIxn_22wX{60&i<&cX!!Il|i(FCzTic4+w$|E8kP5;s z@*)-wK_3(pT|^h9cvT?T$3;+Rgm}?~8B|agN7H z;D}5Q4T>{p`%H0{%7-4Mn;L>4rB(a0=kcv!Y3I0bb~Tx#1|^J%QdC#kZ8rNxFtaww z3Fn#OqHt)x_joAU>5E4;toI&G`22?=zG!7Eu%BeoaFLyo$SLSk)s+Xk6Tx`Y7j_1t z$D9ovyBc=3x?4J%TkBfd>l@5gaeB8MuI5)TVjmvzOW-x*ES){u8;bhF$w1IT(%%Vf z6ylq=JGYU!T_~CJcr*!4U{Gk)+}=hQ*VM~)B=+2dVr{u3#=sWsC4*z*hB^9W z(`$QK_@?cWk0HA$3Z`g_+>GM^7LmWP0QDMt0zJBvm=rU+3@Y_27X|EP{ZwtXPG;*K zzcUmKhoZrGMgLEH*JXjs;yceWhq+ApYnGD<&H+Dkntx>>ncb&(t2gXcVn*jYBza1UtdZUx{sHwe>ct(3irb)w34zFzxC|D^OQ$k;X<2UX$ Bu6O_d delta 828 zcmZp&KV&%J9MdL&jTa6uvC1&qEMb^Dm06eRX36Fw%wddTMwX_g3Sf}Hm9mPB0R+^z zCL6G3F*;11&8p3Mg_(ij&g9dq@~i?t*=LjAv#K+Fh8pJKYz`z5< zyg>_83&5OV@C7Z3{o@u!bXs-h>nnFU{Z&9+%@*e%Wd zeL;KDkp?2^tZx zC=tN|3|CelW&>hSnA-s(0u=6(6@|mX4|0w SiW<-XlU3wZK%wO&Zvg-)KH{?g diff --git a/lib/win_x64/stackman.lib b/lib/win_x64/stackman.lib index 881bad84be7a5653437904f9be68f236b35ff62e..56f06ddfb931082331ad8936672ebcb9f47f5c6a 100644 GIT binary patch delta 704 zcmaE$@l1b1A_uE1Ls%)}<72s1#8H0HBql5|guY6Z7;6Qj!=Z_wXM!O|2+NEy_#Gu}aM= zvvQ3HaSifw^ojTMbM^^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JyyiW!a*3UDzKAMXe9qmDTQ<(DlN{J#)VA+;jQP z+@lSBnZ7@GL5IP1z`yuYwyMer)zx1na(jhgW*KbHZMDs3-l^4zgppt06{eX0=DHfd zA+gIMD%e&Kx9kbv;ezA#{5jx;{GMA_=ws{^Hc7JzD!}HnDF6&tI08j;>QXb)b6|p* zM7d}pM--;~v4X^y%x20kqZQfWl#z)2R*eXg%^2?&O%W&qJT6ytlr@)>N~a+;rW;X{ z*kR{&2PrsMv~FWlTmAPA{zVA0v)xX2a!+IPrc1z;6sMQE|Xx(krvw9m#)prq0DI znyi6VlBX^1z#v$qlPn!gWaq8e|)?6r;o{b z=PsU>{sDMHH@Zt4?sHGiJ$2o-;4hYGm~qwP@#49x9G@5ei9;p#n3dd#V5g?wWB*#g zoUxe8s2ao5ei_%OifI_`(GvNYiP*0pvvTNvjZGq=7ZTS!Jj2|jK_OhCqnA z8H7^8ClI`4v}2z;h)-Qs?2R?zeb0DIkCX84n2TZ$c7LJQsla&!&`7Ei0)!wTOn5!A zJyLvc0q1<)+cV?g?4|lwOO~C9UwbvL$8%`bqmFCFdg_^9wJX=PuCHuaHQ0`P{JQz{ IZpWAX2d^Cewg3PC From ebfb17b318292f3ceb9a89f0cf60fced87b724b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 21:04:38 +0000 Subject: [PATCH 106/115] Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 4.1.7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v2...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/buildcommit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index cfc7faf..06e53bb 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -94,7 +94,7 @@ jobs: if: ${{ github.event_name == 'push' }} steps: - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4.1.7 with: path: lib From c59a1f07fc423cac707bae2bb27ff11030e5827b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 5 Sep 2024 10:44:29 +0000 Subject: [PATCH 107/115] Update buildcommit.yml use @v4 for upload/download artifacts --- .github/workflows/buildcommit.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 06e53bb..7834d97 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -47,7 +47,7 @@ jobs: - name: set abi name run: echo abiname=$(make abiname) >> $GITHUB_ENV - name: Upload build artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ env.abiname }} path: lib/${{ env.abiname }}/libstackman.a @@ -83,7 +83,7 @@ jobs: if: ${{ matrix.native == 'yes' }} run: vs2019\${{matrix.folder}}\Debug\test.exe - name: Upload build artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: win_${{ matrix.platform }} path: lib/win_${{matrix.platform}}/stackman.lib @@ -94,7 +94,7 @@ jobs: if: ${{ github.event_name == 'push' }} steps: - uses: actions/checkout@v2 - - uses: actions/download-artifact@v4.1.7 + - uses: actions/download-artifact@v4 with: path: lib From 7ce4a674d541433e9ea357ca06a225cda5dcaef7 Mon Sep 17 00:00:00 2001 From: Automation tool Date: Thu, 5 Sep 2024 10:46:48 +0000 Subject: [PATCH 108/115] Automated build --- lib/aarch64/libstackman.a | Bin 3990 -> 4318 bytes lib/arm32/libstackman.a | Bin 2774 -> 2774 bytes lib/sysv_amd64/libstackman.a | Bin 3854 -> 3926 bytes lib/sysv_i386/libstackman.a | Bin 2790 -> 2838 bytes lib/win_arm/stackman.lib | Bin 3978 -> 3938 bytes lib/win_arm64/stackman.lib | Bin 8066 -> 7998 bytes lib/win_x64/stackman.lib | Bin 6118 -> 6090 bytes lib/win_x86/stackman.lib | Bin 11040 -> 11074 bytes 8 files changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/aarch64/libstackman.a b/lib/aarch64/libstackman.a index a2316bd9d5f35c8a4aec2547e6848b4b9d240317..c30dcd0259965b9601e523027e70c6044d69eeb4 100644 GIT binary patch delta 896 zcmZva-D(p-6vt;~Ke|bq#x__(MK|k5P1S66<4TJKlah;y1r?-tBcy4vlwiArCX0fg zh=LdKBH@U>Kz)Kff|t4S1@yuj-=SW3W_CtG=z-nyKfnF&nK{FJv41+lhi1A$NV+n5 z@>mN34=$&?o0dWTM@^_2StJW&6}3UA#S!JNOQX}Pntjm*hi+{82n=Egmrm*Fe1=er z#EZga{1+Y!byhT>TaR`Mb$_kk`)&Z==wL36dY%0!Y!^CFAIj`{uGeq2UK}=~vJ!5K z^QtO|5^jr-t$O`lp}4abNBvmzbiI-vi_(8nskmOSDlxoczhJ24pge29D=kmw;Rm}w zGceMew_-xEQ9?|y<>Zx-n&IYC6MS)kr%_*%_0klVC0U-}YAueOgs1U@k_EoPhHh_O znXvQr>#|;%;?HI6P4N(3&IRyMzq4`_9yHx{xEJp?4mwdtr0(^Pl;jx3dIN44ziA0( z&9#NDmh>CSwpn;;mgyn9H>(ujyICy}J^7SZ4$L$7sM!>6Bcpioxzvet-i2+$ZZ@#u zEozdgl$U)UNRY+M&waXY7a6}#YH*Yy{>Xd`gBja-jn!GMPaI-&g=>K7EZ1M@y3Jk2 tXYS&Yup+~>1j|H~4o zT^y0P1qbjvvL0iJR;KQ`IOar(QW2lHB zH292?%m#1>Y=pT3Q^96VpC)7ov`?iMXdKKyDfug^T+50 zru=Doj01l7Z$ot+51TN)Y<{e!9 diff --git a/lib/arm32/libstackman.a b/lib/arm32/libstackman.a index ce4199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{HR}tlxWUQ>gXh#?&iTd1AoTlSOKXVT z%LPw%+U(eF8o;fn1se^UTCEkd-9YVGHauf*ri1Z)+aX9gpiiUH@+1jgN6hhLi|WYm zj9pLq49-&ywQ4ho`(nX~sr;p&oWNDNRGf4-S#j2NgdJW`8f}{YfvP zgx33rv(T?@so%mRFru^3xj}Vkzv^YOBfL?OxMS|GD9Ph|=79fyk+_4iD|nqQ9l!7S eB={>>@~8A^r#Yj)=FvQ{Ea23?$G<`)H}Vf|)Nb(r diff --git a/lib/sysv_i386/libstackman.a b/lib/sysv_i386/libstackman.a index d5e977120323b9c8dc373f67db9902697b342880..1d91d87d0631057b92a0d6d3acae7e872c27a291 100644 GIT binary patch delta 842 zcmYjPJ8u&~5T3c0AHgq3EFcD7NP=x3htC)=G$6UKM52%;5(Nm^i4|GIC*+3&1#t<5 z3(QD}4k0S)P$2jNDP4d>k9bIkUqHjmX;)#S+3(x$o1NX;y&rQgv(Ili5eFdROg3(t zS1L97=oHt+CWKK9$08hs43wDLfR;#@;NjGgP!)z15oTI;Cm3)+2A7k^X3YG2p62k< zy3d{sR@ej)|0WZ_fUI&d$s0B1cR3B_DQt@~4Emj&puO!%%f|YqTlcTJzVB6Og72w^ zv$S9=-RKXRTMxR;05tKo02=lBb+@?L8U}-5xWp^3_``7O?^P;Zxmr>(Wvp3BMo-h! za9^0|(G2f=7$zKn{~JfyLcSdNezbuvhLNu?tMH^CU(tf{*#a~G&M5z^!m>i}`j5MV zW{Yvq6QtkK9KALD=o}KT~qYa%43rv zb^)K#MY}LMU`NiK;*>{{7nFIEQ(i#FYbKZVgi(9P>*56Rysaw}-Wmo=x%-M-S%s94?J*k-Psxpzy+u=)-KjK%06FU^VuZ;l=cOA+H~Vh04(BoIF$3k;gHHW zefP3(FvJ$|I4rP5l)$}P@kX~3w_A}c-Pl}hK76zqPo|*Wggf*1quHsM=vIB2UgJkP z@F(c28l;^dinvQ(JWzcsz~hJZRULgYUZs^iL*~!KIq2`sn_6a(jZ|R z;eH@vm0`-PC0=5cVWskx!AKggPq}V_rMt){*8c($kvdVn9_Q1#H=LXRpi;It_$1-j zIr)zCSeI$X4itWJ*%wZRta*BGhjE*J*sA%>$9_hKc2-X{Zo0n**Y}$K98S6pi8=3T rPV*t$J8bDB3C{EBJ^7r diff --git a/lib/win_arm/stackman.lib b/lib/win_arm/stackman.lib index 2b515b5ef4c3f3470456d7528f02ee271b48bd20..63ddf917bfe985bdaf34ba6afa939d34d0e3e0f9 100644 GIT binary patch delta 468 zcmeB@e&Ijf?@JBJ{3i_D_bt+>D` DSIB~+ delta 497 zcmaDP*CoH<7!z|?DdXgmOuCF=o4+$fG76iSD1bo%*AYe*1`w#2oXnEVcw+K-7H!6e z$-h|^a|5+72s6ksfV8e;y~J!_Y`(dUEr(J47XzypNQ;7QYDGzEQC?z>Rcc*P=D7L%3vlqM_iXitvk7Ul*T5R;jgoKu>TI(Z?lDo~u0hvD<5 zk4%gZ^CoZPFa_B%`3?70aYIW36GJ_Nn9}5;5+#O@pP+V5R^&6B9LpuZ0+OHnhsOiL z@Zj}<>nP9618L!cnF`gx4Kp#hpkVSGUc<=(Tx^qna7j&O;dB8xPY}s@N+4%_n*5v- z?s$HXY+^}HZdx+f50n3KG_o*!`uJ<|Z5~;O8)kAka>48<&7HiE(-I=C#pTQg6Nk8M z@>yP0wrM~gaSKd-!)XPV1-cBVVDfxUZIHuQBS5a0oX4l4Sk=b9KU}wEG56b@#~m-H cWPm~+1RRp{a|`q`Q^F>1<|_q8o+iH~08=-T$^ZZW diff --git a/lib/win_arm64/stackman.lib b/lib/win_arm64/stackman.lib index 68c06e032ad94c4fc53776b089e24794a9b111ee..2b0340bbf6d25d1ed2e55438b7cbdc167d0a0ede 100644 GIT binary patch delta 817 zcmZp&-)A@B9Me1DjTa6vF`p`Bm^_tPm+{o*!^{zkBIXvx3Sf}Hm9mPB0R)mJ>$C1= z44M3zRh!XhvN+pPZlE3pVFpQ&RxyyVlLdG!ChN%vgCzw8tS2W(8cpsJF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-l;8tdtDx9_Wv2(jFZ-Xuo&$=Gg)_8@8HVK2BMy7s z)Rg@J5o@UbXcvEg>xto%y;1|2KUOC@Y!eNZY z;$*Nme4#^Jxj5=$eO$uZyEi?cB-t#00_uCZyLhk9H=-cJIcBi$fS20~^h^VqJ&$O` VPhb8W0DehWOnO>L6fb(7`VS#iKq~+M delta 1103 zcmYjPZA@Eb6h7~53;hBM7fR(LE%du=T_>Yc+SSs!59LoBWyGn?CwIT6LNY?&K)KY)3Xd++l;=XsxV z&U@c4nRl2|SL8A#Mev$@LguOPa)%XjgfQG-W`G#H)gF@=-Rb~QfDpD)fNZ>?d`zX) z0%!?<0i7zdq9qGp0C%d4iZl)I3Z_(cYRQDhRpT1o9cU;4{>yDwcMwv;y{Gv}j_>Ot zn4MEU)YKX(yxO_AP8Bb{JXCe(48SG6kdB=1zi@W>*2rStA!7meT2}@@IbTjk{Il+c zFRCv6i2a{kI5JiLHNcA^-#*lJ@uZoad$&Ae?z(Yy9AHM|$I{uaKjLevI6ZB6YU=E^ zVt^b<@R76Tsj+eM(2mi~t_kME?dJi)V&cYF@8t9k^!BE#{d&5vnG+gGx z9i;4k?qWyo=U^clGV~f9e}njEU;{T?m>|@#4Y*kJGj;e;?z`eQWR&s=jx|w)>hHwv z(xbxV#HG?CnaAF;?_J^83qF76F8`CQ4T0Uwt&M^9t$x$`a5@=I#DYD(jtWo{g`V#g zaEsZA#9_fUMV)9;Yd2xkktM8Y-jod{d!l(5%ch4`ZBqQND}$TZW47Wsx Date: Tue, 13 Aug 2024 11:28:34 +0000 Subject: [PATCH 109/115] Format readme --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4ab8b04..36e4c46 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ [![build test and commit](https://github.com/kristjanvalur/stackman/actions/workflows/buildcommit.yml/badge.svg)](https://github.com/kristjanvalur/stackman/actions/workflows/buildcommit.yml) # stackman + Simple low-level stack manipulation API and implementation for common platforms ## Purpose + This library aims to provide a basic API to perfom stack manipulation on various platforms. Stack manipulation involves changing the machine stack pointer while optionally saving and restoring the stack contents. @@ -29,10 +31,14 @@ Additionally, it provides a set of pre-assembled libraries for the most common platforms so that no assembly steps are required by users. ## Features + - Simple api + - `stackman_switch()` and `stackman_call()` are the only functions. - The caller provides a callback and context pointer to customize behaviour. - Simple implementation + +- Simple implementation + - The code involving assembly is as simple as possible, allowing for straightforward implementation on most platforms. - Complex logic and branching is delegated to the C callback. @@ -40,23 +46,33 @@ platforms so that no assembly steps are required by users. 1. Save and restore volatile registers and stack state on the stack 2. Call the callback twice with the current stack pointer 3. Set the stack pointer to the value returned by the first callback. -- Assembly support + +- Assembly support + The straightforward and application-agnostic switching allows the switching function to be implemented in full assembler. This removes the risk of inline-assembler doing any sort of unexpected things such as in-lining the function or otherwise change the assumptions that the function makes about its environment. This assembly code can be created by the in-line assembler in a controlled environment. + - No dependencies + The library merely provides stack switching. It consist only of a couple of functions with no dependencies. + - Stable + There is no need to add or modify functionality. + - Libraries provided. + The aim is to provide pre-assembled libraries for the most popular platforms. This relieves other tools that want to do stack manipulation from doing any sort of assembly or complex linkage. Just include the headers and link to the appropriate library. ## Supported platforms + The current code is distilled out of other work, with the aim of simplifying and standardizing the api. A number of ABI specifications is supported, meaning architecture and calling convention, plus archive format: + - win_x86 (32 bits) - win_x64 - win_ARM64 (experimental) @@ -65,7 +81,8 @@ calling convention, plus archive format: - AAPCS (32 bit arm) - AAPCS64 (64 bit arm) -Supported toolchains: +### Supported toolchains: + - Gnu C - clang - Microsoft Visual Studio @@ -74,16 +91,21 @@ Other platforms can be easily adapted from both existing implementations for oth projects as well as from example code provided. ## API + There are two functions that make up the stackman library: `stakman_switch()` and `stackman_call()` who both take a `stackman_cb_t` callback: + ```C typedef void *(*stackman_cb_t)( void *context, int opcode, void *stack_pointer); void *stackman_switch(stackman_cb_t callback, void *context); void *stackman_call(stackman_cb_t callback, void *context, void *stack); ``` + ### stackman_switch() + This is the main _stack manipulation_ API. When called, it will call `callback` function twice: + 1. First it calls it with the current opcode `STACKMAN_OP_SAVE`, passing the current `stack_pointer` to the callback. This gives the callback the opportunity to _save_ the stack data somewhere. The callback can then return a **different** stack pointer. @@ -98,14 +120,17 @@ Depending on how the callback function is implemented, this API can be used for saving a copy of the stack, perform a stack switch, query the stack pointer, and so on. ### stackman_call() + This is a helper function to call a callback function, optionally providing it with a different stack to use. + 1. It saves the current CPU stack pointer. If `stack` is non-zero, it will replace the stackpointer with that value. 2. It calls the callback function with the opcode `STACKMAN_OP_CALL`. 3. It replaces the stack pointer with the previously saved value and returns the return value from the callback. This function is useful for at least three things: + - To move the call chain into a custom stack area, some heap-allocated block, for example. - To query the current stack pointer - To enforce an actual function call with stack pointer information. @@ -114,17 +139,21 @@ The last feature is useful to bypass any in-lining that a compiler may do, when a proper function call with stack, for example, when setting up a new stack entry point. ## Usage + - Include `stackman.h` for a decleration of the `stackman_switch()` function and the definition of various platform specific macros. See the documentation in the header file for the various macros. - Implement switching semantics via the callback and call `stackman_switch()` from your program as appropriate. See tests/test.c for examples. -There are two basic ways to add the library to your project: +There are two basic ways to add the library to your project: Using a static library or inlining the code. + ### static library (preferred) + - You link with the `libstackman.a` or `stackman.lib` libraries provided for your platform. ### inlined code + - You inlude `stackman_impl.h` in one of your .c source files to provide inline assembly. - You include `stackman_impl.h` in an assembly (.S) file in your project to include assembly code. - (windows) You include `stackman_s.asm` in an assemby (.asm) file in your project. @@ -132,7 +161,9 @@ There are two basic ways to add the library to your project: over separate assembly language source. ## Development + ### Adding new platforms + 1. Modify `platform.h` to identif the platform environment. Define an ABI name and include custom header files. 2. Use the `switch_template.h` to help build a `switch_ABI.h` file for your ABI. @@ -140,8 +171,10 @@ There are two basic ways to add the library to your project: 4. Provide cross-compilation tools for linux if possible, by modifying the `Makefile` ### Cross-compilation + Linux on x86-64 can be used to cross compile for x86 and ARM targets. This is most useful to generate assembly code, e.g. when compiling stackman/platform/gen_asm.c + - x86 requires the -m32 flag to compilers and linkers. - arm32 requires to use the arm-linux-gnueabi-* tools, including cc and linker - aarch64 requires the aarch64-linux-gnu-* tools. @@ -151,23 +184,27 @@ The x86 tools require the **gcc-multilib** and **g++-multilib** packages to be i platforms may need to be done independently. #### Cross compiling for x86 (32 bit) on Linux + - install __gcc-multilib__ and __g++-multilib__ - *compile* **gen_asm.c** using `gcc -m32` - *make* using `make PLATFORMFLAGS=-m32 test` #### Cross compiling for ARM (32 bit) on Linux + - install __gcc-arm-linux-gnueabi__ and __g++-arm-linux-gnueabi__ - install __qemu-user__ for hardware emulation - *compile* **gen_asm.c** using `arm-linux-gnueabi-gcc` - *make* using `make PLATFORM_PREFIX=arm-linux-gnueabi- EMULATOR=qemu-arm test` #### Cross compiling for Arm64 on Linux + - install **gcc-aarch64-linux-gnu** and **g++-aarch64-linux-gnu** - install __qemu-user__ for hardware emulation - *compile* using `aarch64-linux-gnu-gcc` - *make* using `make PLATFORM_PREFIX=aarch64-linux-gnu- EMULATOR=qemu-aarch64 test` ## A note about Intel CET + Intel's *Control-Flow Enforcement Technology* is incompatible with stack switching because it employs a secondary *Shadow Stack*, that the user-mode program cannot modify. Unexpected return flow after a stack switch would cause the processor @@ -179,6 +216,7 @@ code may be run in such a protected environment. See https://software.intel.com/content/www/us/en/develop/articles/technical-look-control-flow-enforcement-technology.html for more information ## History + This works was originally inspired by *Stackless Python* by [Christian Tismer](https://github.com/ctismer), where the original switching code was developed. From 87ef6417a605de4499fffa42ca2a0c5350f074f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 13 Aug 2024 11:28:44 +0000 Subject: [PATCH 110/115] fix typo --- stackman/platforms/switch_x64_msvc.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stackman/platforms/switch_x64_msvc.asm b/stackman/platforms/switch_x64_msvc.asm index 5143276..998eb24 100644 --- a/stackman/platforms/switch_x64_msvc.asm +++ b/stackman/platforms/switch_x64_msvc.asm @@ -104,7 +104,7 @@ NESTED_END stackman_switch, _TEXT$00 stackman_call PROC FRAME push rbp .pushreg rbp - ; now our stack is 16 byte aligned. don't need additional spacle + ; now our stack is 16 byte aligned. don't need additional space ;sub rsp, 040h ;.allocstack 040h lea rbp, [rsp+00h] From 278103bdb635fc091e085191edcdec7bf1424744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 13 Aug 2024 11:28:51 +0000 Subject: [PATCH 111/115] Remove unused vars --- tests/test.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test.c b/tests/test.c index e6b726e..a8beffc 100644 --- a/tests/test.c +++ b/tests/test.c @@ -254,8 +254,6 @@ void test_04(void) /* test stackman_call() with a null stack pointer */ void test_05(void) { - char *block, *stack, *stack2; - int i, cnt; ctxt01 ctxt; assert(STACKMAN_STACK_FULL_DESCENDING); From 4d5e4c215c2dc5d48bd36d461fe94e357afc73f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 13 Aug 2024 11:29:27 +0000 Subject: [PATCH 112/115] format python helper --- tools/strip-lib.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tools/strip-lib.py b/tools/strip-lib.py index a64aa97..f783d81 100644 --- a/tools/strip-lib.py +++ b/tools/strip-lib.py @@ -7,8 +7,8 @@ # There are some additional fixes added for reproducability, such as fixing the zero-padding of names in the coff # section headers. -import sys import struct +import sys verbose = True @@ -96,8 +96,6 @@ def read_lib(fp): print("coff length:", len(result["o"][-1])) h = None - return result - def write_lib(fp, lib): fp.write(libheader) @@ -184,15 +182,13 @@ def first_lm_read(fp): offsets = [] strings = [] - for i in range(nos): + for _ in range(nos): offset = fp.read(4) offsets.append(struct.unpack(">L", offset)[0]) - for i in range(nos): + for _ in range(nos): strings.append(readcstr(fp)) return {"offsets": offsets, "strings": strings} # sometimes there is an extra \0a after the strings - p = peek(fp) - return zip(offsets, strings) def first_lm_write(fp, lm): @@ -208,16 +204,16 @@ def second_lm_read(fp): # number of members m = struct.unpack(" Date: Tue, 13 Aug 2024 11:32:58 +0000 Subject: [PATCH 113/115] Add solution files for VS2022 --- vs2022/stackman.sln | 44 +++++ vs2022/stackman/stackman.vcxproj | 230 +++++++++++++++++++++++ vs2022/stackman/stackman.vcxproj.filters | 67 +++++++ vs2022/stackman/template.c | 15 ++ vs2022/test/test.vcxproj | 152 +++++++++++++++ vs2022/test/test.vcxproj.filters | 22 +++ 6 files changed, 530 insertions(+) create mode 100644 vs2022/stackman.sln create mode 100644 vs2022/stackman/stackman.vcxproj create mode 100644 vs2022/stackman/stackman.vcxproj.filters create mode 100644 vs2022/stackman/template.c create mode 100644 vs2022/test/test.vcxproj create mode 100644 vs2022/test/test.vcxproj.filters diff --git a/vs2022/stackman.sln b/vs2022/stackman.sln new file mode 100644 index 0000000..6dff39b --- /dev/null +++ b/vs2022/stackman.sln @@ -0,0 +1,44 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}" + ProjectSection(ProjectDependencies) = postProject + {BF7D0638-AC4F-4206-B426-66CDDD468281} = {BF7D0638-AC4F-4206-B426-66CDDD468281} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stackman", "stackman\stackman.vcxproj", "{BF7D0638-AC4F-4206-B426-66CDDD468281}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM.ActiveCfg = Debug|ARM + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM.Build.0 = Debug|ARM + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|ARM64.Build.0 = Debug|ARM64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x64.ActiveCfg = Debug|x64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x64.Build.0 = Debug|x64 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x86.ActiveCfg = Debug|Win32 + {CAFDBD3E-9D0D-4E90-BB6D-6C2A19F5EF53}.Debug|x86.Build.0 = Debug|Win32 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM.ActiveCfg = Debug|ARM + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM.Build.0 = Debug|ARM + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|ARM64.Build.0 = Debug|ARM64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x64.ActiveCfg = Debug|x64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x64.Build.0 = Debug|x64 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x86.ActiveCfg = Debug|Win32 + {BF7D0638-AC4F-4206-B426-66CDDD468281}.Debug|x86.Build.0 = Debug|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A71982F0-A89C-45AB-9F23-149A1983A11B} + EndGlobalSection +EndGlobal diff --git a/vs2022/stackman/stackman.vcxproj b/vs2022/stackman/stackman.vcxproj new file mode 100644 index 0000000..cb9614a --- /dev/null +++ b/vs2022/stackman/stackman.vcxproj @@ -0,0 +1,230 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + + 16.0 + Win32Proj + {bf7d0638-ac4f-4206-b426-66cddd468281} + stackman + 10.0 + stackman + + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)\..\lib\win_x86\ + $(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\..\lib\win_x64\ + + + true + $(SolutionDir)\..\lib\win_arm\ + + + true + $(SolutionDir)\..\lib\win_arm64\ + + + + Level3 + true + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + NotUsing + pch.h + OldStyle + + + + + true + + + /Brepro %(AdditionalOptions) + + + + + + + + + + + + + + + false + Default + + + AssemblyCode + AssemblyCode + AssemblyCode + false + false + false + Default + Default + Default + false + false + false + true + true + false + true + + + + + false + true + true + true + + + Document + true + true + true + + + true + true + true + + + true + true + true + + + + + + + + \ No newline at end of file diff --git a/vs2022/stackman/stackman.vcxproj.filters b/vs2022/stackman/stackman.vcxproj.filters new file mode 100644 index 0000000..9f57a1f --- /dev/null +++ b/vs2022/stackman/stackman.vcxproj.filters @@ -0,0 +1,67 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + + + Source Files + + + Source Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/vs2022/stackman/template.c b/vs2022/stackman/template.c new file mode 100644 index 0000000..2fe7dbd --- /dev/null +++ b/vs2022/stackman/template.c @@ -0,0 +1,15 @@ +#include "..\..\stackman\stackman.h" + +/* + * template file to create assembly code (template.asm) to modify and add to real assembler. + */ + +void* stackman_call_templ(stackman_cb_t callback, void* context, void* stack) +{ + // We use this variabl here for the template generation. Int the modified assembly + // code, we will store the ebp (base pointer) in that place on the stack, + // before storing the original unmodified stack pointer there. + void* localvar = stack; + return callback(context, 2, localvar); + +} \ No newline at end of file diff --git a/vs2022/test/test.vcxproj b/vs2022/test/test.vcxproj new file mode 100644 index 0000000..266eb72 --- /dev/null +++ b/vs2022/test/test.vcxproj @@ -0,0 +1,152 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + + 16.0 + Win32Proj + {cafdbd3e-9d0d-4e90-bb6d-6c2a19f5ef53} + test + 10.0 + + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + true + + + true + + + true + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\stackman + + + Console + true + ..\..\lib\win_x86;%(AdditionalLibraryDirectories) + stackman.lib;%(AdditionalDependencies) + + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\stackman + + + Console + true + stackman.lib;%(AdditionalDependencies) + ..\..\lib\win_x64;%(AdditionalLibraryDirectories) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\stackman + + + Console + true + stackman.lib;%(AdditionalDependencies) + ..\..\lib\win_arm;%(AdditionalLibraryDirectories) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\stackman + + + Console + true + stackman.lib;%(AdditionalDependencies) + ..\..\lib\win_arm64;%(AdditionalLibraryDirectories) + + + + + + + + + \ No newline at end of file diff --git a/vs2022/test/test.vcxproj.filters b/vs2022/test/test.vcxproj.filters new file mode 100644 index 0000000..154d04b --- /dev/null +++ b/vs2022/test/test.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file From f9f82c9b0288594e3ae5e09636fe22cee8271be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Tue, 13 Aug 2024 11:53:10 +0000 Subject: [PATCH 114/115] update build workflow --- .github/workflows/buildcommit.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/buildcommit.yml b/.github/workflows/buildcommit.yml index 7834d97..d858b1f 100644 --- a/.github/workflows/buildcommit.yml +++ b/.github/workflows/buildcommit.yml @@ -30,7 +30,7 @@ jobs: PLATFORM_PREFIX: ${{matrix.platformtools}} EMULATOR: ${{matrix.emulator}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: install multilib run: sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib if: ${{ matrix.name == 'i386' }} @@ -53,7 +53,7 @@ jobs: path: lib/${{ env.abiname }}/libstackman.a build-windows: - runs-on: windows-2019 + runs-on: windows-latest strategy: fail-fast: true matrix: @@ -71,17 +71,17 @@ jobs: folder: arm64 steps: - - uses: actions/checkout@v2 - - uses: microsoft/setup-msbuild@v1.0.2 + - uses: actions/checkout@v4 + - uses: microsoft/setup-msbuild@v2 - name: build - run: msbuild.exe vs2019\stackman.sln /p:Platform=${{matrix.platform}} + run: msbuild.exe vs2022\stackman.sln /p:Platform=${{matrix.platform}} - name: strip timestamps from lib run: python tools/strip-lib.py lib/win_${{matrix.platform}}/stackman.lib - name: rebuild after stripping - run: msbuild.exe vs2019\stackman.sln /p:Platform=${{matrix.platform}} + run: msbuild.exe vs2022\stackman.sln /p:Platform=${{matrix.platform}} - name: test if: ${{ matrix.native == 'yes' }} - run: vs2019\${{matrix.folder}}\Debug\test.exe + run: vs2022\${{matrix.folder}}\Debug\test.exe - name: Upload build artifacts uses: actions/upload-artifact@v4 with: @@ -93,7 +93,7 @@ jobs: needs: [build-linux-gnu, build-windows] if: ${{ github.event_name == 'push' }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: path: lib From cbf4e149a41f6c6ac553b1d17adff1526de54fc3 Mon Sep 17 00:00:00 2001 From: Automation tool Date: Sun, 8 Sep 2024 10:29:30 +0000 Subject: [PATCH 115/115] Automated build --- lib/win_arm/stackman.lib | Bin 3938 -> 4982 bytes lib/win_arm64/stackman.lib | Bin 7998 -> 9414 bytes lib/win_x64/stackman.lib | Bin 6090 -> 7150 bytes lib/win_x86/stackman.lib | Bin 11074 -> 21610 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/win_arm/stackman.lib b/lib/win_arm/stackman.lib index 63ddf917bfe985bdaf34ba6afa939d34d0e3e0f9..0b34d1112c5d1b186516bcad8db92f2e81c23f19 100644 GIT binary patch delta 1712 zcmaJ>eMnnZ6hC<{N%Q#CMxDh{Z0DRU>0Z+$t*Lp&B{3Zq z8o{=Mu`$*QLdObPg!zw9oPX>CVT`dAMAttG+o0{}=sxHQTkKX=8FlBrGz^9t9iK0nDq(Ewx=+gIKef{H=a1cOsXGo(7;8 z4PVC<^cjSPcvUM+V$SRTb;AB zKYf1UJL8f1D;3v%{^ae_3nR^8$=M9>uFN~Rcx`c^!!ma6==Ni;ls$Re-5MExX9tC=ea)P%+Z+P_h*8-BX_L#CjlNIag`j> z>>_(vy+OG^K12>{N-1PfAd%h^-=D{e4a)Z@Kn|4>)MpBtavzxQ2cW%x%>!CESY);W zOyt)Vn96$`ETE^yVS%sn9tXdnN4wS{mr6YjcH;dTWvo2!ao|VKBx5hC@YkR&2P$gh zfu@=hgn&{MWD}%9TS6v{yJ+Wj8_RU{9=@*LBe=-A1#rF%TUL#mG}#>AIk|5Dcbb(y5Tl84gG6und}Ku|BZ54%q$A z2f7pS(}|#D>xjl8NhQHPQxy^Qmr6Er3R}r_y+C-w6wceLAp2Cw*cDAB1BcpsI{IE} z>k8EKKHd{JfVJU!$*QSR$&QD%7RsZw)A*#hd|kY<5Z_!rqso;}D!DRc!#>khVl|Xo zh9x^ZTF$QI>p_Z#95<9=se1CV`E|-6pBnTmEN97**{SPAq7mBxiOt1pwFWSc&D954 zGRQf1pIyjmxZ_#2am4ZGo&j$Elo0hz6#pfCJkt|N>rV3`0e1_mGk1HF`@)Z~(~R4A9h0La)fxtT>-Zw-+31SSln z9T)_h^ioojO4C(BU{VV>7#JonPX5E9#HIigGvJ!6!deJ%sp#Z2t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git a/lib/win_x64/stackman.lib b/lib/win_x64/stackman.lib index f3afbc53c02c26e15ab7529347209872174377e5..f51e16e81b0d2111440c174305d2dc7a62bba96b 100644 GIT binary patch delta 2028 zcmaJ?drXs86hB`JUHRHdTM8A4Qc3}FP}>3pA1F{joNQreh+7&zN?WARk0LE-(4@Mk zdqlS3-AvpxGRLObBvWw9W`eq9*%tSZKen(3ESl(EA!u=nN@m=-Ut5dlJmj|L{?3nk z&pr3tUoR}3Dt>iHeqIhB0ssd8`s&jACf-geHt7UwWLyk~hyh*> zqaY{c3aw-%5+n)3--xz}>g&*FaOlL>p3t7#S@U62@(<#l>+MxhIAB4Rp8v}A}8bKOS=6Q6B15H7m-j>8s#cg3#El-V?m+W zVj}8<$>6`ZV=@kzkRWYtYjO*t&?v zLL+)w0dqw>7H|=ez&sLUOGPz%hR?EbOgycnoNUpil1s8%sRbn#Ypm!PLd#X)jwB>c zW5$U>k=am#m6v0V8|ZRqERHfzRv3AIx3iUZ3Lt*a|Nc0_iDJk*Z*;kvx;7g&M6pV| z#gRC&Nuif4MvPIAy^1ZgZnqWra#~|r1fkZJdD+1bQoh8I3v!hXzr)6HmU2r;^)hP_ z=illHI9s@F)u7UleeP+_r zpZ}xTuzjO!@EI?AUG0$8Pbjav1#kn2cgbL!fsGc#=)|Xykr!lvvdN(8I0+_aiGc2?C;jT<3ZvP+w%zINa=GnYJUOYEuZA1bp{dA$ zA2?<#wdER})9q&>JW{UKV8UOJ8_8Nym69V} zg#j5hh7dTCqE_FRzFwEV5y^5yyxVcT44lIRGG7O@^Breh17EZVMXMY-DB$0w| z%18CqOAiT2MGGQ?!XA7O-vWE6q#^<%2UF-F`giVarb(U4J^c86-*?XM`<-+0O^fwY z4>dCy00saE{iaXsnSOIy*XS4Iah?lLurvg4Fo#4&*qkxEaUUY z)d1yWGE!~7{AnClg|qo{&kkn+T4}7D+`RU2GUTz%CEZ=ARcrie?ndbZL%yS(bu!)n zwzDk?J1nMgoZZVV!yz6*7sL2KVOD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