Przeglądaj źródła

Merge SH-2 trapa fixups from Mark.

2006-10-16  Mark Shinwell  <shinwell@codesourcery.com>

	* libc/sysdeps/linux/sh/vfork.S: Use __SH_SYSCALL_TRAP_BASE.
	Also use __CONFIG_SH2__ rather than __sh2__, for consistency.
	* libc/sysdeps/linux/sh/syscall.c: Use __SH_SYSCALL_TRAP_BASE.
	* libc/sysdeps/linux/sh/bits/uClibc_arch_features.h: Use
	__CONFIG_SH2__ rather than __sh2__, for consistency.
	* libc/sysdeps/linux/sh/bits/syscalls.h (__SH_SYSCALL_TRAP_BASE):
	New.
	Use instead of hard-coded trap numbers in the various __NR_<name>
	macros.
	* libc/sysdeps/linux/sh/clone.S: Use __SH_SYSCALL_TRAP_BASE.
	Also use __CONFIG_SH2__ rather than __sh2__, for consistency.
	* libc/sysdeps/linux/sh/crti.S: Disable GOT-related code if
	__HAVE_SHARED__ is not set.
	* libc/sysdeps/linux/sh/pipe.c (pipe): Use __SH_SYSCALL_TRAP_BASE.
Paul Mundt 17 lat temu
rodzic
commit
0b508dd647

+ 29 - 18
libc/sysdeps/linux/sh/bits/syscalls.h

@@ -4,6 +4,13 @@
 # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
 # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
 #endif
 #endif
 
 
+/* The Linux kernel uses different trap numbers on sh-2.  */
+#ifdef __CONFIG_SH2__
+# define __SH_SYSCALL_TRAP_BASE 0x20
+#else
+# define __SH_SYSCALL_TRAP_BASE 0x10
+#endif
+
 /* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
 /* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
  * header files.  It also defines the traditional `SYS_<name>' macros for older
  * header files.  It also defines the traditional `SYS_<name>' macros for older
  * programs.  */
  * programs.  */
@@ -33,9 +40,9 @@ do { \
 type name(void) \
 type name(void) \
 { \
 { \
 register long __sc0 __asm__ ("r3") = __NR_##name; \
 register long __sc0 __asm__ ("r3") = __NR_##name; \
-__asm__ __volatile__ ("trapa	#0x10" \
+__asm__ __volatile__ ("trapa	%1" \
 	: "=z" (__sc0) \
 	: "=z" (__sc0) \
-	: "0" (__sc0) \
+	: "i" (__SH_SYSCALL_TRAP_BASE), "0" (__sc0) \
 	: "memory" ); \
 	: "memory" ); \
 __syscall_return(type,__sc0); \
 __syscall_return(type,__sc0); \
 }
 }
@@ -45,9 +52,9 @@ type name(type1 arg1) \
 { \
 { \
 register long __sc0 __asm__ ("r3") = __NR_##name; \
 register long __sc0 __asm__ ("r3") = __NR_##name; \
 register long __sc4 __asm__ ("r4") = (long) arg1; \
 register long __sc4 __asm__ ("r4") = (long) arg1; \
-__asm__ __volatile__ ("trapa	#0x11" \
+__asm__ __volatile__ ("trapa	%1" \
 	: "=z" (__sc0) \
 	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4) \
+	: "i" (__SH_SYSCALL_TRAP_BASE + 1), "0" (__sc0), "r" (__sc4) \
 	: "memory"); \
 	: "memory"); \
 __syscall_return(type,__sc0); \
 __syscall_return(type,__sc0); \
 }
 }
@@ -58,9 +65,10 @@ type name(type1 arg1,type2 arg2) \
 register long __sc0 __asm__ ("r3") = __NR_##name; \
 register long __sc0 __asm__ ("r3") = __NR_##name; \
 register long __sc4 __asm__ ("r4") = (long) arg1; \
 register long __sc4 __asm__ ("r4") = (long) arg1; \
 register long __sc5 __asm__ ("r5") = (long) arg2; \
 register long __sc5 __asm__ ("r5") = (long) arg2; \
-__asm__ __volatile__ ("trapa	#0x12" \
+__asm__ __volatile__ ("trapa	%1" \
 	: "=z" (__sc0) \
 	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5) \
+	: "i" (__SH_SYSCALL_TRAP_BASE + 2), "0" (__sc0), "r" (__sc4), \
+          "r" (__sc5) \
 	: "memory"); \
 	: "memory"); \
 __syscall_return(type,__sc0); \
 __syscall_return(type,__sc0); \
 }
 }
@@ -72,9 +80,10 @@ register long __sc0 __asm__ ("r3") = __NR_##name; \
 register long __sc4 __asm__ ("r4") = (long) arg1; \
 register long __sc4 __asm__ ("r4") = (long) arg1; \
 register long __sc5 __asm__ ("r5") = (long) arg2; \
 register long __sc5 __asm__ ("r5") = (long) arg2; \
 register long __sc6 __asm__ ("r6") = (long) arg3; \
 register long __sc6 __asm__ ("r6") = (long) arg3; \
-__asm__ __volatile__ ("trapa	#0x13" \
+__asm__ __volatile__ ("trapa	%1" \
 	: "=z" (__sc0) \
 	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \
+	: "i" (__SH_SYSCALL_TRAP_BASE + 3), "0" (__sc0), "r" (__sc4), \
+          "r" (__sc5), "r" (__sc6) \
 	: "memory"); \
 	: "memory"); \
 __syscall_return(type,__sc0); \
 __syscall_return(type,__sc0); \
 }
 }
@@ -87,9 +96,10 @@ register long __sc4 __asm__ ("r4") = (long) arg1; \
 register long __sc5 __asm__ ("r5") = (long) arg2; \
 register long __sc5 __asm__ ("r5") = (long) arg2; \
 register long __sc6 __asm__ ("r6") = (long) arg3; \
 register long __sc6 __asm__ ("r6") = (long) arg3; \
 register long __sc7 __asm__ ("r7") = (long) arg4; \
 register long __sc7 __asm__ ("r7") = (long) arg4; \
-__asm__ __volatile__ ("trapa	#0x14" \
+__asm__ __volatile__ ("trapa	%1" \
 	: "=z" (__sc0) \
 	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6),  \
+	: "i" (__SH_SYSCALL_TRAP_BASE + 4), "0" (__sc0), "r" (__sc4), \
+          "r" (__sc5), "r" (__sc6),  \
 	  "r" (__sc7) \
 	  "r" (__sc7) \
 	: "memory" ); \
 	: "memory" ); \
 __syscall_return(type,__sc0); \
 __syscall_return(type,__sc0); \
@@ -104,18 +114,19 @@ register long __sc5 __asm__ ("r5") = (long) arg2; \
 register long __sc6 __asm__ ("r6") = (long) arg3; \
 register long __sc6 __asm__ ("r6") = (long) arg3; \
 register long __sc7 __asm__ ("r7") = (long) arg4; \
 register long __sc7 __asm__ ("r7") = (long) arg4; \
 register long __sc0 __asm__ ("r0") = (long) arg5; \
 register long __sc0 __asm__ ("r0") = (long) arg5; \
-__asm__ __volatile__ ("trapa	#0x15" \
+__asm__ __volatile__ ("trapa	%1" \
 	: "=z" (__sc0) \
 	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7),  \
-	  "r" (__sc3) \
+	: "i" (__SH_SYSCALL_TRAP_BASE + 5), "0" (__sc0), "r" (__sc4), \
+          "r" (__sc5), "r" (__sc6), "r" (__sc7), "r" (__sc3) \
 	: "memory" ); \
 	: "memory" ); \
 __syscall_return(type,__sc0); \
 __syscall_return(type,__sc0); \
 }
 }
 
 
-/* Add in _syscall6 which is not in the kernel header */
 #ifndef __SH_SYSCALL6_TRAPA
 #ifndef __SH_SYSCALL6_TRAPA
-# define __SH_SYSCALL6_TRAPA "0x16"
+#define __SH_SYSCALL6_TRAPA __SH_SYSCALL_TRAP_BASE + 6
 #endif
 #endif
+
+/* Add in _syscall6 which is not in the kernel header */
 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
 { \
 { \
@@ -126,10 +137,10 @@ register long __sc6 __asm__ ("r6") = (long) arg3; \
 register long __sc7 __asm__ ("r7") = (long) arg4; \
 register long __sc7 __asm__ ("r7") = (long) arg4; \
 register long __sc0 __asm__ ("r0") = (long) arg5; \
 register long __sc0 __asm__ ("r0") = (long) arg5; \
 register long __sc1 __asm__ ("r1") = (long) arg6; \
 register long __sc1 __asm__ ("r1") = (long) arg6; \
-__asm__ __volatile__ ("trapa	#" __SH_SYSCALL6_TRAPA \
+__asm__ __volatile__ ("trapa	%1" \
 	: "=z" (__sc0) \
 	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
-	  "r" (__sc3), "r" (__sc1) \
+	: "i" (__SH_SYSCALL6_TRAPA), "0" (__sc0), "r" (__sc4), \
+          "r" (__sc5), "r" (__sc6), "r" (__sc7), "r" (__sc3), "r" (__sc1) \
 	: "memory" ); \
 	: "memory" ); \
 __syscall_return(type,__sc0); \
 __syscall_return(type,__sc0); \
 }
 }

+ 2 - 2
libc/sysdeps/linux/sh/bits/uClibc_arch_features.h

@@ -6,9 +6,9 @@
 #define _BITS_UCLIBC_ARCH_FEATURES_H
 #define _BITS_UCLIBC_ARCH_FEATURES_H
 
 
 /* instruction used when calling abort() to kill yourself */
 /* instruction used when calling abort() to kill yourself */
-#if defined(__sh2__)
+#if defined(__CONFIG_SH2__)
 # define __UCLIBC_ABORT_INSTRUCTION__ "trapa #32"
 # define __UCLIBC_ABORT_INSTRUCTION__ "trapa #32"
-#else /* defined(__sh__) */
+#else
 # define __UCLIBC_ABORT_INSTRUCTION__ "trapa #0xff"
 # define __UCLIBC_ABORT_INSTRUCTION__ "trapa #0xff"
 #endif
 #endif
 
 

+ 4 - 2
libc/sysdeps/linux/sh/clone.S

@@ -23,6 +23,8 @@
 #include <asm/unistd.h>
 #include <asm/unistd.h>
 #define _ERRNO_H	1
 #define _ERRNO_H	1
 #include <bits/errno.h>
 #include <bits/errno.h>
+#define _SYSCALL_H
+#include <bits/syscalls.h>
 
 
 
 
 #ifdef __HAVE_SHARED__ 
 #ifdef __HAVE_SHARED__ 
@@ -59,9 +61,9 @@ clone:
 	
 	
 	/* do the system call */
 	/* do the system call */
 	mov	r6, r4
 	mov	r6, r4
-	trapa	#0x12
+	trapa	#(__SH_SYSCALL_TRAP_BASE + 2)
 	mov     r0, r1
 	mov     r0, r1
-#ifdef __sh2__
+#ifdef __CONFIG_SH2__
 // 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!	
 // 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!	
 	shar	r1
 	shar	r1
 	shar	r1
 	shar	r1

+ 13 - 9
libc/sysdeps/linux/sh/crti.S

@@ -8,20 +8,21 @@
 	.type	_init, @function
 	.type	_init, @function
 _init:
 _init:
 	mov.l	r12,@-r15
 	mov.l	r12,@-r15
-	mova	.L6,r0
 	mov.l	r14,@-r15
 	mov.l	r14,@-r15
 	sts.l	pr,@-r15
 	sts.l	pr,@-r15
+#ifndef __HAVE_SHARED__
+	mova	.L6,r0
 	mov.l	.L6,r12
 	mov.l	.L6,r12
-	mov	r15,r14
 	add	r0,r12
 	add	r0,r12
-	
-	
-	
+#endif	
+	mov	r15,r14
 	bra	1f
 	bra	1f
 	nop
 	nop
 	.align 2
 	.align 2
+#ifndef __HAVE_SHARED__
 .L6:
 .L6:
 	.long	_GLOBAL_OFFSET_TABLE_
 	.long	_GLOBAL_OFFSET_TABLE_
+#endif
 1:
 1:
 	
 	
 	.section .fini
 	.section .fini
@@ -31,19 +32,22 @@ _init:
 	.type	_fini, @function
 	.type	_fini, @function
 _fini:
 _fini:
 	mov.l	r12,@-r15
 	mov.l	r12,@-r15
-	mova	.L11,r0
 	mov.l	r14,@-r15
 	mov.l	r14,@-r15
 	sts.l	pr,@-r15
 	sts.l	pr,@-r15
-	mov.l	.L11,r12
 	mov	r15,r14
 	mov	r15,r14
+#ifndef __HAVE_SHARED__
+	mov.l	.L11,r12
+	mova	.L11,r0
 	add	r0,r12
 	add	r0,r12
-	
-	
+#endif	
+
 	bra	1f
 	bra	1f
 	nop
 	nop
 	.align 2
 	.align 2
+#ifndef __HAVE_SHARED__
 .L11:
 .L11:
 	.long	_GLOBAL_OFFSET_TABLE_
 	.long	_GLOBAL_OFFSET_TABLE_
+#endif
 1:
 1:
 	
 	
 	.ident	"GCC: (GNU) 3.3.2"
 	.ident	"GCC: (GNU) 3.3.2"

+ 1 - 3
libc/sysdeps/linux/sh/mmap.c

@@ -26,9 +26,7 @@
 libc_hidden_proto(mmap)
 libc_hidden_proto(mmap)
 
 
 #ifdef HIOS
 #ifdef HIOS
-# define __SH_SYSCALL6_TRAPA "0x2E"
-#else
-# define __SH_SYSCALL6_TRAPA "0x15"
+# define __SH_SYSCALL6_TRAPA 0x2E
 #endif
 #endif
 
 
 #include <sys/syscall.h>
 #include <sys/syscall.h>

+ 3 - 2
libc/sysdeps/linux/sh/pipe.c

@@ -20,12 +20,13 @@ int pipe(int *fd)
 	__asm__ __volatile__ (
 	__asm__ __volatile__ (
 	"mov	%2,	r3;"
 	"mov	%2,	r3;"
 	"mov	%3,	r4;"
 	"mov	%3,	r4;"
-	"trapa	#0x13;"
+	"trapa	%4;"
 	"mov    r1, %1;"
 	"mov    r1, %1;"
 	   : "=z" (__res),
 	   : "=z" (__res),
 	     "=r" ((long) __res2)
 	     "=r" ((long) __res2)
 	   : "r" ((long) __NR_pipe),
 	   : "r" ((long) __NR_pipe),
-	     "r" ((long) fd)
+	     "r" ((long) fd),
+		 "i" (__SH_SYSCALL_TRAP_BASE + 3)
 	   : "cc", "memory", "r1", "r3", "r4");
 	   : "cc", "memory", "r1", "r3", "r4");
 	if ((unsigned long)(__res) >= (unsigned long)(-125)) {
 	if ((unsigned long)(__res) >= (unsigned long)(-125)) {
 		int __err = -(__res);
 		int __err = -(__res);

+ 4 - 2
libc/sysdeps/linux/sh/syscall.c

@@ -16,9 +16,11 @@ register long __sc6 __asm__ ("r6") = (long) arg3;
 register long __sc7 __asm__ ("r7") = (long) arg4;
 register long __sc7 __asm__ ("r7") = (long) arg4;
 register long __sc0 __asm__ ("r0") = (long) arg5;
 register long __sc0 __asm__ ("r0") = (long) arg5;
 register long __sc1 __asm__ ("r1") = (long) arg6;
 register long __sc1 __asm__ ("r1") = (long) arg6;
-__asm__ __volatile__ ("trapa	#0x16" \
+__asm__ __volatile__ (
+	"trapa %1"
 	: "=z" (__sc0) \
 	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
+	: "i" (__SH_SYSCALL_TRAP_BASE + 6),
+          "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
 	  "r" (__sc3), "r" (__sc1) \
 	  "r" (__sc3), "r" (__sc1) \
 	: "memory" );
 	: "memory" );
 __syscall_return(long,__sc0);
 __syscall_return(long,__sc0);

+ 5 - 4
libc/sysdeps/linux/sh/vfork.S

@@ -25,6 +25,7 @@
 #include <bits/sysnum.h>
 #include <bits/sysnum.h>
 #define _ERRNO_H	1
 #define _ERRNO_H	1
 #include <bits/errno.h>
 #include <bits/errno.h>
+#include <bits/syscalls.h>
 
 
 /* Clone the calling process, but without copying the whole address space.
 /* Clone the calling process, but without copying the whole address space.
    The calling process is suspended until the new process exits or is
    The calling process is suspended until the new process exits or is
@@ -39,9 +40,9 @@
 
 
 __vfork:
 __vfork:
 	mov.w	.L2, r3
 	mov.w	.L2, r3
-	trapa	#0x10
+	trapa	#__SH_SYSCALL_TRAP_BASE
 	mov     r0, r1
 	mov     r0, r1
-#ifdef __sh2__
+#ifdef __CONFIG_SH2__
 // 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!	
 // 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!	
 	shar	r1
 	shar	r1
 	shar	r1
 	shar	r1
@@ -70,9 +71,9 @@ __vfork:
 
 
 	/* If we don't have vfork, use fork.  */
 	/* If we don't have vfork, use fork.  */
 	mov.w	.L3, r3
 	mov.w	.L3, r3
-	trapa	#0x10
+	trapa	#__SH_SYSCALL_TRAP_BASE
 	mov     r0, r1
 	mov     r0, r1
-#ifdef __sh2__
+#ifdef __CONFIG_SH2__
 // 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!	
 // 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!	
 	shar	r1
 	shar	r1
 	shar	r1
 	shar	r1