SH: Preserve more registers for frame unwinding purposes, add CFI directives.

This commit is contained in:
Thomas Schwinge 2012-06-23 12:11:13 +02:00
parent 1518f58b61
commit 58f902b8d8
5 changed files with 57 additions and 7 deletions

View File

@ -1,5 +1,12 @@
2012-06-23 Thomas Schwinge <thomas@codesourcery.com>
* sysdeps/sh/____longjmp_chk.S (CALL_FAIL): Preserve r12 and pr
registers for frame unwinding purposes, add CFI directives.
* sysdeps/unix/sysv/linux/sh/____longjmp_chk.S (CALL_FAIL): Likewise.
* sysdeps/unix/sysv/linux/sh/makecontext.S (.Lexitcode): Likewise
* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
Likewise.
* sysdeps/sh/____longjmp_chk.S (CALL_FAIL): Don't plan for the call to
__fortify_fail returning.
* sysdeps/unix/sysv/linux/sh/____longjmp_chk.S (CALL_FAIL): Likewise.

View File

@ -28,9 +28,16 @@ longjmp_msg:
# define CALL_FAIL \
mov.l .Lfail, r1; \
mov.l .Lstr, r4; \
mov.l r12, @-r15; \
cfi_remember_state; \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (r12, 0); \
mova .Lgot, r0; \
mov.l .Lgot, r12; \
add r0, r12; \
sts.l pr, @-r15; \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (pr, 0); \
bsrf r1; \
add r12, r4; \
/* Unreachable. */ \
@ -41,11 +48,16 @@ longjmp_msg:
.Lstr: \
.long longjmp_msg@GOTOFF; \
.Lfail: \
.long __GI___fortify_fail@PLT-(.Lfail0-.);
.long __GI___fortify_fail@PLT-(.Lfail0-.); \
cfi_restore_state;
#else
# define CALL_FAIL \
mov.l .Lfail, r1; \
mov.l .Lstr, r4; \
sts.l pr, @-r15; \
cfi_remember_state; \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (pr, 0); \
jsr @r1; \
nop; \
/* Unreachable. */ \
@ -53,7 +65,8 @@ longjmp_msg:
.Lstr: \
.long longjmp_msg; \
.Lfail: \
.long __fortify_fail;
.long __fortify_fail; \
cfi_restore_state;
#endif
#define CHECK_SP(reg) \

View File

@ -32,9 +32,16 @@ longjmp_msg:
# define CALL_FAIL \
mov.l .Lfail, r1; \
mov.l .Lstr, r4; \
mov.l r12, @-r15; \
cfi_remember_state; \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (r12, 0); \
mova .Lgot, r0; \
mov.l .Lgot, r12; \
add r0, r12; \
sts.l pr, @-r15; \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (pr, 0); \
bsrf r1; \
add r12, r4; \
.Lfail0: \
@ -45,11 +52,16 @@ longjmp_msg:
.Lstr: \
.long longjmp_msg@GOTOFF; \
.Lfail: \
.long __GI___fortify_fail@PLT-(.Lfail0-.);
.long __GI___fortify_fail@PLT-(.Lfail0-.); \
cfi_restore_state;
#else
# define CALL_FAIL \
mov.l .Lfail, r1; \
mov.l .Lstr, r4; \
sts.l pr, @-r15; \
cfi_remember_state; \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (pr, 0); \
jsr @r1; \
nop; \
/* Unreachable. */ \
@ -57,7 +69,8 @@ longjmp_msg:
.Lstr: \
.long longjmp_msg; \
.Lfail: \
.long __fortify_fail;
.long __fortify_fail; \
cfi_restore_state;
#endif
#define CHECK_SP(reg) \

View File

@ -97,8 +97,12 @@ ENTRY(__makecontext)
cfi_endproc
.align 5
cfi_startproc
.Lexitcode:
#ifdef PIC
mov.l r12, @-r15
cfi_adjust_cfa_offset (4)
cfi_rel_offset (r12, 0)
mova .Lgot, r0
mov.l .Lgot, r12
add r0, r12
@ -107,6 +111,9 @@ ENTRY(__makecontext)
bt/s 2f
mov r8, r4 /* r4 <- ucb->uc_link */
mov.l .Lsetcontext, r1
sts.l pr, @-r15
cfi_adjust_cfa_offset (4)
cfi_rel_offset (pr, 0)
#ifdef PIC
bsrf r1
.LPCS0:
@ -115,6 +122,10 @@ ENTRY(__makecontext)
jsr @r1
nop
#endif
/* Restore to keep CFI/CFA balanced. */
lds.l @r15+, pr
cfi_adjust_cfa_offset (-4)
cfi_restore (pr)
/* If this returns (which can happen if the syscall fails) we'll exit
the program with the return error value (-1). */
@ -143,7 +154,6 @@ ENTRY(__makecontext)
.Lexit:
.long HIDDEN_JUMPTARGET(exit)
#endif
cfi_startproc
PSEUDO_END(__makecontext)
weak_alias (__makecontext, makecontext)

View File

@ -1,5 +1,4 @@
/* Copyright (C) 1992,1993,1995-2000,2002-2006,2009,2011
Free Software Foundation, Inc.
/* Copyright (C) 1992-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
Changed by Kaz Kojima, <kkojima@rr.iij4u.or.jp>.
@ -100,11 +99,15 @@
# if RTLD_PRIVATE_ERRNO
# define SYSCALL_ERROR_HANDLER \
neg r0,r1; \
mov r12,r2; \
cfi_register (r12, r2); \
mov.l 0f,r12; \
mova 0f,r0; \
add r0,r12; \
mov.l 1f,r0; \
mov.l r1,@(r0,r12); \
mov r2,r12; \
cfi_restore (r12); \
bra .Lpseudo_end; \
mov _IMM1,r0; \
.align 2; \
@ -121,6 +124,7 @@
# define SYSCALL_ERROR_HANDLER \
neg r0,r1; \
mov r12,r2; \
cfi_register (r12, r2); \
mov.l 0f,r12; \
mova 0f,r0; \
add r0,r12; \
@ -128,6 +132,7 @@
stc gbr, r4; \
mov.l @(r0,r12),r0; \
mov r2,r12; \
cfi_restore (r12); \
add r4,r0; \
mov.l r1,@r0; \
bra .Lpseudo_end; \
@ -140,12 +145,14 @@
# define SYSCALL_ERROR_HANDLER \
neg r0,r1; \
mov r12,r2; \
cfi_register (r12, r2); \
mov.l 0f,r12; \
mova 0f,r0; \
add r0,r12; \
mov.l 1f,r0; \
mov.l @(r0,r12),r0; \
mov r2,r12; \
cfi_restore (r12); \
mov.l r1,@r0; \
bra .Lpseudo_end; \
mov _IMM1,r0; \