Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/csu Add stack alignment checks for alpha, arm, mip...



details:   https://anonhg.NetBSD.org/src/rev/674757b5e244
branches:  trunk
changeset: 325202:674757b5e244
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Dec 11 17:31:55 2013 +0000

description:
Add stack alignment checks for alpha, arm, mips, powerpc, and vax.
Fix makefile to support MACHINE_CPU

diffstat:

 tests/lib/csu/Makefile.check_stack            |   7 ++++++-
 tests/lib/csu/arch/alpha/h_initfini_align.S   |  16 ++++++++++++++++
 tests/lib/csu/arch/arm/h_initfini_align.S     |  20 ++++++++++++++++++++
 tests/lib/csu/arch/mips/h_initfini_align.S    |  19 +++++++++++++++++++
 tests/lib/csu/arch/powerpc/h_initfini_align.S |  17 +++++++++++++++++
 tests/lib/csu/arch/vax/h_initfini_align.S     |  17 +++++++++++++++++
 6 files changed, 95 insertions(+), 1 deletions(-)

diffs (128 lines):

diff -r 1817addbb164 -r 674757b5e244 tests/lib/csu/Makefile.check_stack
--- a/tests/lib/csu/Makefile.check_stack        Wed Dec 11 14:59:47 2013 +0000
+++ b/tests/lib/csu/Makefile.check_stack        Wed Dec 11 17:31:55 2013 +0000
@@ -1,9 +1,14 @@
-# $NetBSD: Makefile.check_stack,v 1.1 2010/11/30 18:38:53 joerg Exp $
+# $NetBSD: Makefile.check_stack,v 1.2 2013/12/11 17:31:55 matt Exp $
 
 .include <bsd.own.mk>
 
+.if exists(${.PARSEDIR}/arch/${MACHINE_ARCH})
 CSU_ARCHDIR=   ${.PARSEDIR}/arch/${MACHINE_ARCH}
 .PATH: ${CSU_ARCHDIR}
+.elif exists(${.PARSEDIR}/arch/${MACHINE_CPU})
+CSU_ARCHDIR=   ${.PARSEDIR}/arch/${MACHINE_CPU}
+.PATH: ${CSU_ARCHDIR}
+.endif
 .if exists(${CSU_ARCHDIR}/h_initfini_align.S)
 SRCS_CHECK_STACK=      h_initfini_align.S
 CPPFLAGS_CHECK_STACK+= -DCHECK_STACK_ALIGNMENT
diff -r 1817addbb164 -r 674757b5e244 tests/lib/csu/arch/alpha/h_initfini_align.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/csu/arch/alpha/h_initfini_align.S       Wed Dec 11 17:31:55 2013 +0000
@@ -0,0 +1,16 @@
+/*     $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:55 matt Exp $        */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:55 matt Exp $")
+
+/*
+ * LINTSTUB: bool check_stack_alignment(void);
+ */
+
+LEAF_NOPROFILE(check_stack_alignment, 0)
+       ldiq    v0, 0
+       and     sp, 7, t0
+       cmoveq  t0, 1, v0
+       ret
+END(check_stack_alignment)
diff -r 1817addbb164 -r 674757b5e244 tests/lib/csu/arch/arm/h_initfini_align.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/csu/arch/arm/h_initfini_align.S Wed Dec 11 17:31:55 2013 +0000
@@ -0,0 +1,20 @@
+/*     $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $        */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $")
+
+/*
+ * LINTSTUB: bool check_stack_alignment(void);
+ */
+
+ARM_ENTRY(check_stack_alignment)
+#ifdef __ARM_EABI__
+       tst     sp, #7
+#else
+       tst     sp, #3
+#endif
+       movne   r0, #0
+       moveq   r0, #1
+       RET
+END(check_stack_alignment)
diff -r 1817addbb164 -r 674757b5e244 tests/lib/csu/arch/mips/h_initfini_align.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/csu/arch/mips/h_initfini_align.S        Wed Dec 11 17:31:55 2013 +0000
@@ -0,0 +1,19 @@
+/*     $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $        */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $")
+
+/*
+ * LINTSTUB: bool check_stack_alignment(void);
+ */
+
+LEAF_NOPROFILE(check_stack_alignment)
+#ifdef __mips_o32
+       andi    v1,sp,3
+#else
+       andi    v1,sp,7
+#endif
+       sltiu   v0,v1,1
+       jr      ra
+END(check_stack_alignment)
diff -r 1817addbb164 -r 674757b5e244 tests/lib/csu/arch/powerpc/h_initfini_align.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/csu/arch/powerpc/h_initfini_align.S     Wed Dec 11 17:31:55 2013 +0000
@@ -0,0 +1,17 @@
+/*     $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $        */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $")
+
+/*
+ * LINTSTUB: bool check_stack_alignment(void);
+ */
+
+_ENTRY(check_stack_alignment)
+       li      %r3,0
+       andis.  %r0,%r1,15
+       bnelr   %cr0
+       li      %r3,1
+       blr
+END(check_stack_alignment)
diff -r 1817addbb164 -r 674757b5e244 tests/lib/csu/arch/vax/h_initfini_align.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/csu/arch/vax/h_initfini_align.S Wed Dec 11 17:31:55 2013 +0000
@@ -0,0 +1,17 @@
+/*     $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $        */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $")
+
+/*
+ * LINTSTUB: bool check_stack_alignment(void);
+ */
+
+_ENTRY(check_stack_alignment, 0)
+       clrl    %r0
+       bitl    $3,%sp
+       bneq    1f
+       incl    %r0
+1:     ret
+END(check_stack_alignment)



Home | Main Index | Thread Index | Old Index