SH: ____longjmp_chk for GNU/Linux with sigaltstack support
Thomas Schwinge
thomas@codesourcery.com
Sat Jun 23 10:09:00 GMT 2012
Hi!
On Sat, 23 Jun 2012 11:59:31 +0200, I wrote:
> On Wed, 13 Jun 2012 20:40:48 +0900, Kaz Kojima <kkojima@rr.iij4u.or.jp> wrote:
> > Thomas Schwinge <thomas@codesourcery.com> wrote:
> > > This one is based on Joseph's suggestions as posted in
> > > <http://sourceware.org/ml/libc-ports/2009-08/msg00002.html>; a part of
> > > the following assembler bits are what .,A;gcc -O2 -S.,A+ produced for Joseph's
> > > C code. No regressions and debug/tst-longjmp_chk2 now passes -- Kaz,
> > > would you please review this patch?
> >
> > Looks fine to me.
>
> I pushed the following as commit
> db9b505976a9448911e728c01885e71ad6e9461f:
>
> * sysdeps/unix/sysv/linux/sh/____longjmp_chk.S: New file, based on
> sysdeps/sh/____longjmp_chk.S.
> * sysdeps/unix/sysv/linux/sh/sigaltstack-offsets.sym: New file, based
> on sysdeps/unix/sysv/linux/x86_64/sigaltstack-offsets.sym.
> * sysdeps/unix/sysv/linux/sh/Makefile [subdir=misc]
> (gen-as-const-headers): Append sigaltstack-offsets.sym.
To optimize assembler code in context of calls to __fortify_fail
(__fortify_fail has »__attribute__ ((__noreturn__))«), I pushed the
following as commit 1518f58b6120289e69aeba9426eca9234cd9a200:
* 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.
diff --git a/sysdeps/sh/____longjmp_chk.S b/sysdeps/sh/____longjmp_chk.S
index 5d17f3a..e8d5f68 100644
--- a/sysdeps/sh/____longjmp_chk.S
+++ b/sysdeps/sh/____longjmp_chk.S
@@ -33,31 +33,27 @@ longjmp_msg:
add r0, r12; \
bsrf r1; \
add r12, r4; \
+ /* Unreachable. */ \
.Lfail0: \
- bra 0f; \
- nop; \
.align 2; \
.Lgot: \
.long _GLOBAL_OFFSET_TABLE_; \
.Lstr: \
.long longjmp_msg@GOTOFF; \
.Lfail: \
- .long __GI___fortify_fail@PLT-(.Lfail0-.); \
-0:
+ .long __GI___fortify_fail@PLT-(.Lfail0-.);
#else
# define CALL_FAIL \
mov.l .Lfail, r1; \
mov.l .Lstr, r4; \
jsr @r1; \
nop; \
- bra 0f; \
- nop; \
+ /* Unreachable. */ \
.align 2; \
.Lstr: \
.long longjmp_msg; \
.Lfail: \
- .long __fortify_fail; \
-0:
+ .long __fortify_fail;
#endif
#define CHECK_SP(reg) \
diff --git a/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S b/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S
index d034afc..bcf828b 100644
--- a/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S
+++ b/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S
@@ -38,30 +38,26 @@ longjmp_msg:
bsrf r1; \
add r12, r4; \
.Lfail0: \
- bra 0f; \
- nop; \
+ /* Unreachable. */ \
.align 2; \
.Lgot: \
.long _GLOBAL_OFFSET_TABLE_; \
.Lstr: \
.long longjmp_msg@GOTOFF; \
.Lfail: \
- .long __GI___fortify_fail@PLT-(.Lfail0-.); \
-0:
+ .long __GI___fortify_fail@PLT-(.Lfail0-.);
#else
# define CALL_FAIL \
mov.l .Lfail, r1; \
mov.l .Lstr, r4; \
jsr @r1; \
nop; \
- bra 0f; \
- nop; \
+ /* Unreachable. */ \
.align 2; \
.Lstr: \
.long longjmp_msg; \
.Lfail: \
- .long __fortify_fail; \
-0:
+ .long __fortify_fail;
#endif
#define CHECK_SP(reg) \
Grüße,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120623/1d539df5/attachment.sig>
More information about the Libc-alpha
mailing list