Commit Graph

135 Commits (master)

Author SHA1 Message Date
Ariadne Conill a04dc12d72 aarch64: add freestanding port 2020-12-06 13:50:50 +00:00
Ariadne Conill f3f52fc17c arm: add freestanding port 2020-12-06 13:43:04 +00:00
Ariadne Conill 7d149e6358 mips: add freestanding port 2020-12-06 06:34:56 -07:00
Ariadne Conill 20fd2b6f52 mips64: add freestanding port 2020-12-06 06:24:50 -07:00
Ariadne Conill 0c6077854a riscv64: add freestanding port 2020-12-06 06:10:00 -07:00
Ariadne Conill 50bb9432c8 s390x: add freestanding port 2020-12-06 12:37:08 +00:00
Ariadne Conill b33c7df219 s390x: update makecontext prototype 2020-12-06 12:30:44 +00:00
Ariadne Conill da736b6add ppc64: chase API changes related to freestanding stuff
freestanding is however NOT supported here
2020-12-06 12:23:09 +00:00
Ariadne Conill 131e825f50 x86: add freestanding port 2020-12-06 11:37:19 +00:00
Ariadne Conill 9c0ffd8fbb x86: fix conflicts with musl headers + freestanding adaptations 2020-12-06 11:24:23 +00:00
Ariadne Conill 9aef11752f x86_64: add freestanding port 2020-12-06 03:22:27 -07:00
Ariadne Conill a8415a0c4e m68k: add freestanding bits.h file 2020-12-06 03:53:45 -06:00
Ariadne Conill c31decc3d4 build: use internal definitions to replace things pulled in from ucontext.h 2020-12-06 03:44:45 -06:00
Ariadne Conill 40c8016144 bits: alias greg_t as libucontext_greg_t in non-freestanding builds 2020-12-06 03:40:55 -06:00
Ariadne Conill 0953d71ed1 build: fill in more details for freestanding builds 2020-12-06 03:31:48 -06:00
Ariadne Conill 2979186379 common: define libucontext_ucontext_t for non-freestanding case 2020-12-06 03:18:41 -06:00
Ariadne Conill e65e485630 everywhere: rename __swapcontext to libucontext_swapcontext 2020-12-06 03:04:22 -06:00
Ariadne Conill 37fe7afd5f everywhere: rename __setcontext to libucontext_setcontext 2020-12-06 03:03:07 -06:00
Ariadne Conill 99ed5bbe12 everywhere: rename __getcontext to libucontext_getcontext 2020-12-06 03:02:25 -06:00
Ariadne Conill 2f31efaa95 everywhere: rename __start_context to better descriptive libucontext_trampoline 2020-12-06 02:59:59 -06:00
Ariadne Conill c693dc663c rename __makecontext to libucontext_makecontext 2020-12-06 02:56:59 -06:00
Ariadne Conill fe19127c66 build: add support for EXPORT_UNPREFIXED=no
In an EXPORT_UNPREFIXED=no build, getcontext/makecontext/setcontext/swapcontext
symbols are not provided.
2020-12-06 02:54:01 -06:00
Ariadne Conill 15ba7b039c m68k: add startcontext trampoline 2020-12-06 02:24:49 -06:00
Ariadne Conill 5f6135c0f9 m68k: fixups for makecontext 2020-12-06 02:24:05 -06:00
Ariadne Conill 22520be2de m68k: fix register layout off by one 2020-12-06 00:52:05 -06:00
Ariadne Conill 89536b198d m68k: add swapcontext 2020-12-06 00:04:50 -06:00
Ariadne Conill c462af8a3c m68k: implement getcontext and setcontext 2020-12-05 23:54:36 -06:00
Ariadne Conill 76f1fd75b8 m68k: add makecontext() implementation 2020-12-05 23:30:39 -06:00
Ariadne Conill 5ee9c4e8a5 m68k: add register definitions 2020-12-05 23:22:40 -06:00
Ariadne Conill a6e76834d7 riscv64: align ucontext register access with musl 1.2 headers 2020-12-05 20:07:34 -07:00
Drew DeVault 5928947223 riscv64: fix PIC-incompatible assembly 2020-12-05 18:53:49 -07:00
Ariadne Conill b1ea2ae83b everywhere: use ucontext.h instead of signal.h for pulling in ucontext definitions
This allows building libucontext against newlib.
2020-12-04 11:19:02 -07:00
Ariadne Conill 34472b8884 riscv64: chase musl ab3eb89a8b83353cdaab12ed017a67a7730f90e9 changes 2020-12-03 18:25:04 -07:00
Ariadne Conill e11fa34822 riscv64: add makecontext() and __start_context() trampoline 2020-05-18 03:19:22 +00:00
Ariadne Conill e9308ef58f riscv64: add swapcontext 2020-05-18 02:48:28 +00:00
Ariadne Conill e32eb6ef59 riscv64: implement getcontext/setcontext 2020-05-18 02:43:27 +00:00
Ariadne Conill 4d42f482dc riscv64: add architectural defines 2020-05-18 02:19:14 +00:00
Khem Raj b6732f6884 Remove using .end directive with clang
Clang does not support this asm directive
Fixes Issue #19

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2020-04-10 11:23:39 -07:00
A. Wilcox 467ee2916d
x86: Update copyright statement
Commit d0ccf2f96f contains the makecontext
fix from Adélie commit aaeb73ea701388e55b7640e32509a5f6a57f6350[1], as
seen at AdelieLinux/libucontext@aaeb73ea – but it didn't include the
addition of my author line.

The full commit text, for future documentation/reference, was:

```
x86: Write link pointer at correct stack offset

It must come *after* the parameters, not *before*.
```

Fixes: d0ccf2f96f ("x86: modernize")
Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>

[1]: aaeb73ea70
2020-03-30 17:25:30 -05:00
Ariadne Conill d7d746f44e s390x: modernize assembly code 2020-03-30 01:12:07 -05:00
Ariadne Conill ef42ad682a s390x: fix makecontext(3) implementation for passing arguments via stack 2020-03-30 01:04:16 -05:00
Ariadne Conill f708c95659 arm: modernize 2020-03-30 05:04:18 +00:00
Ariadne Conill fb27ad693b aarch64: modernize 2020-03-30 04:38:53 +00:00
Ariadne Conill b04da78fb8 mips: use REG_OFFSET 2020-03-30 04:07:41 +00:00
Ariadne Conill 08e8a41d6c mips64: use REG_OFFSET 2020-03-30 04:05:00 +00:00
Ariadne Conill add34ddac7 mips: add MIPS O32 ABI implementation (closes #2) 2020-03-29 15:54:32 +00:00
Ariadne Conill d0ccf2f96f x86: modernize 2020-03-29 15:04:03 +00:00
Ariadne Conill d8cfe83e34 common: use REG_SZ, not SZ_REG in line with mips64 port for REG_OFFSET macro 2020-03-29 14:50:38 +00:00
Ariadne Conill 8631580fbb mips64: use ALIAS() macro for aliases 2020-03-29 14:37:13 +00:00
Ariadne Conill e00902b5b1 x86_64: modernize implementation 2020-03-29 14:27:40 +00:00
Ariadne Conill 2411cdfb54 common: add REG_OFFSET accesso 2020-03-29 14:27:19 +00:00
Ariadne Conill c385d69aa9 common: add ALIAS() macro 2020-03-29 14:12:23 +00:00
Ariadne Conill fd32a2fa8c common: factor out .ent handling 2020-03-29 14:03:18 +00:00
Ariadne Conill 2f4eb16f38 mips64: factor out frame management macros into arch/common/common-defs.h 2020-03-29 13:49:57 +00:00
Ariadne Conill 7c60f4576c mips64: elide emulation of the magic flag crap glibc does 2020-03-29 13:40:32 +00:00
Ariadne Conill 80a6ca3854 add mips64 implementation 2020-03-29 12:05:52 +00:00
Ariadne Conill d31eaabbaf update copyright statements, add mailmap 2020-03-27 09:23:49 +00:00
Bobby Bingham 2610c7faa7 ppc32/64: rewrite get/set/swapcontext in assembly
getcontext cannot be correctly implemented in C.

If this calls another function, as it does to call syscall, it needs to
first spill its return address to the stack.  If, after getcontext returns,
its caller then calls other functions, this saved return address can be
clobbered.  When the context saved by getcontext is later restored, the
(now clobbered) return address will be reloaded from the stack, and the
second return from getcontext will return to the wrong location.

Because the powerpc swapcontext syscall allows either the old context or
new context pointers to be null, it is usable for implementing all of
get/set/swapcontext.

We therefore rewrite swapcontext in assembly, and get/setcontext as simple
assembly function wrappers around swapcontext.

The one piece we keep in C is the code to check the return value of the
system call and to set errno.  This code was actually unnecessary before --
libc does this within syscall.  However, now that the system call is made
directly in assembly, bypassing libc, it is truly necessary.  Because errno
is thread-local and the details of how to set it can vary by libc, this
code remains written in C.
2019-04-05 14:44:54 -05:00
Bobby Bingham 90ff6330e6 ppc32/64: update copyright 2019-04-05 14:18:20 -05:00
Bobby Bingham 29eac4259a ppc32/64: remove unused includes 2019-04-05 14:18:20 -05:00
Bobby Bingham edf69879ea ppc64: remove unnecessary parentheses 2019-04-05 14:18:20 -05:00
Bobby Bingham 40d07758a5 ppc32/64: correct signature of function parameter to makecontext
Because makecontext can pass a set of integer arguments to the provided
function, it is incorrect to require that this function accept no
parameters.
2019-04-05 14:18:20 -05:00
Bobby Bingham a00a05ce29 ppc64: fix incorrect position of parameters within stack frame
On PPC64, there are 4 register-sized stack slots below the parameter save
area, which is different from the 2 stack slots on PPC32.
2019-04-05 14:18:20 -05:00
Bobby Bingham 8ea5f548b9 ppc64: fix makecontext with more than 8 parameters
The ELFv2 ABI used on PPC64 differs from the ELFv1 ABI used on PPC32 here.
On PPC64, once there are any parameters that need to be passed on the
stack, space needs to be reserved on the stack to pass all parameters.
Parameters 0-7 are still only passed by register, but if the callee needs
to spill them, it can use the stack space reserved for the corresponding
parameter to do so.
2019-04-05 14:18:20 -05:00
Bobby Bingham 55168fcb18 ppc32/64: simplify storage of stack parameters
The switch statement is simpler as an if/else, and removing the argp
variable makes the code more symmetric between the register and stack
parameter cases.
2019-04-05 14:18:20 -05:00
Bobby Bingham b500b054c7 ppc32/64: don't store uc_link on the stack
This was previously stored either in the CR (ppc64) or LR (ppc32) save
area of the stack, or to one of the parameter save slots.

In either case, the saved value was unused.  This value is also passed
to __start_context via r31, so there's no need to pass it on the stack.
2019-04-05 14:15:49 -05:00
Bobby Bingham b9bd4045fb ppc32/64: fix back chain pointer
The ABI states that sp[0] should point to the previous stack frame, or be
zero if there is no previous stack frame.  makecontext previously set this
slot to point to the __start_context function, rather than to a valid
stack frame.
2019-04-05 14:15:49 -05:00
Bobby Bingham b6a9b5e279 ppc32: fix stack alignment
The stack should be 16-byte aligned, not 8 mod 16.
2019-04-05 14:15:44 -05:00
A. Wilcox 6046eb47e4
Reorder registers in other x86_64 assembler files
This fixes the previous commit which changed the register order in
swapcontext only, which caused setcontext to subtly corrupt the stack.
2018-07-19 17:18:19 -05:00
Timo Teräs 790ed28aff fix x86_64 register order for swapcontext
rbp and rsi were reversed causing argument passing to fail since
rsi is used to pass 2nd argument.

fixes #9
2018-07-18 15:47:27 +03:00
William Pitcock a76df6b81a arch: add s390x port 2018-02-15 05:54:17 +00:00
William Pitcock f370b25ffc ppc64: trampoline: cleanups 2018-02-15 04:36:47 +00:00
William Pitcock f4d92bb7bd ppc: trampoline: cleanups 2018-02-15 04:36:36 +00:00
William Pitcock 0622245f06 x86_64: trampoline: do same cleanups as in x86 2018-02-15 04:34:37 +00:00
William Pitcock ef2fa49912 x86: trampoline: fix GOT clobbering, pointed out by fabled 2018-02-15 04:32:16 +00:00
William Pitcock 556da6ce99 x86/x86_64: getcontext: no need to restore %ecx or %rcx 2018-02-14 05:12:09 +00:00
William Pitcock 0143bbac98 x86: trampoline: kill textrel 2018-02-14 03:37:25 +00:00
William Pitcock 71979e9cf6 arch: ppc64: now working 2018-02-06 08:05:53 +00:00
William Pitcock 9e5aba6b48 arch: add ppc64 port does not work yet 2018-02-06 06:19:44 +00:00
William Pitcock f3fe8ea781 arch: ppc: new port 2018-02-02 18:46:21 +00:00
William Pitcock ee1526c903 arch: add x86 port 2018-02-01 01:26:34 +00:00
William Pitcock 13283f5eba arch: add aarch64 port 2018-01-31 21:23:18 +00:00
William Pitcock 247f30400c arch: arm: add armv6+ port 2018-01-31 04:11:46 +00:00
William Pitcock da10e5a66d implement ucontext functions on x86_64 2018-01-30 03:41:02 +00:00
William Pitcock 6062fc83b1 don't bother with glibc stuff afterall, kernel defines ABI to use 2018-01-29 21:50:49 +00:00