Commit Graph

58 Commits (d31eaabbaf5f45656c10e4bccd3fe6653a7d3ec1)

Author SHA1 Message Date
Ariadne Conill d31eaabbaf update copyright statements, add mailmap 2020-03-27 09:23:49 +00:00
Ariadne Conill 5f137a1fe4
Merge pull request #16 from gabrielivascu/master
Makefile: i386, i686 -> x86
2020-03-27 03:09:32 -06:00
Khem Raj 6cfab025e0 pass LDFLAGS to link step
This helps to use OE specific linker flags and fixes

do_package_qa: QA Issue: No GNU_HASH in the ELF binary

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2020-03-27 08:54:56 +00:00
Gabriel Ivașcu acff6c83eb Makefile: i386, i686 -> x86 2019-10-22 18:08:47 +03:00
William Pitcock 0b4f9ecf33
Merge pull request #14 from gabrielivascu/master
Makefile: Handle static library at clean/install
2019-04-14 19:33:06 -05:00
Gabriel Ivașcu 2e15b38327 Makefile: Handle static library at clean/install 2019-04-12 10:48:24 +03:00
William Pitcock 05cb8ecbee
Merge pull request #13 from gabrielivascu/master
Build static library too
2019-04-11 13:17:18 -05:00
Gabriel Ivașcu 9cc1a2c0e6 Build static library too 2019-04-09 16:07:39 +03:00
William Pitcock 7599fe5ff2
Merge pull request #11 from koorogi/ppc-fixes
Ppc fixes
2019-04-06 10:30:37 -04: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
Bobby Bingham cb59e7ee95 test calls to getcontext without makecontext 2019-04-05 13:28:36 -05:00
Bobby Bingham 94216c60c4 test ability to pass 10 args through makecontext 2019-04-05 13:28:36 -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
William Pitcock 4f190cc561
Merge pull request #10 from fabled/master
fix x86_64 register order for swapcontext
2018-07-19 00:33:12 -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 7b1a302ed4 README: we support s390x now 2018-02-15 05:55:26 +00:00
William Pitcock a76df6b81a arch: add s390x port 2018-02-15 05:54:17 +00:00
William Pitcock f0741bc7a0 build: use -lucontext instead of libucontext.so in linker flags for test program 2018-02-15 04:41:22 +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 70089a405c build: use absolute path for LD_LIBRARY_PATH when testing 2018-02-14 03:30:50 +00:00
William Pitcock 79415db5a8 README: update for 0.1.0 2018-02-14 03:06:01 +00:00
William Pitcock 0188f29771 build: remove test_libucontext on make clean 2018-02-14 03:01:35 +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 8ff8bb3280 README: note that ppc implementation uses kernel assistance 2018-02-02 18:51:55 +00:00
William Pitcock f3fe8ea781 arch: ppc: new port 2018-02-02 18:46:21 +00:00
William Pitcock 66919bb222 README: x86 now supported 2018-02-01 01:28:19 +00:00
William Pitcock c28af0399e build: rebuild test program if it is modified 2018-02-01 01:27:13 +00:00
William Pitcock ee1526c903 arch: add x86 port 2018-02-01 01:26:34 +00:00
William Pitcock 54a31e566d test_libucontext: explain the stack poisoning part 2018-01-31 23:23:45 +00:00
William Pitcock 13283f5eba arch: add aarch64 port 2018-01-31 21:23:18 +00:00
William Pitcock 3f63152bbc build: add -Iarch/${ARCH} to CFLAGS 2018-01-31 20:37:00 +00:00
William Pitcock b686d707b2 build: fix arch detection 2018-01-31 05:58:26 +00:00
William Pitcock e43fc2698a README: we support ARM 2018-01-31 04:13:42 +00:00
William Pitcock a6dfb59ef2 build: default ARCH to $(uname -m) 2018-01-31 04:13:32 +00:00