Wed Jul 3 11:26:28 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
authorRoland McGrath <roland@gnu.org>
Wed, 3 Jul 1996 18:51:10 +0000 (18:51 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 3 Jul 1996 18:51:10 +0000 (18:51 +0000)
* time/strftime.c (strftime: do_number): Adjust P and I after sprintf
in case it wrote fewer than MAXDIGITS chars.

* stdio/fwrite.c (fwrite: fill_buffer): Separate flushing for last
newline from flushing full buffer in loop, fix test so no fflush is
done when last byte written exactly fills the buffer.

* nss/Makefile ($(services:%=$(objpfx)libnss_%.so)): Depend on libc.so.

* sysdeps/mach/hurd/Makefile (LDLIBS-c.so): Variable removed.
(libc.so): Instead, give this deps on lib{mach,hurd}user.so.

* elf/dl-debug.c (_dl_debug_initialize): Use LDBASE arg instead of
extracting _dl_rtld_map.l_addr.

* sysdeps/i386/dl-machine.h (elf_machine_rel): Declare _dl_rtld_map as
weak.
* sysdeps/alpha/dl-machine.h (elf_machine_rela): Likewise.

* shlib-versions (*-*-*): Set libnss_db=1.

* elf/rtld.c (dl_main): Set _dl_rtld_map's DT_DEBUG location too.

ChangeLog
elf/dl-debug.c
nss/Makefile
stdio/fwrite.c
sysdeps/alpha/dl-machine.h
sysdeps/i386/dl-machine.h
sysdeps/mach/hurd/Makefile
time/strftime.c

index be5ffce..166ae2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,30 @@
+Wed Jul  3 11:26:28 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
+
+       * time/strftime.c (strftime: do_number): Adjust P and I after sprintf
+       in case it wrote fewer than MAXDIGITS chars.
+
+       * stdio/fwrite.c (fwrite: fill_buffer): Separate flushing for last
+       newline from flushing full buffer in loop, fix test so no fflush is
+       done when last byte written exactly fills the buffer.
+
+       * nss/Makefile ($(services:%=$(objpfx)libnss_%.so)): Depend on libc.so.
+
+       * sysdeps/mach/hurd/Makefile (LDLIBS-c.so): Variable removed.
+       (libc.so): Instead, give this deps on lib{mach,hurd}user.so.
+
+       * elf/dl-debug.c (_dl_debug_initialize): Use LDBASE arg instead of
+       extracting _dl_rtld_map.l_addr.
+
+       * sysdeps/i386/dl-machine.h (elf_machine_rel): Declare _dl_rtld_map as
+       weak.
+       * sysdeps/alpha/dl-machine.h (elf_machine_rela): Likewise.
+
+       * shlib-versions (*-*-*): Set libnss_db=1.
+
 Tue Jul  2 10:44:37 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
 
+       * elf/rtld.c (dl_main): Set _dl_rtld_map's DT_DEBUG location too.
+
        * rpm/template (%build): Use @prefix@ instead of always /usr.
        Set up configparms only if @prefix@ is in fact /usr.
        * rpm/Makefile ($(config)): Substitute $(prefix) for @prefix@.
index 861e001..1c4e3c7 100644 (file)
@@ -37,7 +37,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase)
     {
       /* Tell the debugger where to find the map of loaded objects.  */
       _r_debug.r_version = 1   /* R_DEBUG_VERSION XXX */;
-      _r_debug.r_ldbase = _dl_rtld_map.l_addr; /* Record our load address.  */
+      _r_debug.r_ldbase = ldbase;
       _r_debug.r_map = _dl_loaded;
       _r_debug.r_brk = (ElfW(Addr)) &_dl_debug_state;
     }
index 4ab774a..8df173c 100644 (file)
@@ -68,3 +68,8 @@ $(libnss_db-routines:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
         echo '#define GENERIC "../nss_db/db-XXX.c"';\
         echo '#include <$<>') > $@.new
        mv -f $@.new $@
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(services:%=$(objpfx)libnss_%.so): $(common-objpfx)libc.so
index 4d012f1..790c663 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1994, 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
@@ -126,56 +126,67 @@ DEFUN(fwrite, (ptr, size, nmemb, stream),
        }
     }
   else if (!default_func || buffer_space >= to_write)
-  fill_buffer:
-    /* There is enough room in the buffer for everything we
-       want to write or the user has specified his own output
-       buffer-flushing/expanding function.  */
-    while (to_write > 0)
-      {
-       register size_t n = to_write;
-
-       if (n > buffer_space)
-         n = buffer_space;
-
-       buffer_space -= n;
-
-       written += n;
-       to_write -= n;
-
-       if (n < 20)
-         while (n-- > 0)
-           *stream->__bufp++ = *p++;
-       else
-         {
-           memcpy ((PTR) stream->__bufp, (PTR) p, n);
-           stream->__bufp += n;
-           p += n;
-         }
-
-       if (buffer_space == 0 || (to_write == 0 && newlinep))
-         {
-           /* We've filled the buffer, so flush it.  */
-           if (fflush (stream) == EOF)
-             break;
-
-           /* Reset our record of the space available in the buffer,
-              since we have just flushed it.  */
-         check_space:
-           buffer_space = (stream->__bufsize -
-                           (stream->__bufp - stream->__buffer));
-           if (buffer_space == 0)
-             {
-               /* With a custom output-room function, flushing might
-                  not create any buffer space.  Try writing a single
-                  character to create the space.  */
-               if (__flshfp (stream, *p++) == EOF)
-                 goto done;
-               ++written;
-               --to_write;
-               goto check_space;
-             }
-         }
-      }
+    {
+      /* There is enough room in the buffer for everything we want to write
+        or the user has specified his own output buffer-flushing/expanding
+        function.  */
+    fill_buffer:
+      while (to_write > 0)
+       {
+         register size_t n = to_write;
+
+         if (n > buffer_space)
+           n = buffer_space;
+
+         buffer_space -= n;
+
+         written += n;
+         to_write -= n;
+
+         if (n < 20)
+           while (n-- > 0)
+             *stream->__bufp++ = *p++;
+         else
+           {
+             memcpy ((PTR) stream->__bufp, (PTR) p, n);
+             stream->__bufp += n;
+             p += n;
+           }
+
+         if (to_write == 0)
+           /* Done writing.  */
+           break;
+         else if (buffer_space == 0)
+           {
+             /* We have filled the buffer, so flush it.  */
+             if (fflush (stream) == EOF)
+               break;
+
+             /* Reset our record of the space available in the buffer,
+                since we have just flushed it.  */
+           check_space:
+             buffer_space = (stream->__bufsize -
+                             (stream->__bufp - stream->__buffer));
+             if (buffer_space == 0)
+               {
+                 /* With a custom output-room function, flushing might
+                    not create any buffer space.  Try writing a single
+                    character to create the space.  */
+                 if (__flshfp (stream, *p++) == EOF)
+                   goto done;
+                 ++written;
+                 --to_write;
+                 goto check_space;
+               }
+           }
+       }
+
+      /* We have written all the data into the buffer.  If we are
+        line-buffered and just put a newline in the buffer, flush now to
+        make sure it gets out.  */
+      if (newlinep)
+       fflush (stream);
+    }
   else
     {
       /* It won't all fit in the buffer.  */
index a276551..bfde666 100644 (file)
@@ -161,6 +161,7 @@ elf_machine_rela (struct link_map *map,
 {
   Elf64_Addr *const reloc_addr = (void *)(map->l_addr + reloc->r_offset);
   unsigned long r_info = ELF64_R_TYPE (reloc->r_info);
+  weak_symbol (_dl_rtld_map);  /* Defined in rtld.c, but not in libc.a.  */
 
   /* We cannot use a switch here because we cannot locate the switch
      jump table until we've self-relocated.  */
index c164d3d..4061338 100644 (file)
@@ -80,6 +80,7 @@ elf_machine_rel (struct link_map *map,
 {
   Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
   Elf32_Addr loadbase, undo;
+  weak_symbol (_dl_rtld_map);  /* Defined in rtld.c, but not in libc.a.  */
 
   switch (ELF32_R_TYPE (reloc->r_info))
     {
index bbee3fa..200f2b0 100644 (file)
@@ -103,7 +103,8 @@ endif
 
 # For the shared library, we don't need to do the linker script machination.
 # Instead, we specify the required libraries when building the shared object.
-LDLIBS-c.so = -lmachuser -lhurduser
+$(common-objpfx)libc.so: $(firstword $(objdir) $(..)mach)/libmachuser.so \
+                        $(firstword $(objdir) $(..)hurd)/libhurduser.so
 ifndef objpfx
 rpath-link += $(..)mach:$(..)hurd
 endif
index c781841..1af2f83 100644 (file)
@@ -358,6 +358,9 @@ strftime (s, maxsize, format, tp)
            add (maxdigits, sprintf (p, number_fmt, number_value);
                 printed = strlen (p));
 #endif
+           /* Back up if fewer than MAXDIGITS chars written for pad_none.  */
+           p -= maxdigits - printed;
+           i -= maxdigits - printed;
 
            break;
          }