about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog29
-rw-r--r--elf/Makefile2
-rw-r--r--elf/dl-minimal.c153
-rw-r--r--elf/rtld.c50
-rw-r--r--stdio-common/vfprintf.c5
-rw-r--r--stdio-common/vfscanf.c5
-rw-r--r--sysdeps/mach/hurd/dl-sysdep.c56
-rw-r--r--sysdeps/unix/sysv/linux/i386/brk.S8
-rw-r--r--sysdeps/unix/sysv/linux/i386/fpu_control.c2
-rw-r--r--sysdeps/unix/sysv/linux/i386/fpu_control.h10
-rw-r--r--sysdeps/unix/sysv/linux/i386/ieee_fpu.c2
-rw-r--r--sysdeps/unix/sysv/linux/i386/init-first.c2
-rw-r--r--sysdeps/unix/sysv/linux/i386/sysdep.S1
-rw-r--r--sysdeps/unix/sysv/linux/sockaddrcom.h37
14 files changed, 198 insertions, 164 deletions
diff --git a/ChangeLog b/ChangeLog
index f7e5ef69ce..6ef1a87a76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+Wed Nov 22 12:37:39 1995  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>
+
+	* sysdeps/unix/sysv/linux/i386/sysdep.S (_errno): Define as alias
+	for errno.
+
+	* stdio-common/vfprintf.c [USE_IN_LIBIO] (vfprintf): Define as
+	alias for _IO_vfprintf.
+
+	* sysdeps/unix/sysv/linux/sockaddrcom.h: File removed.
+
+	* sysdeps/unix/sysv/linux/i386/init-first.c (init): Use
+	__fpu_control instead of ___fpu_control.
+	* sysdeps/unix/sysv/linux/i386/ieee_fpu.c
+	(___fpu_control): Renamed to __fpu_control.
+	* sysdeps/unix/sysv/linux/i386/fpu_control.h: Likewise.
+	* sysdeps/unix/sysv/linux/i386/fpu_control.c: Likewise.
+
+	* elf/dl-minimal.c: New file.
+	* elf/Makefile (rtld-routines): Add dl-minimal.
+	* elf/rtld.c (__dgettext, __assert_fail, __assert_perror_fail):
+	Functions moved to dl-minimal.c.
+	* sysdeps/mach/hurd/dl-sysdep.c (malloc, free, realloc,
+	sigjmp_save, longjmp): Likewise.
+
+	* sysdeps/unix/sysv/linux/i386/brk.S (__curbrk): Always initialize
+	to &_end, regardless of PIC.
+
+	* stdio-common/vfscanf.c (__vfscanf): Fix arg name in defn.
+
 Tue Nov 21 14:12:13 1995  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>
 
 	* malloc/malloc.c (align): Don't check contiguity and call abort.
diff --git a/elf/Makefile b/elf/Makefile
index 4a1adb8b59..16a6cca2fe 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -28,7 +28,7 @@ libelf-routines	:= elf_hash
 libdl-routines	:= dlopen dlclose dlsym dlerror
 libdl-inhibit-o	= $(filter-out .so,$(object-suffixes)) # Build only shared.
 
-rtld-routines	:= rtld $(addprefix dl-,load lookup object reloc	\
+rtld-routines	:= rtld $(addprefix dl-,minimal load lookup object reloc \
 				        runtime sysdep error init fini)
 distribute	= $(rtld-routines:=.c) dynamic-link.h do-rel.h \
 		  soinit.c sofini.c ldd.sh.in linux-compat.c
diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c
new file mode 100644
index 0000000000..332f21e0b0
--- /dev/null
+++ b/elf/dl-minimal.c
@@ -0,0 +1,153 @@
+/* Minimal replacements for basic facilities used in the dynamic linker.
+Copyright (C) 1995 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <assert.h>
+#include <string.h>
+#include <link.h>
+#include "../stdio-common/_itoa.h"
+
+/* Minimal `malloc' allocator for use while loading shared libraries.
+   Only small blocks are allocated, and none are ever freed.  */
+
+static void *alloc_ptr, *alloc_end, *alloc_last_block;
+
+void *
+malloc (size_t n)
+{
+  extern int _dl_zerofd;
+  static size_t pagesize;
+
+  if (pagesize == 0)
+    pagesize = __getpagesize ();
+
+  if (_dl_zerofd == -1)
+    _dl_zerofd = _dl_sysdep_open_zero_fill ();
+
+  if (alloc_end == 0)
+    {
+      /* Consume any unused space in the last page of our data segment.  */
+      extern int _end;
+      alloc_ptr = &_end;
+      alloc_end = (void *) 0 + (((alloc_ptr - (void *) 0) + pagesize - 1)
+				& ~(pagesize - 1));
+    }
+
+  /* Make sure the allocation pointer is ideally aligned.  */
+  alloc_ptr = (void *) 0 + (((alloc_ptr - (void *) 0) + sizeof (double) - 1)
+			    & ~(sizeof (double) - 1));
+
+  if (alloc_ptr + n >= alloc_end)
+    {
+      /* Insufficient space left; allocate another page.  */
+      caddr_t page;
+      assert (n <= pagesize);
+      page = mmap (0, pagesize, PROT_READ|PROT_WRITE, MAP_ANON, _dl_zerofd, 0);
+      assert (page != (caddr_t) -1);
+      if (page != alloc_end)
+	alloc_ptr = page;
+      alloc_end = page + pagesize;
+    }
+
+  alloc_last_block = (void *) alloc_ptr;
+  alloc_ptr += n;
+  return alloc_last_block;
+}
+weak_symbol (malloc)
+
+/* This will rarely be called.  */
+void
+free (void *ptr)
+{
+  /* We can free only the last block allocated.  */
+  if (ptr == alloc_last_block)
+    alloc_ptr = alloc_last_block;
+}
+weak_symbol (free)
+
+/* This is never called.  */
+void *
+realloc (void *ptr, size_t n)
+{ ptr += n; abort (); }
+weak_symbol (realloc)
+
+/* Avoid signal frobnication in setjmp/longjmp.  Keeps things smaller.  */
+
+#include <setjmp.h>
+
+int __sigjmp_save (sigjmp_buf env, int savemask)
+{ env[0].__mask_was_saved = savemask; return 0; }
+weak_symbol (__sigjmp_save)
+
+void
+longjmp (jmp_buf env, int val) { __longjmp (env[0].__jmpbuf, val); }
+weak_symbol (longjmp)
+
+
+/* Define our own stub for the localization function used by strerror.
+   English-only in the dynamic linker keeps it smaller.  */
+
+char *
+__dgettext (const char *domainname, const char *msgid)
+{
+  assert (domainname == _libc_intl_domainname);
+  return (char *) msgid;
+}
+weak_symbol (__dgettext)
+weak_alias (__dgettext, dgettext)
+
+#ifndef NDEBUG
+
+/* Define (weakly) our own assert failure function which doesn't use stdio.
+   If we are linked into the user program (-ldl), the normal __assert_fail
+   defn can override this one.  */
+
+void
+__assert_fail (const char *assertion,
+	       const char *file, unsigned int line, const char *function)
+{
+  char buf[64];
+  buf[sizeof buf - 1] = '\0';
+  _dl_sysdep_fatal ("BUG IN DYNAMIC LINKER ld.so: ",
+		    file, ": ", _itoa (line, buf + sizeof buf - 1, 10, 0),
+		    ": ", function ?: "", function ? ": " : "",
+		    "Assertion `", assertion, "' failed!\n",
+		    NULL);
+
+}
+weak_symbol (__assert_fail)
+
+void
+__assert_perror_fail (int errnum,
+		      const char *file, unsigned int line,
+		      const char *function)
+{
+  char buf[64];
+  buf[sizeof buf - 1] = '\0';
+  _dl_sysdep_fatal ("BUG IN DYNAMIC LINKER ld.so: ",
+		    file, ": ", _itoa (line, buf + sizeof buf - 1, 10, 0),
+		    ": ", function ?: "", function ? ": " : "",
+		    "Unexpected error: ", strerror (errnum), "\n", NULL);
+
+}
+weak_symbol (__assert_perror_fail)
+
+#endif
diff --git a/elf/rtld.c b/elf/rtld.c
index cf9517d527..62d6488767 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -381,53 +381,3 @@ void
 _dl_r_debug_state (void)
 {
 }
-
-/* Define our own stub for the localization function used by strerror.
-   English-only in the dynamic linker keeps it smaller.  */
-
-char *
-__dgettext (const char *domainname, const char *msgid)
-{
-  assert (domainname == _libc_intl_domainname);
-  return (char *) msgid;
-}
-weak_symbol (__dgettext)
-weak_alias (__dgettext, dgettext)
-
-#ifndef NDEBUG
-
-/* Define (weakly) our own assert failure function which doesn't use stdio.
-   If we are linked into the user program (-ldl), the normal __assert_fail
-   defn can override this one.  */
-
-void
-__assert_fail (const char *assertion,
-	       const char *file, unsigned int line, const char *function)
-{
-  char buf[64];
-  buf[sizeof buf - 1] = '\0';
-  _dl_sysdep_fatal ("BUG IN DYNAMIC LINKER ld.so: ",
-		    file, ": ", _itoa (line, buf + sizeof buf - 1, 10, 0),
-		    ": ", function ?: "", function ? ": " : "",
-		    "Assertion `", assertion, "' failed!\n",
-		    NULL);
-
-}
-weak_symbol (__assert_fail)
-
-void
-__assert_perror_fail (int errnum,
-		      const char *file, unsigned int line,
-		      const char *function)
-{
-  char buf[64];
-  buf[sizeof buf - 1] = '\0';
-  _dl_sysdep_fatal ("BUG IN DYNAMIC LINKER ld.so: ",
-		    file, ": ", _itoa (line, buf + sizeof buf - 1, 10, 0),
-		    ": ", function ?: "", function ? ": " : "",
-		    "Unexpected error: ", strerror (errnum), "\n", NULL);
-
-}
-weak_symbol (__assert_perror_fail)
-
-#endif
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 9e855ded56..c73661973a 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -617,6 +617,11 @@ vfprintf (s, format, ap)
   return done;
 }
 
+#ifdef USE_IN_LIBIO
+#undef vfprintf
+strong_alias (_IO_vfprintf, vfprintf)
+#endif
+
 
 /* Handle an unknown format specifier.  This prints out a canonicalized
    representation of the format spec itself.  */
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index a3c058495e..a0bb63281c 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -98,10 +98,7 @@ _IO_vfscanf (s, format, argptr, errp)
      int *errp;
 #else
 int
-__vfscanf (s, format, arg)
-     FILE *s;
-     const char *format;
-     va_list argptr;
+__vfscanf (FILE *s, const char *format, va_list argptr)
 #endif
 {
   va_list arg = (va_list) argptr;
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index f8997fe025..a2ffcd2e8c 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -535,62 +535,6 @@ weak_symbol (open)
 weak_symbol (close)
 weak_symbol (mmap)
 
-/* Minimal `malloc' allocator for use while loading shared libraries.
-   Only small blocks are allocated, and none are ever freed.  */
-
-void *
-malloc (size_t n)
-{
-  static vm_address_t ptr, end;
-  void *block;
-
-  if (end == 0)
-    {
-      /* Consume any unused space in the last page of our data segment.  */
-      extern char _end;
-      ptr = (vm_address_t) &_end;
-      end = round_page (ptr);
-    }
-
-  /* Make sure the allocation pointer is ideally aligned.  */
-  ptr += sizeof (double) - 1;
-  ptr &= ~(sizeof (double) - 1);
-
-  if (ptr + n >= end)
-    {
-      /* Insufficient space left; allocate another page.  */
-      vm_address_t page;
-      assert (n <= __vm_page_size);
-      __vm_allocate (__mach_task_self (), &page, __vm_page_size, 1);
-      if (page != end)
-	ptr = page;
-      end = page + __vm_page_size;
-    }
-
-  block = (void *) ptr;
-  ptr += n;
-  return block;
-}
-weak_symbol (malloc)
-
-/* This should never be called.  */
-void *realloc (void *ptr, size_t n) { ptr += n; abort (); }
-weak_symbol (realloc)
-
-/* This will rarely be called.  */
-void free (void *ptr) { ptr = ptr; }
-weak_symbol (free)
-
-/* Avoid signal frobnication in setjmp/longjmp.  */
-
-int __sigjmp_save (sigjmp_buf env, int savemask)
-{ env[0].__mask_was_saved = savemask; return 0; }
-weak_symbol (__sigjmp_save)
-
-void
-longjmp (jmp_buf env, int val) { __longjmp (env[0].__jmpbuf, val); }
-weak_symbol (longjmp)
-
 
 /* This function is called by interruptible RPC stubs.  For initial
    dynamic linking, just use the normal mach_msg.  Since this defn is
diff --git a/sysdeps/unix/sysv/linux/i386/brk.S b/sysdeps/unix/sysv/linux/i386/brk.S
index 754ec5ef09..e54e311f23 100644
--- a/sysdeps/unix/sysv/linux/i386/brk.S
+++ b/sysdeps/unix/sysv/linux/i386/brk.S
@@ -21,15 +21,7 @@ Cambridge, MA 02139, USA.  */
 .data
 .globl C_SYMBOL_NAME(__curbrk)
 C_LABEL(__curbrk)
-#ifdef PIC
-	.long 0
-#else
-# ifdef HAVE_GNU_LD
 	.long C_SYMBOL_NAME(_end)
-# else
-	.long C_SYMBOL_NAME(end)
-# endif
-#endif
 
 .text
 
diff --git a/sysdeps/unix/sysv/linux/i386/fpu_control.c b/sysdeps/unix/sysv/linux/i386/fpu_control.c
index 79933b90eb..b6840d0b17 100644
--- a/sysdeps/unix/sysv/linux/i386/fpu_control.c
+++ b/sysdeps/unix/sysv/linux/i386/fpu_control.c
@@ -17,4 +17,4 @@ License along with the GNU C Library; see the file COPYING.LIB.  If
 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-unsigned short ___fpu_control = 0;
+unsigned short __fpu_control = 0;
diff --git a/sysdeps/unix/sysv/linux/i386/fpu_control.h b/sysdeps/unix/sysv/linux/i386/fpu_control.h
index 470e960853..8cf4292643 100644
--- a/sysdeps/unix/sysv/linux/i386/fpu_control.h
+++ b/sysdeps/unix/sysv/linux/i386/fpu_control.h
@@ -21,7 +21,7 @@ Boston, MA 02111-1307, USA.  */
 #define _FPU_CONTROL_H
 
 /* Here is the dirty part. Settup up your 387 through the control word
- * (cw) register. 
+ * (cw) register.
  *
  *     15-13    12  11-10  9-8     7-6     5    4    3    2    1    0
  * | reserved | IC | RC  | PC | reserved | PM | UM | OM | ZM | DM | IM
@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA.  */
  * OM: Overflow mask
  * UM: Underflow mask
  * PM: Precision (inexact result) mask
- * 
+ *
  * Mask bit is 1 means no interrupt.
  *
  * PC: Precision control
@@ -55,7 +55,7 @@ Boston, MA 02111-1307, USA.  */
 #include <features.h>
 
 /* masking of interrupts */
-#define _FPU_MASK_IM  0x01  
+#define _FPU_MASK_IM  0x01
 #define _FPU_MASK_DM  0x02
 #define _FPU_MASK_ZM  0x04
 #define _FPU_MASK_OM  0x08
@@ -82,13 +82,13 @@ Boston, MA 02111-1307, USA.  */
      - extended precision
      - rounding to nearest
      - exceptions on overflow, zero divide and NaN */
-#define _FPU_DEFAULT  0x1372 
+#define _FPU_DEFAULT  0x1372
 
 /* IEEE:  same as above, but exceptions */
 #define _FPU_IEEE     0x137f
 
 /* private namespace. It should only be used in init-first.o. */
-extern unsigned short ___fpu_control;
+extern unsigned short __fpu_control;
 
 __BEGIN_DECLS
 
diff --git a/sysdeps/unix/sysv/linux/i386/ieee_fpu.c b/sysdeps/unix/sysv/linux/i386/ieee_fpu.c
index 4a0bf31e7c..41511547b2 100644
--- a/sysdeps/unix/sysv/linux/i386/ieee_fpu.c
+++ b/sysdeps/unix/sysv/linux/i386/ieee_fpu.c
@@ -19,4 +19,4 @@ Boston, MA 02111-1307, USA.  */
 
 #include <fpu_control.h>
 
-unsigned short ___fpu_control = _FPU_IEEE;
+unsigned short __fpu_control = _FPU_IEEE;
diff --git a/sysdeps/unix/sysv/linux/i386/init-first.c b/sysdeps/unix/sysv/linux/i386/init-first.c
index 84b5ff9f2c..9ee3f77ef5 100644
--- a/sysdeps/unix/sysv/linux/i386/init-first.c
+++ b/sysdeps/unix/sysv/linux/i386/init-first.c
@@ -44,7 +44,7 @@ init (int *data)
        : : "a" (SYS_ify (personality)));
 
   /* Set the FPU control word to the proper default value.  */
-  __setfpucw (___fpu_control);
+  __setfpucw (__fpu_control);
 
   __environ = envp;
   __libc_init (argc, argv, envp);
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.S b/sysdeps/unix/sysv/linux/i386/sysdep.S
index 0f05c84808..42f4854797 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.S
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.S
@@ -24,6 +24,7 @@ Cambridge, MA 02139, USA.  */
 
    ...and this place is here.  */
 .comm errno,4,4
+_errno = errno	/* This name is expected by hj libc.so.5 startup code.  */
 
 /* The following code is not used at all in the shared library.
    The PIC system call stubs set errno themselves.  */
diff --git a/sysdeps/unix/sysv/linux/sockaddrcom.h b/sysdeps/unix/sysv/linux/sockaddrcom.h
deleted file mode 100644
index 768d05be35..0000000000
--- a/sysdeps/unix/sysv/linux/sockaddrcom.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Definition of `struct sockaddr_*' common members.  Generic/4.2 BSD version.
-Copyright (C) 1995 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 Library General Public License as
-published by the Free Software Foundation; either version 2 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
-
-#ifndef _SOCKADDRCOM_H
-#define _SOCKADDRCOM_H	1
-
-/* This prevents including the file <linux/socket.h>.  */
-#define _LINUX_SOCKET_H
-#define _LINUX_TYPES_H
-
-/* This macro is used to declare the initial common members
-   of the data types used for socket addresses, `struct sockaddr',
-   `struct sockaddr_in', `struct sockaddr_un', etc.  */
-
-#define	__SOCKADDR_COMMON(sa_prefix) \
-  unsigned short int sa_prefix##family
-
-#define __SOCKADDR_COMMON_SIZE	(sizeof (unsigned short int))
-
-
-#endif	/* sockaddrcom.h */