Browse Source

riscv: fix getcallerpc

gcc is just not doing it correctly in the portable version.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 3 years ago
parent
commit
5aa42c1359
2 changed files with 6 additions and 1 deletions
  1. 6 0
      riscv/include/u.h
  2. 0 1
      sys/src/libc/riscv/build.json

+ 6 - 0
riscv/include/u.h

@@ -54,3 +54,9 @@ typedef __builtin_va_list va_list;
 #define va_arg(v,l)	__builtin_va_arg(v,l)
 #define va_copy(v,l)	__builtin_va_copy(v,l)
 
+static inline uintptr_t getcallerpc(void)
+{
+	uintptr_t x = 0;
+	__asm__ __volatile__("sd ra, -24(s0)\n");
+	return x;
+}

+ 0 - 1
sys/src/libc/riscv/build.json

@@ -4,7 +4,6 @@
 	    "$ARCH/notejmp.c",
 	    "$ARCH/argv0.c",
 	    "$ARCH/atomic.S",
-	    "port/getcallerpc.c",
 	    "port/getcallstack.c",
 	    "$ARCH/gettls.S",
 	    "$ARCH/main9.S",