summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/cris
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/cris')
-rw-r--r--libc/sysdeps/linux/cris/__init_brk.c6
-rw-r--r--libc/sysdeps/linux/cris/__longjmp.S40
-rw-r--r--libc/sysdeps/linux/cris/bits/byteswap.h74
-rw-r--r--libc/sysdeps/linux/cris/bits/syscalls.h8
-rw-r--r--libc/sysdeps/linux/cris/bits/termios.h215
-rw-r--r--libc/sysdeps/linux/cris/bits/uClibc_arch_features.h45
-rw-r--r--libc/sysdeps/linux/cris/bits/uClibc_page.h6
-rw-r--r--libc/sysdeps/linux/cris/brk.c14
-rw-r--r--libc/sysdeps/linux/cris/clone.S33
-rw-r--r--libc/sysdeps/linux/cris/crt0.c73
-rw-r--r--libc/sysdeps/linux/cris/crt1.S56
-rw-r--r--libc/sysdeps/linux/cris/crti.S57
-rw-r--r--libc/sysdeps/linux/cris/crtn.S42
-rw-r--r--libc/sysdeps/linux/cris/fork.c12
-rw-r--r--libc/sysdeps/linux/cris/sbrk.c15
-rw-r--r--libc/sysdeps/linux/cris/setjmp.S44
-rw-r--r--libc/sysdeps/linux/cris/syscall.S25
-rw-r--r--libc/sysdeps/linux/cris/sysdep.S33
-rw-r--r--libc/sysdeps/linux/cris/sysdep.h79
19 files changed, 632 insertions, 245 deletions
diff --git a/libc/sysdeps/linux/cris/__init_brk.c b/libc/sysdeps/linux/cris/__init_brk.c
index 211ae9136..8e6591a62 100644
--- a/libc/sysdeps/linux/cris/__init_brk.c
+++ b/libc/sysdeps/linux/cris/__init_brk.c
@@ -5,8 +5,13 @@
#include <errno.h>
#include "sysdep.h"
+extern void *__curbrk;
+libc_hidden_proto(__curbrk)
void * __curbrk = 0;
+libc_hidden_data_def(__curbrk)
+extern int __init_brk (void);
+libc_hidden_proto(__init_brk)
int
__init_brk (void)
{
@@ -29,3 +34,4 @@ __init_brk (void)
}
return 0;
}
+libc_hidden_def(__init_brk)
diff --git a/libc/sysdeps/linux/cris/__longjmp.S b/libc/sysdeps/linux/cris/__longjmp.S
index 98472a673..52a986fd9 100644
--- a/libc/sysdeps/linux/cris/__longjmp.S
+++ b/libc/sysdeps/linux/cris/__longjmp.S
@@ -1,5 +1,5 @@
/* longjmp for CRIS.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 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
@@ -17,24 +17,46 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <sysdep.h>
+#include <features.h>
+#include "sysdep.h"
#define _SETJMP_H
#define _ASM
#include <bits/setjmp.h>
+ .syntax no_register_prefix
+
/* Saving and restoring CCR is meaningless, so we don't do it. */
ENTRY (__longjmp)
/* Note that r10 = jmp_buf, r11 = retval. */
- move [$r10+16*4],$srp
- test.d $r11
+#ifdef __arch_v32
+
+ /* We don't restore the call-clobbered registers for v32;
+ their space (corresponding to v10) is now defined as
+ reserved. */
+ movem [r10],r9
+ addq 14*4,r10
+ cmpq 0,r11
+ beq 0f
+ move.d [r10+],sp
+
+ move.d r11,r9
+0:
+ move.d [r10+],acr
+ jump acr
+ move [r10],srp
+
+#else
+
+ move [r10+16*4],srp
+ test.d r11
beq 0f /* Already a 1 in place. */
nop
/* Offset for r9, the return value (see setjmp). */
- move.d $r11,[$r10+6*4]
+ move.d r11,[r10+6*4]
0:
- movem [$r10],$pc
-END (__longjmp)
+ movem [r10],pc
- .weak longjmp
- longjmp = __longjmp
+#endif
+END (__longjmp)
+libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/cris/bits/byteswap.h b/libc/sysdeps/linux/cris/bits/byteswap.h
index e35c4b63f..4027456ac 100644
--- a/libc/sysdeps/linux/cris/bits/byteswap.h
+++ b/libc/sysdeps/linux/cris/bits/byteswap.h
@@ -1,51 +1,56 @@
#ifndef _BITS_BYTESWAP_H
#define _BITS_BYTESWAP_H 1
-#define ___swab16(x) \
+/* CRIS specific byte swap operations: 16, 32 and 64-bit */
+
+/* Swap bytes in 16 bit value. */
+#define __bswap_constant_16(x) \
({ \
unsigned short __x = (x); \
((unsigned short)( \
- (((unsigned short)(__x) & (unsigned short)0x00ffU) << 8) | \
- (((unsigned short)(__x) & (unsigned short)0xff00U) >> 8) )); \
+ (((unsigned short)(__x) & (unsigned short)0x00ffu) << 8) | \
+ (((unsigned short)(__x) & (unsigned short)0xff00u) >> 8) )); \
})
-#define ___swab32(x) \
+#if defined __GNUC__ && __GNUC__ >= 2
+# define __bswap_16(x) \
+ __extension__ \
+ ({ unsigned short __bswap_16_v; \
+ if (__builtin_constant_p (x)) \
+ __bswap_16_v = __bswap_constant_16 (x); \
+ else \
+ __asm__ ("swapb %0" : "=r" (__bswap_16_v) : "0" (x)); \
+ __bswap_16_v; })
+#else
+# define __bswap_16(x) __bswap_constant_16 (x)
+#endif
+
+
+/* Swap bytes in 32 bit value. */
+#define __bswap_constant_32(x) \
({ \
unsigned long __x = (x); \
((unsigned long)( \
- (((unsigned long)(__x) & (unsigned long)0x000000ffUL) << 24) | \
- (((unsigned long)(__x) & (unsigned long)0x0000ff00UL) << 8) | \
- (((unsigned long)(__x) & (unsigned long)0x00ff0000UL) >> 8) | \
- (((unsigned long)(__x) & (unsigned long)0xff000000UL) >> 24) )); \
+ (((unsigned long)(__x) & (unsigned long)0x000000fful) << 24) | \
+ (((unsigned long)(__x) & (unsigned long)0x0000ff00ul) << 8) | \
+ (((unsigned long)(__x) & (unsigned long)0x00ff0000ul) >> 8) | \
+ (((unsigned long)(__x) & (unsigned long)0xff000000ul) >> 24) )); \
})
-/* these are CRIS specific */
-
-static inline unsigned short __fswab16(unsigned short x)
-{
- __asm__ ("swapb %0" : "=r" (x) : "0" (x));
-
- return(x);
-}
-
-static inline unsigned long __fswab32(unsigned long x)
-{
- __asm__ ("swapwb %0" : "=r" (x) : "0" (x));
-
- return(x);
-}
-
-# define __bswap_16(x) \
-(__builtin_constant_p((unsigned short)(x)) ? \
- ___swab16((x)) : \
- __fswab16((x)))
-
+#if defined __GNUC__ && __GNUC__ >= 2
# define __bswap_32(x) \
-(__builtin_constant_p((unsigned long)(x)) ? \
- ___swab32((x)) : \
- __fswab32((x)))
+ __extension__ \
+ ({ unsigned long __bswap_32_v; \
+ if (__builtin_constant_p (x)) \
+ __bswap_32_v = __bswap_constant_32 (x); \
+ else \
+ __asm__ ("swapwb %0" : "=r" (__bswap_32_v) : "0" (x)); \
+ __bswap_32_v; })
+#else
+# define __bswap_32(x) __bswap_constant_32 (x)
+#endif
+
-#if defined __GNUC__ && __GNUC__ >= 2
/* Swap bytes in 64 bit value. */
# define __bswap_constant_64(x) \
((((x) & 0xff00000000000000ull) >> 56) \
@@ -57,6 +62,7 @@ static inline unsigned long __fswab32(unsigned long x)
| (((x) & 0x000000000000ff00ull) << 40) \
| (((x) & 0x00000000000000ffull) << 56))
+#if defined __GNUC__ && __GNUC__ >= 2
# define __bswap_64(x) \
(__extension__ \
({ union { __extension__ unsigned long long int __ll; \
@@ -70,6 +76,8 @@ static inline unsigned long __fswab32(unsigned long x)
__r.__l[1] = __bswap_32 (__w.__l[0]); \
} \
__r.__ll; }))
+#else
+# define __bswap_64(x) __bswap_constant_64 (x)
#endif
#endif /* _BITS_BYTESWAP_H */
diff --git a/libc/sysdeps/linux/cris/bits/syscalls.h b/libc/sysdeps/linux/cris/bits/syscalls.h
index 5f587854f..ce68c04d4 100644
--- a/libc/sysdeps/linux/cris/bits/syscalls.h
+++ b/libc/sysdeps/linux/cris/bits/syscalls.h
@@ -62,6 +62,14 @@ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \
}
+#undef _syscall6
+#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) \
+{ \
+return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
+}
+
#undef INLINE_SYSCALL
#define INLINE_SYSCALL(name, nr, args...) \
({ \
diff --git a/libc/sysdeps/linux/cris/bits/termios.h b/libc/sysdeps/linux/cris/bits/termios.h
new file mode 100644
index 000000000..63ca4ea93
--- /dev/null
+++ b/libc/sysdeps/linux/cris/bits/termios.h
@@ -0,0 +1,215 @@
+/* termios type and macro definitions. Linux version.
+ Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2005
+ 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TERMIOS_H
+# error "Never include <bits/termios.h> directly; use <termios.h> instead."
+#endif
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+#define NCCS 32
+struct termios
+ {
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_line; /* line discipline */
+ cc_t c_cc[NCCS]; /* control characters */
+ speed_t c_ispeed; /* input speed */
+ speed_t c_ospeed; /* output speed */
+#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
+#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
+ };
+
+/* c_cc characters */
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VTIME 5
+#define VMIN 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VEOL 11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOL2 16
+
+/* c_iflag bits */
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IUCLC 0001000
+#define IXON 0002000
+#define IXANY 0004000
+#define IXOFF 0010000
+#define IMAXBEL 0020000
+#define IUTF8 0040000
+
+/* c_oflag bits */
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+#if defined __USE_MISC || defined __USE_XOPEN
+# define NLDLY 0000400
+# define NL0 0000000
+# define NL1 0000400
+# define CRDLY 0003000
+# define CR0 0000000
+# define CR1 0001000
+# define CR2 0002000
+# define CR3 0003000
+# define TABDLY 0014000
+# define TAB0 0000000
+# define TAB1 0004000
+# define TAB2 0010000
+# define TAB3 0014000
+# define BSDLY 0020000
+# define BS0 0000000
+# define BS1 0020000
+# define FFDLY 0100000
+# define FF0 0000000
+# define FF1 0100000
+#endif
+
+#define VTDLY 0040000
+#define VT0 0000000
+#define VT1 0040000
+
+#ifdef __USE_MISC
+# define XTABS 0014000
+#endif
+
+/* c_cflag bit meaning */
+#ifdef __USE_MISC
+# define CBAUD 0010017
+#endif
+#define B0 0000000 /* hang up */
+#define B50 0000001
+#define B75 0000002
+#define B110 0000003
+#define B134 0000004
+#define B150 0000005
+#define B200 0000006
+#define B300 0000007
+#define B600 0000010
+#define B1200 0000011
+#define B1800 0000012
+#define B2400 0000013
+#define B4800 0000014
+#define B9600 0000015
+#define B19200 0000016
+#define B38400 0000017
+#ifdef __USE_MISC
+# define EXTA B19200
+# define EXTB B38400
+#endif
+#define CSIZE 0000060
+#define CS5 0000000
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+#define CSTOPB 0000100
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
+#define CLOCAL 0004000
+#ifdef __USE_MISC
+# define CBAUDEX 0010000
+#endif
+#define B57600 0010001
+#define B115200 0010002
+#define B230400 0010003
+#define B460800 0010004
+#define B921600 0010005
+#define B1843200 0010006
+#define B6250000 0010007
+#ifdef __arch_v32
+#define B12500000 0010010
+#define __MAX_BAUD B12500000
+#else
+#define __MAX_BAUD B6250000
+#endif
+#ifdef __USE_MISC
+# define CIBAUD 002003600000 /* input baud rate (not used) */
+# define CMSPAR 010000000000 /* mark or space (stick) parity */
+# define CRTSCTS 020000000000 /* flow control */
+#endif
+
+/* c_lflag bits */
+#define ISIG 0000001
+#define ICANON 0000002
+#if defined __USE_MISC || defined __USE_XOPEN
+# define XCASE 0000004
+#endif
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0000400
+#ifdef __USE_MISC
+# define ECHOCTL 0001000
+# define ECHOPRT 0002000
+# define ECHOKE 0004000
+# define FLUSHO 0010000
+# define PENDIN 0040000
+#endif
+#define IEXTEN 0100000
+
+/* tcflow() and TCXONC use these */
+#define TCOOFF 0
+#define TCOON 1
+#define TCIOFF 2
+#define TCION 3
+
+/* tcflush() and TCFLSH use these */
+#define TCIFLUSH 0
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+
+/* tcsetattr uses these */
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+
+#define _IOT_termios /* Hurd ioctl type field. */ \
+ _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
diff --git a/libc/sysdeps/linux/cris/bits/uClibc_arch_features.h b/libc/sysdeps/linux/cris/bits/uClibc_arch_features.h
new file mode 100644
index 000000000..b62a51020
--- /dev/null
+++ b/libc/sysdeps/linux/cris/bits/uClibc_arch_features.h
@@ -0,0 +1,45 @@
+/*
+ * Track misc arch-specific features that aren't config options
+ */
+
+#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
+#define _BITS_UCLIBC_ARCH_FEATURES_H
+
+/* instruction used when calling abort() to kill yourself */
+/*#define __UCLIBC_ABORT_INSTRUCTION__ "asm instruction"*/
+#undef __UCLIBC_ABORT_INSTRUCTION__
+
+/* can your target use syscall6() for mmap ? */
+#undef __UCLIBC_MMAP_HAS_6_ARGS__
+
+/* does your target use syscall4() for truncate64 ? (32bit arches only) */
+#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+
+/* does your target have a broken create_module() ? */
+#define __UCLIBC_BROKEN_CREATE_MODULE__
+
+/* does your target prefix all symbols with an _ ? */
+#define __UCLIBC_NO_UNDERSCORES__
+
+/* does your target have an asm .set ? */
+#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
+
+/* define if target doesn't like .global */
+#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
+
+/* define if target supports .weak */
+#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
+
+/* define if target supports .weakext */
+#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
+
+/* needed probably only for ppc64 */
+#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
+
+/* define if target supports IEEE signed zero floats */
+#define __UCLIBC_HAVE_SIGNED_ZERO__
+
+/* lovely */
+#define ASM_LINE_SEP @
+
+#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/cris/bits/uClibc_page.h b/libc/sysdeps/linux/cris/bits/uClibc_page.h
index 8219a19da..adfc3c9af 100644
--- a/libc/sysdeps/linux/cris/bits/uClibc_page.h
+++ b/libc/sysdeps/linux/cris/bits/uClibc_page.h
@@ -25,4 +25,10 @@
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
+/* Some architectures always use 12 as page shift for mmap2() eventhough the
+ * real PAGE_SHIFT != 12. Other architectures use the same value as
+ * PAGE_SHIFT...
+ */
+#define MMAP2_PAGE_SHIFT PAGE_SHIFT
+
#endif /* _UCLIBC_PAGE_H */
diff --git a/libc/sysdeps/linux/cris/brk.c b/libc/sysdeps/linux/cris/brk.c
index 10965d3b9..6c518f5a6 100644
--- a/libc/sysdeps/linux/cris/brk.c
+++ b/libc/sysdeps/linux/cris/brk.c
@@ -1,13 +1,23 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <unistd.h>
#include <sys/syscall.h>
#include <errno.h>
#include "sysdep.h"
+libc_hidden_proto(brk)
+
extern void * __curbrk;
+libc_hidden_proto(__curbrk)
extern int __init_brk (void);
+libc_hidden_proto(__init_brk)
-int attribute_hidden __brk(void * end_data_seg)
+int brk(void * end_data_seg)
{
if (__init_brk () == 0) {
/*
@@ -29,4 +39,4 @@ int attribute_hidden __brk(void * end_data_seg)
return -1;
}
-strong_alias(__brk,brk)
+libc_hidden_def(brk)
diff --git a/libc/sysdeps/linux/cris/clone.S b/libc/sysdeps/linux/cris/clone.S
index 19ba71996..9e284fe0a 100644
--- a/libc/sysdeps/linux/cris/clone.S
+++ b/libc/sysdeps/linux/cris/clone.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 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
@@ -16,24 +16,27 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <asm/errno.h>
+#include <features.h>
#include <sys/syscall.h>
-#include <sysdep.h>
+#include "sysdep.h"
+#define _ERRNO_H 1
+#include <bits/errno.h>
/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
.syntax no_register_prefix
.text
-ENTRY (__clone)
+ENTRY (clone)
/* Sanity check arguments: No NULL function pointers. Allow a NULL
stack pointer though; it makes the kernel allocate stack. */
- test.d r10
+ cmpq 0,r10
beq 1f
nop
/* We need to muck with a few registers. */
- movem r1,[sp=sp-8]
+ subq 8,sp
+ movem r1,[sp]
/* Save the function pointer and argument. We can't save them
onto the new stack since it can be NULL. */
@@ -47,7 +50,7 @@ ENTRY (__clone)
/* Do the system call. */
movu.w SYS_ify (clone),r9
break 13
- test.d r10
+ cmpq 0,r10
beq .Lthread_start
nop
@@ -64,15 +67,22 @@ ENTRY (__clone)
/* Terminate frame pointers here. */
moveq 0,r8
+#ifdef __arch_v32
+ /* Is this the right place for an argument? */
+ jsr r0
+ move.d r1,r10
+#else
/* I've told you once. */
move.d r1,r10
jsr r0
+#endif
SETUP_PIC
- PLTCALL (_exit_internal)
+ PLTCALL (HIDDEN_JUMPTARGET(_exit))
/* Die horribly. */
- test.d [6809]
+ move.d 6809,r13
+ test.d [r13]
/* Stop the unstoppable. */
9:
@@ -83,7 +93,4 @@ ENTRY (__clone)
1:
movs.w -EINVAL,r10
/* Drop through into the ordinary error handler. */
-PSEUDO_END (__clone)
-
-.globl clone
- clone = __clone
+PSEUDO_END (clone)
diff --git a/libc/sysdeps/linux/cris/crt0.c b/libc/sysdeps/linux/cris/crt0.c
deleted file mode 100644
index a676ee908..000000000
--- a/libc/sysdeps/linux/cris/crt0.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Startup code compliant to the ELF CRIS ABI */
-
-/* The first piece of initialized data. */
-int __data_start = 0;
-
-static void start1 (int argc, char **argv) __attribute__ ((used, noreturn));
-
-/*
- * It is important that this be the first function.
- * This file is the first thing in the text section.
- * This is implemented completely in assembler to avoid that the
- * compiler pushes stuff on the stack (e.g. the frame pointer when
- * debuging).
- */
-
-/*
- * On the stack we have argc. We can calculate argv/envp
- * from that and the succeeding stack location, but fix so
- * we get the right calling convention (regs in r10/r11).
- *
- * Please view linux/fs/binfmt_elf.c for a complete
- * understanding of this.
- */
-__asm__ ( \
- ".text\n\t" \
- ".global _start\n\t" \
- "_start:\n\t" \
- "pop $r10\n\t" \
- "move.d $sp, $r11\n\t" \
- "jump start1\n\t");
-
-#include <features.h>
-
-extern void __uClibc_main(int argc, char **argv, char **envp)
- __attribute__ ((__noreturn__));
-extern void __uClibc_start_main(int argc, char **argv, char **envp,
- void (*app_init)(void), void (*app_fini)(void))
- __attribute__ ((__noreturn__));
-extern void weak_function _init(void);
-extern void weak_function _fini(void);
-
-/* Stick in a dummy reference to main(), so that if an application
- * is linking when the main() function is in a static library (.a)
- * we can be sure that main() actually gets linked in */
-extern void main(int argc,void *argv,void *envp);
-void (*__mainp)(int argc,void *argv,void *envp) = main;
-
-static void
-start1 (int argc, char **argv)
-{
- char** environ;
-
- /* The environment starts just after ARGV. */
- environ = &argv[argc + 1];
-
- /*
- * If the first thing after ARGV is the arguments
- * themselves, there is no environment.
- */
- if ((char *) environ == *argv)
- /*
- * The environment is empty. Make environ
- * point at ARGV[ARGC], which is NULL.
- */
- --environ;
-
-#if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__
- /* Leave control to the libc */
- __uClibc_main(argc, argv, environ);
-#else
- __uClibc_start_main(argc, argv, environ, _init, _fini);
-#endif
-}
diff --git a/libc/sysdeps/linux/cris/crt1.S b/libc/sysdeps/linux/cris/crt1.S
new file mode 100644
index 000000000..b07e36b51
--- /dev/null
+++ b/libc/sysdeps/linux/cris/crt1.S
@@ -0,0 +1,56 @@
+/* Startup code compliant to the ELF CRIS ABI */
+
+#include <features.h>
+
+ .syntax no_register_prefix
+
+/* The first piece of initialized data. */
+ .data
+ .global __data_start
+ .align 2
+ .type __data_start, @object
+ .size __data_start, 4
+__data_start:
+ .dword 0
+
+ .text
+ .align 1
+ .global _start
+ .type _start, %function
+#if defined(__UCLIBC_CTOR_DTOR__)
+ .type _init, %function
+ .type _fini, %function
+#else
+ .weak _init
+ .weak _fini
+#endif
+ .type main, %function
+ .type __uClibc_main, %function
+
+/*
+ * On the stack we have argc. We can calculate argv/envp
+ * from that and the succeeding stack location, but fix so
+ * we get the right calling convention (regs in r10/r11).
+ *
+ * Please view linux/fs/binfmt_elf.c for a complete
+ * understanding of this.
+ */
+
+/*
+ * Need to call __uClibc_main(main, argc, argv, _init, _fini)
+ */
+
+_start:
+ move.d main, r10
+ move.d [sp+], r11
+ move.d sp, r12
+ subq 4, sp
+ move srp, [sp]
+ subq 4, sp
+ move.d _fini, r13
+ move.d r13, [sp]
+ move.d _init, r13
+ /* Leave control to the libc */
+ jsr __uClibc_main
+ nop
+ .size _start, .-_start
diff --git a/libc/sysdeps/linux/cris/crti.S b/libc/sysdeps/linux/cris/crti.S
index 78a1862ef..0740c765d 100644
--- a/libc/sysdeps/linux/cris/crti.S
+++ b/libc/sysdeps/linux/cris/crti.S
@@ -1,36 +1,29 @@
-#NO_APP
- .file "initfini.c"
-#APP
-
- .section .init
-#NO_APP
- .align 1
- .global _init
+/* glibc's sysdeps/cris/elf/initfini.c used for reference [PROLOG] */
+
+ .section .init
+ .align 1
+ .global _init
.type _init, @function
_init:
- Push $srp
- subq 4,$sp
- movem $r0,[$sp]
- move.d $pc,$r0
- sub.d .:GOTOFF,$r0
-#APP
-
- .align 1
-
-
- .section .fini
-#NO_APP
- .align 1
- .global _fini
+ subq 4,$sp
+ move.d $r1,[$sp]
+ move $srp,$r1
+ subq 4,$sp
+ move.d $r0,[$sp]
+ move.d $pc,$r0
+ sub.d .:GOTOFF,$r0
+ .align 1
+
+ .section .fini
+ .align 1
+ .global _fini
.type _fini, @function
_fini:
- Push $srp
- subq 4,$sp
- movem $r0,[$sp]
- move.d $pc,$r0
- sub.d .:GOTOFF,$r0
-#APP
- .align 1
-
-
-/*@TRAILER_BEGINS*/
+ subq 4,$sp
+ move.d $r1,[$sp]
+ move $srp,$r1
+ subq 4,$sp
+ move.d $r0,[$sp]
+ move.d $pc,$r0
+ sub.d .:GOTOFF,$r0
+ .align 1
diff --git a/libc/sysdeps/linux/cris/crtn.S b/libc/sysdeps/linux/cris/crtn.S
index e9d8a963f..951ae5449 100644
--- a/libc/sysdeps/linux/cris/crtn.S
+++ b/libc/sysdeps/linux/cris/crtn.S
@@ -1,27 +1,23 @@
-#NO_APP
- .file "initfini.c"
-#APP
-
- .section .init
-#NO_APP
- .align 1
- .global _init
+/* glibc's sysdeps/cris/elf/initfini.c used for reference [EPILOG] */
+
+ .section .init
+ .align 1
+ .global _init
.type _init, @function
-#NO_APP
- movem [$sp+],$r0
- Jump [$sp+]
+ move.d [$sp+],$r0
+ move $r1,$srp
+ move.d [$sp+],$r1
+ Ret
+ nop
.size _init, .-_init
-#APP
-
- .section .fini
-#NO_APP
- .align 1
- .global _fini
+
+ .section .fini
+ .align 1
+ .global _fini
.type _fini, @function
-#NO_APP
- movem [$sp+],$r0
- Jump [$sp+]
+ move.d [$sp+],$r0
+ move $r1,$srp
+ move.d [$sp+],$r1
+ Ret
+ nop
.size _fini, .-_fini
-#APP
-
-/*@TRAILER_BEGINS*/
diff --git a/libc/sysdeps/linux/cris/fork.c b/libc/sysdeps/linux/cris/fork.c
index 4dd8e0269..20b546901 100644
--- a/libc/sysdeps/linux/cris/fork.c
+++ b/libc/sysdeps/linux/cris/fork.c
@@ -1,4 +1,10 @@
-#include <sysdep.h>
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include "sysdep.h"
#define __NR___libc_fork __NR_fork
SYSCALL__ (__libc_fork, 0)
@@ -8,4 +14,6 @@ SYSCALL__ (__libc_fork, 0)
R0&-1==R0, and the child gets R0&0==0. */
/* i dunno what the blurb above is useful for. we just return. */
__asm__("ret\n\tnop");
-weak_alias(__libc_fork, fork)
+libc_hidden_proto(fork)
+weak_alias(__libc_fork,fork)
+libc_hidden_weak(fork)
diff --git a/libc/sysdeps/linux/cris/sbrk.c b/libc/sysdeps/linux/cris/sbrk.c
index 3683435bf..15f506cd7 100644
--- a/libc/sysdeps/linux/cris/sbrk.c
+++ b/libc/sysdeps/linux/cris/sbrk.c
@@ -1,16 +1,25 @@
/* From libc-5.3.12 */
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <unistd.h>
#include <sys/syscall.h>
#include <errno.h>
#include "sysdep.h"
+libc_hidden_proto(sbrk)
+
extern void * __curbrk;
+libc_hidden_proto(__curbrk)
extern int __init_brk (void);
+libc_hidden_proto(__init_brk)
-void attribute_hidden *
-__sbrk(intptr_t increment)
+void *
+sbrk(intptr_t increment)
{
if (__init_brk () == 0) {
void * tmp = __curbrk + increment;
@@ -34,4 +43,4 @@ __sbrk(intptr_t increment)
}
return ((void *) -1);
}
-strong_alias(__sbrk,sbrk)
+libc_hidden_def(sbrk)
diff --git a/libc/sysdeps/linux/cris/setjmp.S b/libc/sysdeps/linux/cris/setjmp.S
index a5ea0e2d8..e7bb6358a 100644
--- a/libc/sysdeps/linux/cris/setjmp.S
+++ b/libc/sysdeps/linux/cris/setjmp.S
@@ -1,5 +1,5 @@
/* setjmp for CRIS.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 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
@@ -17,15 +17,29 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <sysdep.h>
-#define _ASM
+#include "sysdep.h"
#define _SETJMP_H
+#define _ASM
#include <bits/setjmp.h>
.syntax no_register_prefix
ENTRY (__sigsetjmp)
.Local__sigsetjmp:
+
+#ifdef __arch_v32
+
+ moveq 1,r9
+ move.d r10,r12
+ addq 14*4,r12
+ movem r9,[r10]
+ lapc 0f,r13
+ move.d sp,[r12+]
+ move.d r13,[r12+]
+ move srp,[r12+]
+
+#else
+
moveq 1,r9
movem sp,[r10+1*4]
#ifdef __PIC__
@@ -36,6 +50,15 @@ ENTRY (__sigsetjmp)
#endif
move.d r9,[r10]
move srp,[r10+16*4]
+
+#endif
+
+/* Saving and restoring CCR is meaningless, so we don't do it. */
+
+/* Saving registers would complicate the implementation, but we
+ can get away with not setting up R0 here since we know that
+ __sigjmp_save is a local symbol; it doesn't have a PLT (which
+ would have required GOT in R0 at the time of the jump). */
PLTJUMP (__sigjmp_save)
0: /* This is where longjmp returns. (Don't use "ret" - it's a macro. */
Ret
@@ -59,18 +82,3 @@ ENTRY (setjmp)
ba .Local__sigsetjmp
moveq 1,r11
END (setjmp)
-
-/*
-weak_extern (__setjmp)
-weak_extern (_setjmp)
-weak_extern (setjmp)
-*/
-
-
-
-
-
-
-
-
-
diff --git a/libc/sysdeps/linux/cris/syscall.S b/libc/sysdeps/linux/cris/syscall.S
index 011d59920..d4b052e8e 100644
--- a/libc/sysdeps/linux/cris/syscall.S
+++ b/libc/sysdeps/linux/cris/syscall.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2003, 2004 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
@@ -16,13 +16,33 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <sysdep.h>
+#include "sysdep.h"
.syntax no_register_prefix
/* Make syscall (callno, ...) into a system call. */
ENTRY (syscall)
+#ifdef __arch_v32
+ subq 4,sp
+ move.d r10,r9
+ move srp,[sp]
+ addoq 8,sp,acr
+ move.d r11,r10
+ move [acr],mof
+ addoq 12,sp,acr
+ move.d r12,r11
+ move [acr],srp
+ addoq 4,sp,acr
+ move.d r13,r12
+ move.d [acr],r13
+ break 13
+ cmps.w -4096,r10
+ bhs 0f
+ move [sp+],srp
+ Ret
+ nop
+#else
push srp
move.d r10,r9
move.d r11,r10
@@ -37,4 +57,5 @@ ENTRY (syscall)
pop srp
Ret
nop
+#endif
PSEUDO_END (syscall)
diff --git a/libc/sysdeps/linux/cris/sysdep.S b/libc/sysdeps/linux/cris/sysdep.S
index 0c98825cc..4e558153b 100644
--- a/libc/sysdeps/linux/cris/sysdep.S
+++ b/libc/sysdeps/linux/cris/sysdep.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 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
@@ -17,7 +17,7 @@
Boston, MA 02111-1307, USA. */
#include <features.h>
-#include <sysdep.h>
+#include "sysdep.h"
/* Make space for the errno variable. */
@@ -25,11 +25,9 @@
.type C_SYMBOL_NAME(errno),@object
.lcomm C_SYMBOL_NAME(errno),4
+ .weak errno
errno = _errno
- /* weak_alias (errno, _errno) */
-
-
/* The syscall stubs jump here when they detect an error, bot for PIC and
non-PIC. */
@@ -39,25 +37,38 @@ ENTRY (__syscall_error)
neg.d r10,r10
#ifdef __UCLIBC_HAS_THREADS__
- push r10
- push srp
+ subq 4,sp
+ move.d r10,[sp]
+ subq 4,sp
+ move srp,[sp]
/* Note that __syscall_error is only visible within this library,
and no-one passes it on as a pointer, so can assume that R0 (GOT
pointer) is correctly set up. */
- PLTCALL (__errno_location)
+ PLTCALL (HIDDEN_JUMPTARGET(__errno_location))
- pop srp
- pop r11
+ move [sp+],srp
+ move.d [sp+],r11
move.d r11,[r10]
#else /* not __UCLIBC_HAS_THREADS__ */
+#ifdef __arch_v32
+# ifdef __PIC__
+ addo.d C_SYMBOL_NAME(errno:GOT),r0,acr
+ move.d [acr],r9
+ move.d r10,[r9]
+# else /* not __PIC__ */
+ lapc C_SYMBOL_NAME(errno),acr
+ move.d r10,[r9]
+# endif /* not __PIC__ */
+#else /* not __arch_v32 */
# ifdef __PIC__
move.d [r0+C_SYMBOL_NAME(errno:GOT)],r9
move.d r10,[r9]
# else
move.d r10,[C_SYMBOL_NAME(errno)]
# endif
+#endif /* not __arch_v32 */
#endif /* __UCLIBC_HAS_THREADS__ */
#ifdef __PIC__
@@ -69,7 +80,7 @@ ENTRY (__syscall_error)
moveq -1,r10
Ret
- pop r0
+ move.d [sp+],r0
#else
Ret
moveq -1,r10
diff --git a/libc/sysdeps/linux/cris/sysdep.h b/libc/sysdeps/linux/cris/sysdep.h
index b441ff122..593e7772e 100644
--- a/libc/sysdeps/linux/cris/sysdep.h
+++ b/libc/sysdeps/linux/cris/sysdep.h
@@ -40,9 +40,13 @@
#define END(sym)
#endif
-#define C_SYMBOL_NAME(name) name
+#undef SYS_ify
+#define SYS_ify(syscall_name) (__NR_##syscall_name)
-#ifdef __ASSEMBLER__
+#ifdef __ASSEMBLER__
+
+#undef SYS_ify
+#define SYS_ify(syscall_name) __NR_##syscall_name
/* Syntactic details of assembly-code. */
@@ -54,24 +58,54 @@
of relying on hearsay. */
#define ALIGNARG(log2) log2
-#define ASM_GLOBAL_DIRECTIVE .globl
#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
/* The non-PIC jump is preferred, since it does not stall, and does not
invoke generation of a PLT. These macros assume that $r0 is set up as
GOT register. */
+#ifdef __arch_v32
+#ifdef __PIC__
+#define PLTJUMP(_x) \
+ ba C_SYMBOL_NAME (_x):PLT @ \
+ nop
+
+#define PLTCALL(_x) \
+ bsr C_SYMBOL_NAME (_x):PLT @ \
+ nop
+
+#define SETUP_PIC \
+ subq 4,$sp @ \
+ move.d $r0,[$sp] @ \
+ lapc _GLOBAL_OFFSET_TABLE_,$r0
+
+#define TEARDOWN_PIC move.d [$sp+],$r0
+#else
+#define PLTJUMP(_x) \
+ ba C_SYMBOL_NAME (_x) @ \
+ nop
+
+#define PLTCALL(_x) \
+ bsr C_SYMBOL_NAME (_x) @ \
+ nop
+
+#define SETUP_PIC
+#define TEARDOWN_PIC
+#endif
+
+#else
+
#ifdef __PIC__
#define PLTJUMP(_x) \
- add.d C_SYMBOL_NAME (_x):PLT,$pc
+ add.d C_SYMBOL_NAME (_x):PLT,$pc
#define PLTCALL(_x) \
jsr [$r0+C_SYMBOL_NAME (_x):GOTPLT16]
#define SETUP_PIC \
- push $r0 @ \
+ push $r0 @ \
move.d $pc,$r0 @ \
- sub.d .:GOTOFF,$r0
+ sub.d .:GOTOFF,$r0
#define TEARDOWN_PIC pop $r0
#else
@@ -81,38 +115,35 @@
#define TEARDOWN_PIC
#endif
+#endif /* __arch_v32 */
+
/* Define an entry point visible from C. */
-#define ENTRY(name) \
+#define ENTRY(name) \
.text @ \
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name) @ \
ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function) @ \
.align ALIGNARG (2) @ \
- C_LABEL(name) @ \
- CALL_MCOUNT
+ C_LABEL(name)
-#undef END
+#undef END
#define END(name) \
ASM_SIZE_DIRECTIVE (C_SYMBOL_NAME (name))
#define PSEUDO(name, syscall_name, args) \
- ENTRY (name) @ \
- DOARGS_##args @ \
- movu.w SYS_ify (syscall_name),$r9 @ \
- break 13 @ \
- cmps.w -4096,$r10 @ \
- bhs 0f @ \
- nop @ \
+ ENTRY (name) @ \
+ DOARGS_##args @ \
+ movu.w SYS_ify (syscall_name),$r9 @ \
+ break 13 @ \
+ cmps.w -4096,$r10 @ \
+ bhs 0f @ \
+ nop @ \
UNDOARGS_return_##args
#define PSEUDO_END(name) \
-0: @ \
- SETUP_PIC @ \
- PLTJUMP (__syscall_error) @ \
+0: @ \
+ SETUP_PIC @ \
+ PLTJUMP (__syscall_error) @ \
END (name)
-/* If compiled for profiling, do nothing */
-#define CALL_MCOUNT /* Do nothing. */
-
-
#endif /* __ASSEMBLER__ */
#endif /* _SYSDEP_H_ */