about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/i386
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386')
-rw-r--r--sysdeps/unix/sysv/linux/i386/Dist2
-rw-r--r--sysdeps/unix/sysv/linux/i386/init-first.h38
-rw-r--r--sysdeps/unix/sysv/linux/i386/mmap.S8
3 files changed, 31 insertions, 17 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/Dist b/sysdeps/unix/sysv/linux/i386/Dist
index 4e4f467392..780edfca50 100644
--- a/sysdeps/unix/sysv/linux/i386/Dist
+++ b/sysdeps/unix/sysv/linux/i386/Dist
@@ -1,3 +1,3 @@
 sys/perm.h sys/vm86.h
 init-first.h
-close.S
+clone.S
diff --git a/sysdeps/unix/sysv/linux/i386/init-first.h b/sysdeps/unix/sysv/linux/i386/init-first.h
index f42d7f2533..4c61f1b41e 100644
--- a/sysdeps/unix/sysv/linux/i386/init-first.h
+++ b/sysdeps/unix/sysv/linux/i386/init-first.h
@@ -1,13 +1,27 @@
-/* This fragment is invoked in the stack context of program start.
-   Its job is to set up a pointer to argc as an argument, pass
-   control to `INIT', and, if necessary, clean up after the call
-   to leave the stack in the same condition it was found in.  */
+/* The job of this fragment it to find argc and friends for INIT.
+   This is done in one of two ways: either in the stack context
+   of program start, or having dlopen pass them in.  */
 
-#define SYSDEP_CALL_INIT(NAME, INIT)	\
-    asm(".globl " #NAME "\n\t"		\
-	#NAME ":\n\t"			\
-	"lea 4(%esp), %eax\n\t"		\
-	"pushl %eax\n\t"		\
-	"call " #INIT "\n\t"		\
-	"popl %eax\n\t"			\
-	"ret");
+#define SYSDEP_CALL_INIT(NAME, INIT)					      \
+void NAME (void *arg)							      \
+{									      \
+  int argc;								      \
+  char **argv, **envp;							      \
+									      \
+  __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;		      \
+									      \
+  if (!__libc_multiple_libcs)						      \
+    {									      \
+      argc = (int) arg;							      \
+      argv = (char **) &arg + 1;					      \
+      envp = &argv[argc+1];						      \
+    }									      \
+  else									      \
+    {									      \
+      argc = (int) arg;							      \
+      argv = ((char ***) &arg)[1];					      \
+      envp = ((char ***) &arg)[2];					      \
+    }									      \
+									      \
+  INIT (argc, argv, envp);						      \
+}
diff --git a/sysdeps/unix/sysv/linux/i386/mmap.S b/sysdeps/unix/sysv/linux/i386/mmap.S
index 90ac88c46f..638d548e00 100644
--- a/sysdeps/unix/sysv/linux/i386/mmap.S
+++ b/sysdeps/unix/sysv/linux/i386/mmap.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996 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
@@ -36,9 +36,9 @@ ENTRY (__mmap)
 	/* Restore registers.  */
 	movl %edx, %ebx
 
-	/* %eax is < 0 if there was an error.  */
-	testl %eax, %eax
-	jl syscall_error
+	/* If 0 > %eax > -4096 there was an error.  */
+	cmpl $-4096, %eax
+	ja syscall_error
 
 	/* Successful; return the syscall's value.  */
 	ret