OSDN Git Service

Yet another large update to ld.so. In this iteration I finally got
authorEric Andersen <andersen@codepoet.org>
Fri, 27 Apr 2001 17:23:26 +0000 (17:23 -0000)
committerEric Andersen <andersen@codepoet.org>
Fri, 27 Apr 2001 17:23:26 +0000 (17:23 -0000)
the C based syscalls working, which greatly simplifies what it takes
to get new architectures running.
 -Erik

18 files changed:
ldso/ldso/Makefile
ldso/ldso/i386/dl-syscalls.h [new file with mode: 0644]
ldso/ldso/i386/dl-sysdep.h
ldso/ldso/i386/ld_syscalls.h [new file with mode: 0644]
ldso/ldso/i386/ld_sysdep.h
ldso/ldso/i386/resolve.S
ldso/ldso/i386/syscalls.h [new file with mode: 0644]
ldso/ldso/i386/sysdep.h
ldso/ldso/ld_syscall.h [new file with mode: 0644]
ldso/ldso/m68k/dl-syscalls.h [new file with mode: 0644]
ldso/ldso/m68k/ld_syscalls.h [new file with mode: 0644]
ldso/ldso/m68k/resolve.S
ldso/ldso/m68k/syscalls.h [new file with mode: 0644]
ldso/ldso/sparc/dl-syscalls.h [new file with mode: 0644]
ldso/ldso/sparc/ld_syscalls.h [new file with mode: 0644]
ldso/ldso/sparc/syscalls.h [new file with mode: 0644]
ldso/ldso/syscall.h [new file with mode: 0644]
ldso/libdl/Makefile

index 5048bd7..6d4e395 100644 (file)
@@ -1,23 +1,21 @@
 TOPDIR=../../
 include $(TOPDIR)/ld.so-1/Rules.mak
 
-CFLAGS += -DNO_UNDERSCORE -DVERBOSE_DLINKER
 CFLAGS += -DUSE_CACHE -fPIC -D__PIC__ #-funroll-loops
 
-CSRC= boot1.c hash.c readelflib1.c vsprintf.c
+CSRC= boot1.c hash.c readelflib1.c vsprintf.c $(TARGET_ARCH)/elfinterp.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
-OBJS=$(COBJS)
+ASRC=$(shell ls $(TARGET_ARCH)/*.S)
+AOBJS=$(patsubst %.S,%.o, $(ASRC))
+OBJS=$(AOBJS) $(COBJS)
 
 ELF_LDFLAGS=--shared # using GNU ld
 
-all: sysdeps lib
+all: lib
 
-sysdeps:
-       make -C $(TARGET_ARCH)
-
-lib:: $(OBJS)
+lib:: $(OBJS) $(DLINK_OBJS)
        $(LD) -e _dl_boot $(ELF_LDFLAGS) -o $(DLINKER).$(LDSO_VMAJOR) \
-         -soname $(DLINKER).$(LDSO_VMAJOR) *.o
+         -soname $(DLINKER).$(LDSO_VMAJOR) $(OBJS)
 
 $(COBJS): %.o : %.c
        $(CC) -I. -I./$(TARGET_ARCH) -I../libdl $(CFLAGS) -c $< -o $@
@@ -27,6 +25,5 @@ realclean::
        $(RM) -f .depend $(DLINKER) core *.o *.a *.s *.i tmp_make foo *~
 
 clean::
-       $(RM) -f $(DLINKER)* core *.o *.a *.s *.i tmp_make foo *~
+       $(RM) -f $(DLINKER)* $(OBJS) core *.o *.a *.s *.i tmp_make foo *~
 
-.PHONY: sysdeps
diff --git a/ldso/ldso/i386/dl-syscalls.h b/ldso/ldso/i386/dl-syscalls.h
new file mode 100644 (file)
index 0000000..263dc5a
--- /dev/null
@@ -0,0 +1,94 @@
+#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. */
+
+
+#undef __syscall_return
+#define __syscall_return(type, res) \
+do { \
+       if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+               /*errno = -(res); */ \
+               res = -1; \
+       } \
+       return (type) (res); \
+} while (0)
+
+
+#if defined(__PIC__)
+
+/*
+ * PIC uses %ebx, so we need to save it during system calls
+ */
+
+#undef _syscall1
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall2
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1,type2 arg2) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall3
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name(type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
+               "d" ((long)(arg3))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall4
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
+         "d" ((long)(arg3)),"S" ((long)(arg4))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall5
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+          type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
+         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
+__syscall_return(type,__res); \
+}
+
+#endif /* __PIC__ */
+
+
index 9bbeef1..bf3d43b 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Various assmbly language/system dependent  hacks that are required
  * so that we can minimize the amount of platform specific code.
@@ -73,9 +72,9 @@
 /* Here we define the magic numbers that this dynamic loader should accept */
 
 #define MAGIC1 EM_386
-#define MAGIC2 EM_486
+#undef  MAGIC2
 /* Used for error messages */
-#define ELF_TARGET "386/486"
+#define ELF_TARGET "386"
 
 extern unsigned int _dl_linux_resolver(int dummy, int i);
 
diff --git a/ldso/ldso/i386/ld_syscalls.h b/ldso/ldso/i386/ld_syscalls.h
new file mode 100644 (file)
index 0000000..263dc5a
--- /dev/null
@@ -0,0 +1,94 @@
+#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. */
+
+
+#undef __syscall_return
+#define __syscall_return(type, res) \
+do { \
+       if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+               /*errno = -(res); */ \
+               res = -1; \
+       } \
+       return (type) (res); \
+} while (0)
+
+
+#if defined(__PIC__)
+
+/*
+ * PIC uses %ebx, so we need to save it during system calls
+ */
+
+#undef _syscall1
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall2
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1,type2 arg2) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall3
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name(type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
+               "d" ((long)(arg3))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall4
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
+         "d" ((long)(arg3)),"S" ((long)(arg4))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall5
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+          type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
+         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
+__syscall_return(type,__res); \
+}
+
+#endif /* __PIC__ */
+
+
index 9bbeef1..bf3d43b 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Various assmbly language/system dependent  hacks that are required
  * so that we can minimize the amount of platform specific code.
@@ -73,9 +72,9 @@
 /* Here we define the magic numbers that this dynamic loader should accept */
 
 #define MAGIC1 EM_386
-#define MAGIC2 EM_486
+#undef  MAGIC2
 /* Used for error messages */
-#define ELF_TARGET "386/486"
+#define ELF_TARGET "386"
 
 extern unsigned int _dl_linux_resolver(int dummy, int i);
 
index db22e7b..8ae2efa 100644 (file)
@@ -1,34 +1,14 @@
-#if 0
-#include <sysdep.h>
-#endif
 /*
  * These are various helper routines that are needed to run an ELF image.
  */
-#ifndef ALIGN
-#define ALIGN 4
-#endif
-
-#ifndef NO_UNDERSCORE
-#define RUN _linux_run
-#define RESOLVE __dl_linux_resolve
-#define EXIT __interpreter_exit
-#define RESOLVER __dl_linux_resolver
-#define INIT ___loader_bootstrap
-#else
-#define RUN linux_run
-#define RESOLVE _dl_linux_resolve
-#define RESOLVER _dl_linux_resolver
-#define EXIT _interpreter_exit
-#define INIT __loader_bootstrap
-#endif
 
 .text
-.align ALIGN
-       .align 16
+.align 4
+
+.globl _dl_linux_resolve
+.type  _dl_linux_resolve,@function
 
-.globl RESOLVE
-       .type   RESOLVE,@function
-RESOLVE:
+_dl_linux_resolve:
        pusha                           /* preserve all regs */
        lea     0x20(%esp),%eax         /* eax = tpnt and reloc_entry params */
        pushl   4(%eax)                 /* push copy of reloc_entry param */
@@ -40,10 +20,10 @@ RESOLVE:
 .L24:
        popl    %ebx
        addl    $_GLOBAL_OFFSET_TABLE_+[.-.L24],%ebx
-       movl RESOLVER@GOT(%ebx),%ebx    /* eax = resolved func */
+       movl _dl_linux_resolver@GOT(%ebx),%ebx  /* eax = resolved func */
        call *%ebx
 #else
-       call RESOLVER
+       call _dl_linux_resolver
 #endif
        movl    %eax,0x2C(%esp)         /* store func addr over original
                                         * tpnt param */
@@ -52,4 +32,4 @@ RESOLVE:
        ret     $4                      /* jump to func removing original
                                         * reloc_entry param from stack */
 .LFE2:
-       .size RESOLVE,.LFE2-RESOLVE
+       .size _dl_linux_resolve,.LFE2-_dl_linux_resolve
diff --git a/ldso/ldso/i386/syscalls.h b/ldso/ldso/i386/syscalls.h
new file mode 100644 (file)
index 0000000..263dc5a
--- /dev/null
@@ -0,0 +1,94 @@
+#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. */
+
+
+#undef __syscall_return
+#define __syscall_return(type, res) \
+do { \
+       if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+               /*errno = -(res); */ \
+               res = -1; \
+       } \
+       return (type) (res); \
+} while (0)
+
+
+#if defined(__PIC__)
+
+/*
+ * PIC uses %ebx, so we need to save it during system calls
+ */
+
+#undef _syscall1
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall2
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1,type2 arg2) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall3
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name(type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
+               "d" ((long)(arg3))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall4
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
+         "d" ((long)(arg3)),"S" ((long)(arg4))); \
+__syscall_return(type,__res); \
+}
+
+#undef _syscall5
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+          type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
+       : "=a" (__res) \
+       : "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
+         "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
+__syscall_return(type,__res); \
+}
+
+#endif /* __PIC__ */
+
+
index 9bbeef1..bf3d43b 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Various assmbly language/system dependent  hacks that are required
  * so that we can minimize the amount of platform specific code.
@@ -73,9 +72,9 @@
 /* Here we define the magic numbers that this dynamic loader should accept */
 
 #define MAGIC1 EM_386
-#define MAGIC2 EM_486
+#undef  MAGIC2
 /* Used for error messages */
-#define ELF_TARGET "386/486"
+#define ELF_TARGET "386"
 
 extern unsigned int _dl_linux_resolver(int dummy, int i);
 
diff --git a/ldso/ldso/ld_syscall.h b/ldso/ldso/ld_syscall.h
new file mode 100644 (file)
index 0000000..4e4d4c1
--- /dev/null
@@ -0,0 +1,105 @@
+#include "syscalls.h"
+
+/* Here are the definitions for some syscalls that are used
+   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 __NR__dl_exit __NR_exit
+static inline _syscall1(void, _dl_exit, int, status);
+
+
+#define __NR__dl_close __NR_close
+static inline _syscall1(int, _dl_close, int, fd);
+
+
+#define __NR__dl_mmap_real __NR_mmap
+static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
+
+static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
+               int flags, int fd, unsigned long offset)
+{
+       unsigned long buffer[6];
+
+       buffer[0] = (unsigned long) addr;
+       buffer[1] = (unsigned long) size;
+       buffer[2] = (unsigned long) prot;
+       buffer[3] = (unsigned long) flags;
+       buffer[4] = (unsigned long) fd;
+       buffer[5] = (unsigned long) offset;
+       return (void *) _dl_mmap_real(buffer);
+}
+#ifndef _dl_MAX_ERRNO
+#define _dl_MAX_ERRNO 4096
+#endif
+#define _dl_mmap_check_error(__res)    \
+       (((int)__res) < 0 && ((int)__res) >= -_dl_MAX_ERRNO)
+
+
+
+#define __NR__dl_open __NR_open
+static inline _syscall2(int, _dl_open, const char *, fn, int, flags);
+
+#define __NR__dl_write __NR_write
+static inline _syscall3(unsigned long, _dl_write, int, fd, 
+           const void *, buf, unsigned long, count);
+
+
+#define __NR__dl_read __NR_read
+static inline _syscall3(unsigned long, _dl_read, int, fd, 
+           const void *, buf, unsigned long, count);
+
+#define __NR__dl_mprotect __NR_mprotect
+static inline _syscall3(int, _dl_mprotect, const void *, addr, unsigned long, len, int, prot);
+
+
+
+/* Pull in whatever this particular arch's kernel thinks the kernel version of
+ * struct stat should look like.  It turns out that each arch has a different
+ * opinion on the subject, and different kernel revs use different names... */
+#define __NR__dl_stat  __NR_stat
+#define stat kernel_stat
+#define new_stat kernel_stat
+#include <asm/stat.h> 
+#undef new_stat
+#undef stat
+static inline _syscall2(int, _dl_stat, const char *, file_name, struct kernel_stat *, buf);
+
+
+#define __NR__dl_munmap __NR_munmap
+static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
+
+#define __NR__dl_getuid __NR_getuid
+static inline _syscall0(gid_t, _dl_getuid);
+
+#define __NR__dl_geteuid __NR_geteuid
+static inline _syscall0(uid_t, _dl_geteuid);
+
+#define __NR__dl_getgid __NR_getgid
+static inline _syscall0(gid_t, _dl_getgid);
+
+#define __NR__dl_getegid __NR_getegid
+static inline _syscall0(gid_t, _dl_getegid);
+
+/*
+ * Not an actual syscall, but we need something in assembly to say whether
+ * this is OK or not.
+ */
+extern inline int _dl_suid_ok(void)
+{
+    uid_t uid, euid, gid, egid;
+
+    uid = _dl_getuid();
+    euid = _dl_geteuid();
+    gid = _dl_getgid();
+    egid = _dl_getegid();
+
+    if(uid == euid && gid == egid)
+       return 1;
+    else
+       return 0;
+}
+
diff --git a/ldso/ldso/m68k/dl-syscalls.h b/ldso/ldso/m68k/dl-syscalls.h
new file mode 100644 (file)
index 0000000..908f5ac
--- /dev/null
@@ -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 (file)
index 0000000..908f5ac
--- /dev/null
@@ -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); \
+}
+
+
index 9b1a24c..9de314d 100644 (file)
@@ -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 (file)
index 0000000..908f5ac
--- /dev/null
@@ -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/sparc/dl-syscalls.h b/ldso/ldso/sparc/dl-syscalls.h
new file mode 100644 (file)
index 0000000..c2b7e55
--- /dev/null
@@ -0,0 +1,144 @@
+#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 _syscall0(type,name) \
+type name(void) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res)\
+                     : "r" (__g1) \
+                     : "o0", "cc"); \
+if (__res < -255 || __res >= 0) \
+    return (type) __res; \
+/*errno = -__res; */\
+return -1; \
+}
+
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res >= 0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1,type2 arg2) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res >= 0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name(type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+register long __o2 __asm__ ("o2") = (long)(arg3); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res>=0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+register long __o2 __asm__ ("o2") = (long)(arg3); \
+register long __o3 __asm__ ("o3") = (long)(arg4); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res>=0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+} 
+
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+         type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+register long __o2 __asm__ ("o2") = (long)(arg3); \
+register long __o3 __asm__ ("o3") = (long)(arg4); \
+register long __o4 __asm__ ("o4") = (long)(arg5); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res>=0) \
+       return (type) __res; \
+/*errno = -__res; */\
+return -1; \
+}
diff --git a/ldso/ldso/sparc/ld_syscalls.h b/ldso/ldso/sparc/ld_syscalls.h
new file mode 100644 (file)
index 0000000..c2b7e55
--- /dev/null
@@ -0,0 +1,144 @@
+#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 _syscall0(type,name) \
+type name(void) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res)\
+                     : "r" (__g1) \
+                     : "o0", "cc"); \
+if (__res < -255 || __res >= 0) \
+    return (type) __res; \
+/*errno = -__res; */\
+return -1; \
+}
+
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res >= 0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1,type2 arg2) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res >= 0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name(type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+register long __o2 __asm__ ("o2") = (long)(arg3); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res>=0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+register long __o2 __asm__ ("o2") = (long)(arg3); \
+register long __o3 __asm__ ("o3") = (long)(arg4); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res>=0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+} 
+
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+         type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+register long __o2 __asm__ ("o2") = (long)(arg3); \
+register long __o3 __asm__ ("o3") = (long)(arg4); \
+register long __o4 __asm__ ("o4") = (long)(arg5); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res>=0) \
+       return (type) __res; \
+/*errno = -__res; */\
+return -1; \
+}
diff --git a/ldso/ldso/sparc/syscalls.h b/ldso/ldso/sparc/syscalls.h
new file mode 100644 (file)
index 0000000..c2b7e55
--- /dev/null
@@ -0,0 +1,144 @@
+#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 _syscall0(type,name) \
+type name(void) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res)\
+                     : "r" (__g1) \
+                     : "o0", "cc"); \
+if (__res < -255 || __res >= 0) \
+    return (type) __res; \
+/*errno = -__res; */\
+return -1; \
+}
+
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res >= 0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1,type2 arg2) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res >= 0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name(type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+register long __o2 __asm__ ("o2") = (long)(arg3); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res>=0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+register long __o2 __asm__ ("o2") = (long)(arg3); \
+register long __o3 __asm__ ("o3") = (long)(arg4); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res>=0) \
+       return (type) __res; \
+/*errno = -__res;*/ \
+return -1; \
+} 
+
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+         type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+register long __g1 __asm__ ("g1") = __NR_##name; \
+register long __o0 __asm__ ("o0") = (long)(arg1); \
+register long __o1 __asm__ ("o1") = (long)(arg2); \
+register long __o2 __asm__ ("o2") = (long)(arg3); \
+register long __o3 __asm__ ("o3") = (long)(arg4); \
+register long __o4 __asm__ ("o4") = (long)(arg5); \
+__asm__ __volatile__ ("t 0x10\n\t" \
+                     "bcc 1f\n\t" \
+                     "mov %%o0, %0\n\t" \
+                     "sub %%g0, %%o0, %0\n\t" \
+                     "1:\n\t" \
+                     : "=r" (__res), "=&r" (__o0) \
+                     : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
+                     : "cc"); \
+if (__res < -255 || __res>=0) \
+       return (type) __res; \
+/*errno = -__res; */\
+return -1; \
+}
diff --git a/ldso/ldso/syscall.h b/ldso/ldso/syscall.h
new file mode 100644 (file)
index 0000000..4e4d4c1
--- /dev/null
@@ -0,0 +1,105 @@
+#include "syscalls.h"
+
+/* Here are the definitions for some syscalls that are used
+   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 __NR__dl_exit __NR_exit
+static inline _syscall1(void, _dl_exit, int, status);
+
+
+#define __NR__dl_close __NR_close
+static inline _syscall1(int, _dl_close, int, fd);
+
+
+#define __NR__dl_mmap_real __NR_mmap
+static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
+
+static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
+               int flags, int fd, unsigned long offset)
+{
+       unsigned long buffer[6];
+
+       buffer[0] = (unsigned long) addr;
+       buffer[1] = (unsigned long) size;
+       buffer[2] = (unsigned long) prot;
+       buffer[3] = (unsigned long) flags;
+       buffer[4] = (unsigned long) fd;
+       buffer[5] = (unsigned long) offset;
+       return (void *) _dl_mmap_real(buffer);
+}
+#ifndef _dl_MAX_ERRNO
+#define _dl_MAX_ERRNO 4096
+#endif
+#define _dl_mmap_check_error(__res)    \
+       (((int)__res) < 0 && ((int)__res) >= -_dl_MAX_ERRNO)
+
+
+
+#define __NR__dl_open __NR_open
+static inline _syscall2(int, _dl_open, const char *, fn, int, flags);
+
+#define __NR__dl_write __NR_write
+static inline _syscall3(unsigned long, _dl_write, int, fd, 
+           const void *, buf, unsigned long, count);
+
+
+#define __NR__dl_read __NR_read
+static inline _syscall3(unsigned long, _dl_read, int, fd, 
+           const void *, buf, unsigned long, count);
+
+#define __NR__dl_mprotect __NR_mprotect
+static inline _syscall3(int, _dl_mprotect, const void *, addr, unsigned long, len, int, prot);
+
+
+
+/* Pull in whatever this particular arch's kernel thinks the kernel version of
+ * struct stat should look like.  It turns out that each arch has a different
+ * opinion on the subject, and different kernel revs use different names... */
+#define __NR__dl_stat  __NR_stat
+#define stat kernel_stat
+#define new_stat kernel_stat
+#include <asm/stat.h> 
+#undef new_stat
+#undef stat
+static inline _syscall2(int, _dl_stat, const char *, file_name, struct kernel_stat *, buf);
+
+
+#define __NR__dl_munmap __NR_munmap
+static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
+
+#define __NR__dl_getuid __NR_getuid
+static inline _syscall0(gid_t, _dl_getuid);
+
+#define __NR__dl_geteuid __NR_geteuid
+static inline _syscall0(uid_t, _dl_geteuid);
+
+#define __NR__dl_getgid __NR_getgid
+static inline _syscall0(gid_t, _dl_getgid);
+
+#define __NR__dl_getegid __NR_getegid
+static inline _syscall0(gid_t, _dl_getegid);
+
+/*
+ * Not an actual syscall, but we need something in assembly to say whether
+ * this is OK or not.
+ */
+extern inline int _dl_suid_ok(void)
+{
+    uid_t uid, euid, gid, egid;
+
+    uid = _dl_getuid();
+    euid = _dl_geteuid();
+    gid = _dl_getgid();
+    egid = _dl_getegid();
+
+    if(uid == euid && gid == egid)
+       return 1;
+    else
+       return 0;
+}
+
index ca97823..39171b2 100644 (file)
@@ -1,7 +1,7 @@
 TOPDIR=../../
 include $(TOPDIR)/ld.so-1/Rules.mak
 
-CFLAGS += -DNO_UNDERSCORE -DVERBOSE_DLINKER -DUSE_CACHE
+CFLAGS += -DUSE_CACHE
 CFLAGS += #-fPIC -D__PIC__ #-funroll-loops
 
 CSRC= dlib.c