summaryrefslogtreecommitdiff
path: root/ldso/ldso/m68k
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-04-27 17:23:26 +0000
committerEric Andersen <andersen@codepoet.org>2001-04-27 17:23:26 +0000
commit9d5bfe0b9467fc6f54f564648edbc9676106d08d (patch)
tree135e8ecc10701fe8b0fe7f441f0171ac59961ab8 /ldso/ldso/m68k
parent8802da12759ac0cc4fefb09c02522857a3fc961d (diff)
Yet another large update to ld.so. In this iteration I finally got
the C based syscalls working, which greatly simplifies what it takes to get new architectures running. -Erik
Diffstat (limited to 'ldso/ldso/m68k')
-rw-r--r--ldso/ldso/m68k/dl-syscalls.h111
-rw-r--r--ldso/ldso/m68k/ld_syscalls.h111
-rw-r--r--ldso/ldso/m68k/resolve.S20
-rw-r--r--ldso/ldso/m68k/syscalls.h111
4 files changed, 339 insertions, 14 deletions
diff --git a/ldso/ldso/m68k/dl-syscalls.h b/ldso/ldso/m68k/dl-syscalls.h
new file mode 100644
index 000000000..908f5acb3
--- /dev/null
+++ b/ldso/ldso/m68k/dl-syscalls.h
@@ -0,0 +1,111 @@
+#include <linux/types.h>
+#include <asm/unistd.h>
+
+/* Here are the macros which define how this platform makes
+ * system calls. This particular variant does _not_ set
+ * errno (note how it is disabled in __syscall_return) since
+ * these will get called before the errno symbol is dynamicly
+ * linked.
+ by the dynamic linker. The idea is that we want to be able
+ to call these before the errno symbol is dynamicly linked, so
+ we use our own version here. Note that we cannot assume any
+ dynamic linking at all, so we cannot return any error codes.
+ We just punt if there is an error. */
+
+#define __syscall_return(type, res) \
+do { \
+ if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+ /* avoid using res which is declared to be in register d0; \
+ errno might expand to a function call and clobber it. */ \
+ /* int __err = -(res); \
+ errno = __err; */ \
+ res = -1; \
+ } \
+ return (type) (res); \
+} while (0)
+
+#define _syscall0(type,name) \
+type name(void) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+__asm__ __volatile__ ("trap #0" \
+ : "=g" (__res) \
+ : "0" (__res) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall1(type,name,atype,a) \
+type name(atype a) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall2(type,name,atype,a,btype,b) \
+type name(atype a,btype b) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
+type name(atype a,btype b,ctype c) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+register long __c __asm__ ("%d3") = (long)(c); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b), \
+ "d" (__c) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
+type name (atype a, btype b, ctype c, dtype d) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+register long __c __asm__ ("%d3") = (long)(c); \
+register long __d __asm__ ("%d4") = (long)(d); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b), \
+ "d" (__c), "d" (__d) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
+type name (atype a,btype b,ctype c,dtype d,etype e) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+register long __c __asm__ ("%d3") = (long)(c); \
+register long __d __asm__ ("%d4") = (long)(d); \
+register long __e __asm__ ("%d5") = (long)(e); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b), \
+ "d" (__c), "d" (__d), "d" (__e) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+
diff --git a/ldso/ldso/m68k/ld_syscalls.h b/ldso/ldso/m68k/ld_syscalls.h
new file mode 100644
index 000000000..908f5acb3
--- /dev/null
+++ b/ldso/ldso/m68k/ld_syscalls.h
@@ -0,0 +1,111 @@
+#include <linux/types.h>
+#include <asm/unistd.h>
+
+/* Here are the macros which define how this platform makes
+ * system calls. This particular variant does _not_ set
+ * errno (note how it is disabled in __syscall_return) since
+ * these will get called before the errno symbol is dynamicly
+ * linked.
+ by the dynamic linker. The idea is that we want to be able
+ to call these before the errno symbol is dynamicly linked, so
+ we use our own version here. Note that we cannot assume any
+ dynamic linking at all, so we cannot return any error codes.
+ We just punt if there is an error. */
+
+#define __syscall_return(type, res) \
+do { \
+ if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+ /* avoid using res which is declared to be in register d0; \
+ errno might expand to a function call and clobber it. */ \
+ /* int __err = -(res); \
+ errno = __err; */ \
+ res = -1; \
+ } \
+ return (type) (res); \
+} while (0)
+
+#define _syscall0(type,name) \
+type name(void) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+__asm__ __volatile__ ("trap #0" \
+ : "=g" (__res) \
+ : "0" (__res) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall1(type,name,atype,a) \
+type name(atype a) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall2(type,name,atype,a,btype,b) \
+type name(atype a,btype b) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
+type name(atype a,btype b,ctype c) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+register long __c __asm__ ("%d3") = (long)(c); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b), \
+ "d" (__c) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
+type name (atype a, btype b, ctype c, dtype d) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+register long __c __asm__ ("%d3") = (long)(c); \
+register long __d __asm__ ("%d4") = (long)(d); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b), \
+ "d" (__c), "d" (__d) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
+type name (atype a,btype b,ctype c,dtype d,etype e) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+register long __c __asm__ ("%d3") = (long)(c); \
+register long __d __asm__ ("%d4") = (long)(d); \
+register long __e __asm__ ("%d5") = (long)(e); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b), \
+ "d" (__c), "d" (__d), "d" (__e) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+
diff --git a/ldso/ldso/m68k/resolve.S b/ldso/ldso/m68k/resolve.S
index 9b1a24c68..9de314dfb 100644
--- a/ldso/ldso/m68k/resolve.S
+++ b/ldso/ldso/m68k/resolve.S
@@ -1,29 +1,21 @@
-#if 0
-#include <sysdep.h>
-#endif
/*
* These are various helper routines that are needed to run an ELF image.
*/
-#ifdef NO_UNDERSCORE
-#define __dl_linux_resolve _dl_linux_resolve
-#define __dl_linux_resolver _dl_linux_resolver
-#endif
-
.text
.even
-.globl __dl_linux_resolve
- .type __dl_linux_resolve,@function
-__dl_linux_resolve:
+.globl _dl_linux_resolve
+ .type _dl_linux_resolve,@function
+_dl_linux_resolve:
moveml %a0/%a1,%sp@-
#ifdef __PIC__
- bsrl __dl_linux_resolver@PLTPC
+ bsrl _dl_linux_resolver@PLTPC
#else
- jbsr __dl_linux_resolver
+ jbsr _dl_linux_resolver
#endif
moveml %sp@+,%a0/%a1
addql #8,%sp
jmp @(%d0)
.LFE2:
- .size __dl_linux_resolve,.LFE2-__dl_linux_resolve
+ .size _dl_linux_resolve,.LFE2-_dl_linux_resolve
diff --git a/ldso/ldso/m68k/syscalls.h b/ldso/ldso/m68k/syscalls.h
new file mode 100644
index 000000000..908f5acb3
--- /dev/null
+++ b/ldso/ldso/m68k/syscalls.h
@@ -0,0 +1,111 @@
+#include <linux/types.h>
+#include <asm/unistd.h>
+
+/* Here are the macros which define how this platform makes
+ * system calls. This particular variant does _not_ set
+ * errno (note how it is disabled in __syscall_return) since
+ * these will get called before the errno symbol is dynamicly
+ * linked.
+ by the dynamic linker. The idea is that we want to be able
+ to call these before the errno symbol is dynamicly linked, so
+ we use our own version here. Note that we cannot assume any
+ dynamic linking at all, so we cannot return any error codes.
+ We just punt if there is an error. */
+
+#define __syscall_return(type, res) \
+do { \
+ if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+ /* avoid using res which is declared to be in register d0; \
+ errno might expand to a function call and clobber it. */ \
+ /* int __err = -(res); \
+ errno = __err; */ \
+ res = -1; \
+ } \
+ return (type) (res); \
+} while (0)
+
+#define _syscall0(type,name) \
+type name(void) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+__asm__ __volatile__ ("trap #0" \
+ : "=g" (__res) \
+ : "0" (__res) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall1(type,name,atype,a) \
+type name(atype a) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall2(type,name,atype,a,btype,b) \
+type name(atype a,btype b) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
+type name(atype a,btype b,ctype c) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+register long __c __asm__ ("%d3") = (long)(c); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b), \
+ "d" (__c) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
+type name (atype a, btype b, ctype c, dtype d) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+register long __c __asm__ ("%d3") = (long)(c); \
+register long __d __asm__ ("%d4") = (long)(d); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b), \
+ "d" (__c), "d" (__d) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
+type name (atype a,btype b,ctype c,dtype d,etype e) \
+{ \
+register long __res __asm__ ("%d0") = __NR_##name; \
+register long __a __asm__ ("%d1") = (long)(a); \
+register long __b __asm__ ("%d2") = (long)(b); \
+register long __c __asm__ ("%d3") = (long)(c); \
+register long __d __asm__ ("%d4") = (long)(d); \
+register long __e __asm__ ("%d5") = (long)(e); \
+__asm__ __volatile__ ("trap #0" \
+ : "=d" (__res) \
+ : "0" (__res), "d" (__a), "d" (__b), \
+ "d" (__c), "d" (__d), "d" (__e) \
+ : "%d0"); \
+__syscall_return(type,__res); \
+}
+
+