2
0
mirror of https://github.com/boostorg/context.git synced 2026-01-19 04:02:17 +00:00

319 Commits

Author SHA1 Message Date
David CARLIER
739ee59db2 make_fcontext darwin arm64 removes workaround LLVM IR supports label to adr ins since couple of years already 2021-04-01 10:41:42 +01:00
Oliver Kowalke
0416c11f00 Merge pull request #160 from dixyes/combined-add-arms
Add arm and arm64 into combined asm codes
2021-03-01 07:39:05 +01:00
dixyes
1c763c9796 Add arm and arm64 into combined asm codes
Apple silicon M1 uses arm64 architecture, this commit will add arm and
arm64 architecture into combined asm code in order to support newer
apple's machine in combined asm codes.
2021-03-01 09:27:44 +08:00
Rosen Penev
275bf84228 fix softfloat support for MIPS64 ASM
Added define also found in the MIPS32 ASM files.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-02-12 18:00:04 -08:00
Eric Astor
e47fc8b730 Add variants for clang targeting Windows without MASM support
This is not an officially-supported Boost toolset, but is consumed by at least one user.
2020-08-24 11:55:14 -04:00
Julien Schueller
d52ce8ca89 Revert "Fix exports for 32-bit GNU assembler files targeting Windows."
This reverts 85783e8, as the wrong linker was used

Closes #136
2020-08-20 12:55:24 +02:00
Harald van Dijk
5ace4ff3a5 Fixes for x32 ABI.
In the x32 ABI, pointers take up 4 bytes, so a structure containing two
pointers is passed and returned in a single 8-byte register.
2020-06-28 22:11:44 +01:00
Andreas Krebbel
e0ba57928d IBM Z: Fix fcontext routines 2020-02-21 08:47:46 +01:00
YunQiang Su
e115983fdf mips64/n64: .align 3
The right align for mips64/n64 is 3 instead of 2.
2019-12-18 03:48:43 -08:00
Andreas Schwab
e86c66714c Fix non-PIC in RISC-V assembly
Since this ends up in a shared library we should use a PLT call.  Also,
the finish label is local, so we can use lla instead of la.
2019-12-06 22:49:43 +01:00
Eric Astor
bebf903239 Mark 32-bit GNU assembly files targeting Windows as /safeseh linking compatible.
We set the LSB of the magic symbol @feat.00 to 1.

This is used to communicate from the compiler to the linker, and specifically to express that the object file has opted into "safeseh"; any SEH handlers used in this file must be listed in the .sxdata section.

Since we don't have any SEH handlers in these files, this is trivially satisfied.

Reference: the PE-COFF specification, https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-sxdata-section
2019-11-27 22:30:46 -05:00
Eric Astor
85783e8cbb Fix exports for 32-bit GNU assembler files targeting Windows.
The incorrect exports can cause linker issues (at least when using LLVM's lld-link) claiming that these primitives are not available.
2019-11-22 11:08:41 -05:00
George Koehler
df8fb6b528 Fix ppc32 on Linux musl, NetBSD, OpenBSD; fixes #120
This fixes fcontext on my PowerBook G4 running Void Linux
ppc-musl-20190901, NetBSD/macppc 8.1, or OpenBSD/macppc 6.6-current,
all with g++.  These systems use fcontext for *ppc32_sysv_elf*
(PowerPC 32-bit System V ELF).  The assembly code was wrong for BSD
and crashing on Linux musl.

Linux returns a transfer_t in memory (through a hidden pointer in R3),
but other systems (at least NetBSD and OpenBSD) return a transfer_t in
registers R3:R4.  jump_fcontext() and ontop_fcontext() were always
using the hidden pointer.  Add checks for `#ifdef__linux__`; start
using R3:R4 on other systems.

make_fcontext() was calling _exit(0) through the insecure BSS PLT.
Set R30 to use the secure PLT.  This prevents a crash when musl's
ld.so loads the executable; musl seems to require the secure PLT.

Fix ontop_fcontext() to restore the hidden pointer on Linux.  It was
passing the wrong context's hidden pointer to the ontop-function fn(),
so fn() returned a transfer_t to the wrong stack.  When fn() was
context_exit() in <boost/context/continuation_fcontext.hpp>, it freed
the old stack, then returned `transfer_t{ nullptr, nullptr }` to free
memory.  This crashed on Linux musl.

Now that ontop_fcontext() restores the hidden pointer, it must stop
abusing the same pointer to pass a transfer_t argument to fn().  Add a
new ontop_fcontext_tail() in C++, which takes arguments in registers
and allocates a transfer_t.  The code is in C++ so it can free the
transfer_t argument if fn() throws a C++ exception.

Rearrange the context frame to shrink it from 244 to 240 bytes.  This
fixes the stack alignment: the ABI requires R1 % 16 == 0, and
make_fcontext() respects this, but jump_fcontext() was adding 244 to
R1, so the new context ran with a misaligned stack (244 % 16 == 4).

Remove R13 from the context frame, so new contexts stop loading R13
with garbage.  The ABI uses R13 to point to the executable's small
data, so R13 should have the same value in every context.

Add the backchain to the context frame; make room by moving LR to the
caller's frame.  Order CR, R14 to R31, F14 to F31 at the frame's end,
as is typical for this ABI.  Provide 8-byte alignment for FPSCR and
F14 to F31, to avoid a misalignment penalty.
2019-10-19 14:06:24 -04:00
Neale Ferguson
b90917eaed Optimize s390x instructions 2019-09-20 13:23:19 -04:00
Naveenaidu
adecfdc88c S390x: Add Support for s390x arch 2019-09-06 20:08:10 +05:30
Oliver Kowalke
0c754f90c5 execution_context removed 2019-08-29 13:42:03 +02:00
Oliver Kowalke
9c772a7830 Revert "S390x Implementation: WIP" 2019-08-03 08:33:17 +02:00
Naveenaidu
4d0cd2a6ce jump_s390x_sys_elf: Add jump_context for s390x 2019-07-31 18:51:49 +05:30
Naveenaidu
99a29956f3 s390x_make_context: Fix stack frame 2019-07-31 18:50:38 +05:30
Naveenaidu
81e26a1618 make_context: Add s390x arch 2019-07-22 22:53:43 +05:30
Shawn Anastasio
2354eca9b7 Fix ABI violation on ppc64 ELFv2, fixes #72
The existing ontop_fcontext implementation for ppc64 ELFv2
violates the ABI by not storing the callback entry address
in %r12 before branching. This results in crashes on this
platform.

This commit addresses this and allows the context library
to function as expected on ppc64 platforms using the ELFv2 ABI.
2019-05-03 20:18:11 -05:00
Andreas Schwab
c8fb4a42f3 Add support for RISC-V LP64D 2019-04-09 14:15:31 +02:00
Oliver Kowalke
2741e7b771 Update jump_i386_sysv_macho_gas.S 2019-02-18 19:30:00 +01:00
tux3
8e0047654d Fix jump_i386_sysv_macho writing garbage to the x87 control word
It seems the macho code may have been modeled after the elf version,
which writes the returned transport_t through a pointer in eax,
however macho is expected to return its transport_t result in eax:edx.

The macho code mistakenly wrote its "data" return value through eax.
This happens to overwrite the saved fc_x87_cw before it is loaded,
resulting in floating-point exceptions and crashes in unrelated code.
2019-02-18 17:44:54 +01:00
Daniel Glaser
b1ec752540 Fixed a bug for armv7 by adding .syntax unifed to assembly sources 2018-12-02 12:56:51 +01:00
Jiaxun Yang
e3f744a186 Implement mips64 n64 elf
n64 ABI is very different from o32 ABI
2018-11-28 15:13:56 +08:00
Oliver Kowalke
bcc3ed785b Reproducibility: Set .file section for all *_elf_gas.S
- in context of #91

Add a .file directive to all *_elf_gas.S files to prevent the linker
adding a host build-system path as a FILE symbol to the object file.
Without this, the gnu linker adds a symbol like this:

thanks to Douglas Royds <douglas.royds@taitradio.com>
openembedded/openembedded-core
2018-11-24 19:36:27 +01:00
Oliver Kowalke
c999e42b7e add copyright statements 2018-05-22 08:55:00 +02:00
Oliver Kowalke
d08d608989 rename thread-local for fiber
- in context of #78
2018-04-11 06:23:29 +02:00
Oliver Kowalke
ac99b9bf25 prevent compiling compilation units for non-C++11 compilers 2018-03-12 12:14:50 +01:00
Daniel James
63f85b4c54 Fix braces in execution_context.cpp
When BOOST_NO_CXX11_THREAD_LOCAL is defined.
2018-03-11 18:34:30 +00:00
Oliver Kowalke
3ca5a272e7 fix C2492 (Windows/MSVC)
- in context of #73
2018-02-24 08:42:14 +01:00
Oliver Kowalke
a0433d1c72 execution_context without depended compilation
- execution_context v1 in namecpase v1
- execution_context v2 in inlined namespace v2
2018-02-05 19:34:35 +01:00
Oliver Kowalke
51ea6b583d re-introduce continuation - fix conflicts 2018-02-05 13:31:35 +01:00
Oliver Kowalke
10d3264f7b implementation of fibers without scheduler according to P0876R0 2018-02-05 13:31:32 +01:00
James Cowgill
9e7c5e0671 mips: simplify finish function
- Don't bother allocating any extra stack space. We can reuse the 16
  bytes at the top of the stack originally used for the gp and transfer_t.
- Don't bother saving the return address which we never read back.
- Use la to load the address of _exit (purely style).
- Move the "move $a0, $zero" instruction so the assembly can put it in
  the delay slot.
- Use "jr" instead of "jalr" because we don't expect _exit to ever
  return.
2018-01-11 14:38:35 +00:00
James Cowgill
3f6c3a0bb7 mips: allocate unused stack space for incoming argument area
The MIPS ABI requires that 16 bytes of unused stack space is allocated by
the caller when calling functions. Some comments refer to "shadow space"
which might be talking about this, but since the captured_context code
was added, the assembly has not actually allocated any extra space.

Therefore, allocate an extra 16 bytes between the fcontext_t data and
the saved GP which the initial function will use.

Also fix the address of the returned transfer_t which was incorrect
(although fairly harmless since this data is never read).
2018-01-11 14:37:34 +00:00
James Cowgill
e0d067c751 mips: optimize stack calculation in make_fcontext
This commit removes some useless moves which are later overwitten at the
start of the "make_fcontext" function.
2018-01-10 14:04:15 +00:00
James Cowgill
3d3bf4a1ec mips: perform jump through t9 in ontop_fcontext
The MIPS ABI requires all calls to be made "through" t9 (so the called
function can easily get its address).
2018-01-05 12:05:40 +00:00
James Cowgill
1491ce4424 mips: use v0 as temporary for returned transfer_t
For functions which return structures indirectly, the MIPS abi requires
the pointer to the returned structure to be in v0 (so in most cases v0
will contain the value passed to the function in a0).
2018-01-05 12:04:15 +00:00
James Cowgill
f410f4d80c mips: remove unused context diagram 2018-01-05 11:52:46 +00:00
Oliver Kowalke
75125efc6e set default stacksize to 128kB for all platforms 2017-11-05 07:55:56 +01:00
Oliver Kowalke
59ead04c0a move thread-local pointer of current action-record in compilation unit
- prevents error C4251 on Windows
2017-10-02 14:19:43 +02:00
Michael Johns
035d2d78f3 Fix i386/macho routines to correctly return transfer_t in EAX/EDX
The OSX 32bit ABI differs from the System V ABI in that 8 byte structs
are returned in registers EAX/EDX instead of passing the address of the
struct on the stack. See: https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/LowLevelABI/130-IA-32_Function_Calling_Conventions/IA32.html

The current implementation for this platform crashes when compiled for
32bit OSX (e.g. when running a 32bit iOS simulator) due to not
satisfying the ABI.
2017-08-24 19:05:57 +02:00
Oliver Kowalke
3bbc81a5e7 set default-stacksize to 64kB 2017-06-24 13:37:30 +02:00
Oliver Kowalke
e038a7402c fix minimum/default stacksize for POSIX 2017-06-15 18:06:11 +02:00
Oliver Kowalke
6de3a2b15f remove unused function page_count() 2017-06-10 15:32:48 +02:00
Oliver Kowalke
fa890b1c4d adapt Jamfiles for new properties 2017-06-04 20:27:03 +02:00
Oliver Kowalke
a72f69607f support WinFibers in callcc() 2017-06-04 20:27:03 +02:00
Oliver Kowalke
0f02a5ca2e 64kB default stack-size on POSIX 2017-06-01 18:20:02 +02:00