Module Name: src
Committed By: matt
Date: Mon Aug 5 00:57:24 UTC 2013
Modified Files:
src/sys/arch/arm/arm: cpu_exec.c
src/sys/arch/arm/include: elf_machdep.h
Log Message:
Add EF_ARM_BE8
Make sure that running a program, that it right big-endian format for the
processor. (BE8 for armv7, BE32 for all others).
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/arm/cpu_exec.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/include/elf_machdep.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arm/arm/cpu_exec.c
diff -u src/sys/arch/arm/arm/cpu_exec.c:1.3 src/sys/arch/arm/arm/cpu_exec.c:1.4
--- src/sys/arch/arm/arm/cpu_exec.c:1.3 Sat Aug 11 07:18:53 2012
+++ src/sys/arch/arm/arm/cpu_exec.c Mon Aug 5 00:57:24 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_exec.c,v 1.3 2012/08/11 07:18:53 matt Exp $ */
+/* $NetBSD: cpu_exec.c,v 1.4 2013/08/05 00:57:24 matt Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_exec.c,v 1.3 2012/08/11 07:18:53 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_exec.c,v 1.4 2013/08/05 00:57:24 matt Exp $");
#include "opt_compat_netbsd.h"
#include "opt_compat_netbsd32.h"
@@ -68,6 +68,18 @@ arm_netbsd_elf32_probe(struct lwp *l, st
#else
const bool aapcs_p = false;
#endif
+#ifdef __ARMEB__
+ const bool be8_p = (eh->e_flags & EF_ARM_BE8) != 0;
+
+ /*
+ * If the BE-8 model is supported, CPSR[7] will be clear.
+ * If the BE-32 model is supported, CPSR[7] will be set.
+ */
+ register_t cpsr;
+ __asm("mrs\t%0, cpsr" : "=r"(cpsr));
+ if ((cpsr & CPU_CONTROL_BEND_ENABLE) == be8_p)
+ return ENOEXEC;
+#endif /* __ARMEB__ */
/*
* This is subtle. If are netbsd32, then we don't want to match the
Index: src/sys/arch/arm/include/elf_machdep.h
diff -u src/sys/arch/arm/include/elf_machdep.h:1.11 src/sys/arch/arm/include/elf_machdep.h:1.12
--- src/sys/arch/arm/include/elf_machdep.h:1.11 Wed Apr 24 22:35:23 2013
+++ src/sys/arch/arm/include/elf_machdep.h Mon Aug 5 00:57:24 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: elf_machdep.h,v 1.11 2013/04/24 22:35:23 matt Exp $ */
+/* $NetBSD: elf_machdep.h,v 1.12 2013/08/05 00:57:24 matt Exp $ */
#ifndef _ARM_ELF_MACHDEP_H_
#define _ARM_ELF_MACHDEP_H_
@@ -27,6 +27,7 @@
#define EF_ARM_NEW_ABI 0x00000080
#define EF_ARM_OLD_ABI 0x00000100
#define EF_ARM_SOFT_FLOAT 0x00000200
+#define EF_ARM_BE8 0x00800000
#define EF_ARM_EABIMASK 0xff000000
#define EF_ARM_EABI_VER1 0x01000000
#define EF_ARM_EABI_VER2 0x02000000