aboutsummaryrefslogtreecommitdiff
path: root/glibc
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2015-01-06 02:27:34 -0800
committerAndrew Waterman <waterman@cs.berkeley.edu>2015-01-06 02:48:49 -0800
commit7eb613824f52d39c0d42a48975ef64e0a1b4d0db (patch)
tree3838b62f4bd7a8b15add25fc261907a338bcb0a6 /glibc
parent87c17aee9406aff62a4cce74e7dd0158bb2b0fed (diff)
downloadriscv-gnu-toolchain-7eb613824f52d39c0d42a48975ef64e0a1b4d0db.zip
riscv-gnu-toolchain-7eb613824f52d39c0d42a48975ef64e0a1b4d0db.tar.gz
riscv-gnu-toolchain-7eb613824f52d39c0d42a48975ef64e0a1b4d0db.tar.bz2
glibc: use cfi directives in setcontext
Diffstat (limited to 'glibc')
-rw-r--r--glibc/sysdeps/riscv/nptl/sysdep-cancel.h4
-rw-r--r--glibc/sysdeps/riscv/sys/asm.h17
-rw-r--r--glibc/sysdeps/unix/riscv/sysdep.h14
-rw-r--r--glibc/sysdeps/unix/sysv/linux/riscv/Makefile1
-rw-r--r--glibc/sysdeps/unix/sysv/linux/riscv/__start_context.S36
-rw-r--r--glibc/sysdeps/unix/sysv/linux/riscv/makecontext.c7
-rw-r--r--glibc/sysdeps/unix/sysv/linux/riscv/setcontext.S90
7 files changed, 73 insertions, 96 deletions
diff --git a/glibc/sysdeps/riscv/nptl/sysdep-cancel.h b/glibc/sysdeps/riscv/nptl/sysdep-cancel.h
index b50a493..9ca31c4 100644
--- a/glibc/sysdeps/riscv/nptl/sysdep-cancel.h
+++ b/glibc/sysdeps/riscv/nptl/sysdep-cancel.h
@@ -34,7 +34,6 @@
# define PSEUDO(name, syscall_name, args) \
.align 2; \
L(pseudo_start): \
- cfi_startproc; \
99: j __syscall_error; \
ENTRY (name) \
SINGLE_THREAD_P(t0); \
@@ -67,9 +66,6 @@
L(pseudo_end):
-# undef PSEUDO_END
-# define PSEUDO_END(sym) cfi_endproc; .size sym,.-sym
-
# define PUSHARGS_0 /* nothing to do */
# define PUSHARGS_1 PUSHARGS_0 REG_S a0, STKOFF_A0(sp); cfi_rel_offset (a0, STKOFF_A0);
# define PUSHARGS_2 PUSHARGS_1 REG_S a1, STKOFF_A1(sp); cfi_rel_offset (a1, STKOFF_A1);
diff --git a/glibc/sysdeps/riscv/sys/asm.h b/glibc/sysdeps/riscv/sys/asm.h
index fc30999..827612d 100644
--- a/glibc/sysdeps/riscv/sys/asm.h
+++ b/glibc/sysdeps/riscv/sys/asm.h
@@ -41,11 +41,12 @@
/*
* LEAF - declare leaf routine
*/
-#define LEAF(symbol) \
- .globl symbol; \
- .align 2; \
- .type symbol,@function; \
-symbol:
+#define LEAF(symbol) \
+ .globl symbol; \
+ .align 2; \
+ .type symbol,@function; \
+symbol: \
+ cfi_startproc;
/*
* NESTED - declare nested routine entry point
@@ -55,15 +56,13 @@ symbol:
/*
* END - mark end of function
*/
-#ifndef END
-# define END(function) \
+#define END(function) \
+ cfi_endproc; \
.size function,.-function
-#endif
/*
* Stack alignment
*/
-#define ALSZ 15
#define ALMASK ~15
#endif /* sys/asm.h */
diff --git a/glibc/sysdeps/unix/riscv/sysdep.h b/glibc/sysdeps/unix/riscv/sysdep.h
index df03609..6e6c20d 100644
--- a/glibc/sysdeps/unix/riscv/sysdep.h
+++ b/glibc/sysdeps/unix/riscv/sysdep.h
@@ -18,22 +18,14 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <sysdeps/unix/sysdep.h>
-
#ifdef __ASSEMBLER__
#include <sys/asm.h>
#define ENTRY(name) LEAF(name)
-#undef END
-#define END(function) \
- .size function,.-function
-
-#define ret ret
-
#undef PSEUDO_END
-#define PSEUDO_END(sym) .size sym,.-sym
+#define PSEUDO_END(sym) END(sym)
#define PSEUDO_NOERRNO(name, syscall_name, args) \
.align 2; \
@@ -42,7 +34,7 @@
scall
#undef PSEUDO_END_NOERRNO
-#define PSEUDO_END_NOERRNO(sym) .size sym,.-sym
+#define PSEUDO_END_NOERRNO(sym) PSEUDO_END(sym)
#define ret_NOERRNO ret
@@ -70,3 +62,5 @@
L(syse1):
#endif
+
+#include <sysdeps/unix/sysdep.h>
diff --git a/glibc/sysdeps/unix/sysv/linux/riscv/Makefile b/glibc/sysdeps/unix/sysv/linux/riscv/Makefile
index 396053f..7bc7a04 100644
--- a/glibc/sysdeps/unix/sysv/linux/riscv/Makefile
+++ b/glibc/sysdeps/unix/sysv/linux/riscv/Makefile
@@ -8,6 +8,5 @@ endif
endif
ifeq ($(subdir),stdlib)
-sysdep_routines += __start_context
gen-as-const-headers += ucontext_i.sym
endif
diff --git a/glibc/sysdeps/unix/sysv/linux/riscv/__start_context.S b/glibc/sysdeps/unix/sysv/linux/riscv/__start_context.S
deleted file mode 100644
index 5f6a734..0000000
--- a/glibc/sysdeps/unix/sysv/linux/riscv/__start_context.S
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Modify saved context.
- Copyright (C) 2009 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Maciej W. Rozycki <macro@codesourcery.com>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
- 02110-1301, USA. */
-
-#include <sysdep.h>
-#include <sys/asm.h>
-
-#include "ucontext_i.h"
-
- .text
-LEAF (__start_context)
- move a0, zero
- beqz s0, 1f
-
- /* setcontext (ucp) */
- move a0, s0
- jal __setcontext
-1: jal HIDDEN_JUMPTARGET (exit)
-
-PSEUDO_END (__start_context)
diff --git a/glibc/sysdeps/unix/sysv/linux/riscv/makecontext.c b/glibc/sysdeps/unix/sysv/linux/riscv/makecontext.c
index a0f0304..bbbdbf3 100644
--- a/glibc/sysdeps/unix/sysv/linux/riscv/makecontext.c
+++ b/glibc/sysdeps/unix/sysv/linux/riscv/makecontext.c
@@ -5,10 +5,9 @@
#include <assert.h>
void __makecontext (ucontext_t *ucp, void (*func) (void), int argc,
- long a0, long a1, long a2, long a3,
- long a4, ...)
+ long a0, long a1, long a2, long a3, long a4, ...)
{
- extern void __start_context(void);
+ extern void __start_context(void) attribute_hidden;
long i, sp;
va_list vl;
@@ -38,6 +37,8 @@ void __makecontext (ucontext_t *ucp, void (*func) (void), int argc,
ucp->uc_mcontext.gregs[REG_SP] = sp;
ucp->uc_mcontext.gregs[REG_PC] = (long)func;
ucp->uc_mcontext.gregs[REG_RA] = (long)&__start_context;
+
+ va_end(vl);
}
weak_alias (__makecontext, makecontext)
diff --git a/glibc/sysdeps/unix/sysv/linux/riscv/setcontext.S b/glibc/sysdeps/unix/sysv/linux/riscv/setcontext.S
index 64752b4..7ad635c 100644
--- a/glibc/sysdeps/unix/sysv/linux/riscv/setcontext.S
+++ b/glibc/sysdeps/unix/sysv/linux/riscv/setcontext.S
@@ -23,6 +23,20 @@
#include "ucontext_i.h"
+#define RESTORE_FP_REG(name, num, base) \
+ fld name, ((num) * 8 + MCONTEXT_FPREGS)(base)
+
+#define RESTORE_FP_REG_CFI(name, num, base) \
+ RESTORE_FP_REG (name, num, base); \
+ cfi_offset (name, (num) * SZREG + MCONTEXT_GREGS)
+
+#define RESTORE_INT_REG(name, num, base) \
+ REG_L name, ((num) * SZREG + MCONTEXT_GREGS)(base)
+
+#define RESTORE_INT_REG_CFI(name, num, base) \
+ RESTORE_INT_REG (name, num, base); \
+ cfi_offset (name, (num) * SZREG + MCONTEXT_GREGS)
+
/* int setcontext (const ucontext_t *ucp) */
.text
@@ -41,21 +55,23 @@ LEAF (__setcontext)
bltz a0, 99f
+ cfi_def_cfa (t0, 0)
+
#ifdef __riscv_hard_float
lw t1, MCONTEXT_FSR(t0)
- fld fs0, ( 8 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs1, ( 9 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs2, (18 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs3, (19 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs4, (20 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs5, (21 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs6, (22 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs7, (23 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs8, (24 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs9, (25 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs10,(26 * 8 + MCONTEXT_FPREGS)(t0)
- fld fs11,(27 * 8 + MCONTEXT_FPREGS)(t0)
+ RESTORE_FP_REG_CFI (fs0, 8, t0)
+ RESTORE_FP_REG_CFI (fs1, 9, t0)
+ RESTORE_FP_REG_CFI (fs2, 18, t0)
+ RESTORE_FP_REG_CFI (fs3, 19, t0)
+ RESTORE_FP_REG_CFI (fs4, 20, t0)
+ RESTORE_FP_REG_CFI (fs5, 21, t0)
+ RESTORE_FP_REG_CFI (fs6, 22, t0)
+ RESTORE_FP_REG_CFI (fs7, 23, t0)
+ RESTORE_FP_REG_CFI (fs8, 24, t0)
+ RESTORE_FP_REG_CFI (fs9, 25, t0)
+ RESTORE_FP_REG_CFI (fs10, 26, t0)
+ RESTORE_FP_REG_CFI (fs11, 27, t0)
fssr t1
#endif /* __riscv_hard_float */
@@ -65,31 +81,39 @@ LEAF (__setcontext)
REG_L t1, MCONTEXT_PC(t0)
REG_L ra, ( 1 * SZREG + MCONTEXT_GREGS)(t0)
REG_L sp, ( 2 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s0, ( 8 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s1, ( 9 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L a0, (10 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L a1, (11 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L a2, (12 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L a3, (13 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L a4, (14 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L a5, (15 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L a6, (16 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L a7, (17 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s2, (18 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s3, (19 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s4, (20 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s5, (21 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s6, (22 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s7, (23 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s8, (24 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s9, (25 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s10,(26 * SZREG + MCONTEXT_GREGS)(t0)
- REG_L s11,(27 * SZREG + MCONTEXT_GREGS)(t0)
+ RESTORE_INT_REG_CFI (s0, 8, t0)
+ RESTORE_INT_REG_CFI (s1, 9, t0)
+ RESTORE_INT_REG (a0, 10, t0)
+ RESTORE_INT_REG (a1, 11, t0)
+ RESTORE_INT_REG (a2, 12, t0)
+ RESTORE_INT_REG (a3, 13, t0)
+ RESTORE_INT_REG (a4, 14, t0)
+ RESTORE_INT_REG (a5, 15, t0)
+ RESTORE_INT_REG (a6, 16, t0)
+ RESTORE_INT_REG (a7, 17, t0)
+ RESTORE_INT_REG_CFI (s2, 18, t0)
+ RESTORE_INT_REG_CFI (s3, 19, t0)
+ RESTORE_INT_REG_CFI (s4, 20, t0)
+ RESTORE_INT_REG_CFI (s5, 21, t0)
+ RESTORE_INT_REG_CFI (s6, 22, t0)
+ RESTORE_INT_REG_CFI (s7, 23, t0)
+ RESTORE_INT_REG_CFI (s8, 24, t0)
+ RESTORE_INT_REG_CFI (s9, 25, t0)
+ RESTORE_INT_REG_CFI (s10, 26, t0)
+ RESTORE_INT_REG_CFI (s11, 27, t0)
jr t1
99: j __syscall_error
PSEUDO_END (__setcontext)
-
weak_alias (__setcontext, setcontext)
+
+LEAF (__start_context)
+
+ /* if (link == 0) exit(0); else __setcontext(link); */
+ move a0, s0
+ bnez s0, __setcontext
+ j exit
+
+PSEUDO_END (__start_context)