2003-02-07  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* elf/tls-macros.h: Add non-PIC TLS macros and fix clobber list
	for SH.
	* sysdeps/unix/sysv/linux/sh/brk.c: Add SYSCALL_INST_PAD
	after the trapa instruction.
	* sysdeps/unix/sysv/linux/sh/clone.S (__clone): Add additional
	parameters.
	* sysdeps/unix/sysv/linux/sh/sh4/sysdep.h: New file.
	(NEED_SYSCALL_INST_PAD): Define.
	* sysdeps/unix/sysv/linux/sh/sys/user.h (start_thread): Undef to
	avoid to use definition for the kernel.
	* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
	Save and restore the frame pointer.
	(SYSCALL_INST_PAD): Define.
	(INLINE_SYSCALL): Make use of INTERNAL_SYSCALL.
	(INTERNAL_SYSCALL): Make use of ERR parameter. Add SYSCALL_INST_PAD
	after trapa instruction.
	(INTERNAL_SYSCALL_DECL, INTERNAL_SYSCALL_ERRNO,
	INTERNAL_SYSCALL_ERROR_P): Adjust accordingly.
This commit is contained in:
Ulrich Drepper 2003-02-08 02:34:27 +00:00
parent d9c734e9cd
commit 2a051a7d1a
6 changed files with 78 additions and 13 deletions

View File

@ -1,3 +1,24 @@
2003-02-07 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* elf/tls-macros.h: Add non-PIC TLS macros and fix clobber list
for SH.
* sysdeps/unix/sysv/linux/sh/brk.c: Add SYSCALL_INST_PAD
after the trapa instruction.
* sysdeps/unix/sysv/linux/sh/clone.S (__clone): Add additional
parameters.
* sysdeps/unix/sysv/linux/sh/sh4/sysdep.h: New file.
(NEED_SYSCALL_INST_PAD): Define.
* sysdeps/unix/sysv/linux/sh/sys/user.h (start_thread): Undef to
avoid to use definition for the kernel.
* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
Save and restore the frame pointer.
(SYSCALL_INST_PAD): Define.
(INLINE_SYSCALL): Make use of INTERNAL_SYSCALL.
(INTERNAL_SYSCALL): Make use of ERR parameter. Add SYSCALL_INST_PAD
after trapa instruction.
(INTERNAL_SYSCALL_DECL, INTERNAL_SYSCALL_ERRNO,
INTERNAL_SYSCALL_ERROR_P): Adjust accordingly.
2003-02-07 Jakub Jelinek <jakub@redhat.com>
* resolv/res_libc.c (_res): Ensure _res is not common symbol,

View File

@ -1,5 +1,5 @@
/* brk system call for Linux/SH.
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -31,7 +31,7 @@ __brk (void *addr)
register long r3 asm ("%r3") = SYS_ify (brk);
register long r4 asm ("%r4") = (long)addr;
asm volatile ("trapa #0x11"
asm volatile ("trapa #0x11\n\t" SYSCALL_INST_PAD
: "=z"(newbrk)
: "r" (r3), "r" (r4));

View File

@ -23,7 +23,8 @@
#define _ERRNO_H 1
#include <bits/errno.h>
/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
pid_t *ptid, void *tls, pid_t *ctid); */
.text
ENTRY(__clone)
@ -43,8 +44,11 @@ ENTRY(__clone)
/* do the system call */
mov r6, r4
mov.l @r15, r6
mov.l @(8,r15), r7
mov.l @(4,r15), r0
mov #+SYS_ify(clone), r3
trapa #0x12
trapa #0x15
mov r0, r1
mov #-12, r2
shad r2, r1

View File

@ -0,0 +1,4 @@
/* 4 instruction cycles not accessing cache and TLB are needed after
trapa instruction to avoid an SH-4 silicon bug. */
#define NEED_SYSCALL_INST_PAD
#include <sysdeps/unix/sysv/linux/sh/sysdep.h>

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
/* Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -23,4 +23,6 @@
#include <asm/user.h>
#undef start_thread
#endif /* sys/user.h */

View File

@ -115,19 +115,23 @@
# else
# define SYSCALL_ERROR_HANDLER \
neg r0,r1; \
mov.l r14,@-r15; \
mov.l r12,@-r15; \
mov.l r1,@-r15; \
mov.l 0f,r12; \
mova 0f,r0; \
add r0,r12; \
sts.l pr,@-r15; \
mov r15,r14; \
mov.l 1f,r1; \
bsrf r1; \
nop; \
2: lds.l @r15+,pr; \
2: mov r14,r15; \
lds.l @r15+,pr; \
mov.l @r15+,r1; \
mov.l r1,@r0; \
mov.l @r15+,r12; \
mov.l @r15+,r14; \
bra .Lpseudo_end; \
mov _IMM1,r0; \
.align 2; \
@ -174,6 +178,13 @@
1: .long SYS_ify (syscall_name); \
2:
# ifdef NEED_SYSCALL_INST_PAD
# define SYSCALL_INST_PAD \
or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0
# else
# define SYSCALL_INST_PAD
# endif
#else /* not __ASSEMBLER__ */
#define SYSCALL_INST_STR0 "trapa #0x10\n\t"
@ -184,6 +195,13 @@
#define SYSCALL_INST_STR5 "trapa #0x15\n\t"
#define SYSCALL_INST_STR6 "trapa #0x16\n\t"
# ifdef NEED_SYSCALL_INST_PAD
# define SYSCALL_INST_PAD "\
or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0"
# else
# define SYSCALL_INST_PAD
# endif
#define ASMFMT_0
#define ASMFMT_1 \
, "r" (r4)
@ -238,24 +256,40 @@
register long r2 asm ("%r2") = (long)(arg7)
#undef INLINE_SYSCALL
#define INLINE_SYSCALL(name, nr, args...) \
#define INLINE_SYSCALL(name, nr, args...) \
({ \
unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
{ \
__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
resultvar = 0xffffffff; \
} \
(int) resultvar; })
#undef INTERNAL_SYSCALL
#define INTERNAL_SYSCALL(name, err, nr, args...) \
({ \
unsigned long resultvar; \
register long r3 asm ("%r3") = SYS_ify (name); \
SUBSTITUTE_ARGS_##nr(args); \
\
asm volatile (SYSCALL_INST_STR##nr \
asm volatile (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \
: "=z" (resultvar) \
: "r" (r3) ASMFMT_##nr \
: "memory"); \
\
if (resultvar >= 0xfffff001) \
{ \
__set_errno (-resultvar); \
resultvar = 0xffffffff; \
} \
(int) resultvar; })
#undef INTERNAL_SYSCALL_DECL
#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
#undef INTERNAL_SYSCALL_ERROR_P
#define INTERNAL_SYSCALL_ERROR_P(val, err) \
((unsigned int) (val) >= 0xfffff001u)
#undef INTERNAL_SYSCALL_ERRNO
#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
#endif /* __ASSEMBLER__ */
#endif /* linux/sh/sysdep.h */