summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/xtensa/makecontext.c
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2024-06-01 03:39:03 -0700
committerWaldemar Brodkorb <wbx@openadk.org>2024-06-04 16:40:42 +0200
commit138274e92a01be8a98392489b1a2f497ab11c201 (patch)
treef0be841a1e915e86d4215326a13654f8034632a4 /libc/sysdeps/linux/xtensa/makecontext.c
parent8bb33a2e1f2baec2078581d77e181f1ead5f51aa (diff)
xtensa: add FDPIC support
This change implements Xtensa FDPIC ABI as specified in the first version of the following document: https://github.com/jcmvbkbc/xtensa-abi/blob/master/fdpic-xtensa.txt Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/xtensa/makecontext.c')
-rw-r--r--libc/sysdeps/linux/xtensa/makecontext.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/xtensa/makecontext.c b/libc/sysdeps/linux/xtensa/makecontext.c
index da26a0130..0a8f7116f 100644
--- a/libc/sysdeps/linux/xtensa/makecontext.c
+++ b/libc/sysdeps/linux/xtensa/makecontext.c
@@ -73,7 +73,12 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
sp -= 4 * (argc + 2);
sp &= -16;
+#ifdef __FDPIC__
+ ucp->uc_mcontext.sc_pc = ((unsigned long *) __start_context)[0];
+ ucp->uc_mcontext.sc_a[15] = ((unsigned long *) __start_context)[1];
+#else
ucp->uc_mcontext.sc_pc = (unsigned long) __start_context;
+#endif
ucp->uc_mcontext.sc_a[1] = sp;
ucp->uc_mcontext.sc_a[12] = (unsigned long) func;
ucp->uc_mcontext.sc_a[13] = (unsigned long) ucp->uc_link;