From d81154a61c869e51bea3c1604c5e2f9edbcc68e4 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sat, 12 Dec 2020 07:07:32 +0000 Subject: [PATCH] riscv64: port to C trampoline --- README.md | 2 +- arch/riscv64/defs.h | 3 +++ arch/riscv64/startcontext.S | 26 -------------------------- arch/riscv64/trampoline.c | 2 ++ 4 files changed, 6 insertions(+), 27 deletions(-) delete mode 100644 arch/riscv64/startcontext.S create mode 100644 arch/riscv64/trampoline.c diff --git a/README.md b/README.md index 94bd2c5..66d9133 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ target to do it. | mips64 | ✓ | | ✓ | | | ppc | ✓ | ✓ | | | | ppc64 | ✓ | ✓ | | | -| riscv64 | ✓ | | ✓ | | +| riscv64 | ✓ | | ✓ | ✓ | | s390x | ✓ | | ✓ | | | sh | ✓ | | ✓ | ✓ | | x86 | ✓ | | ✓ | ✓ | diff --git a/arch/riscv64/defs.h b/arch/riscv64/defs.h index 72ffb47..191e8c2 100644 --- a/arch/riscv64/defs.h +++ b/arch/riscv64/defs.h @@ -47,6 +47,9 @@ #define PC_OFFSET REG_OFFSET(REG_PC) +#define FETCH_LINKPTR(dest) \ + asm("mv %0, s1" : "=rm" ((dest))) + #include "common-defs.h" #endif diff --git a/arch/riscv64/startcontext.S b/arch/riscv64/startcontext.S deleted file mode 100644 index 0ba2d43..0000000 --- a/arch/riscv64/startcontext.S +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2020 Ariadne Conill - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * This software is provided 'as is' and without any warranty, express or - * implied. In no event shall the authors be liable for any damages arising - * from the use of this software. - */ - -#include "defs.h" - -FUNC(libucontext_trampoline) - /* check for linked context */ - beqz s1, no_linked_context - - /* if one is set, invoke it */ - mv a0, s1 - jal libucontext_setcontext - - /* otherwise, exit. */ -no_linked_context: - tail exit@plt -END(libucontext_trampoline) diff --git a/arch/riscv64/trampoline.c b/arch/riscv64/trampoline.c new file mode 100644 index 0000000..83eb453 --- /dev/null +++ b/arch/riscv64/trampoline.c @@ -0,0 +1,2 @@ +#include "defs.h" +#include "common-trampoline.c"