about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-07-03 18:51:10 +0000
committerRoland McGrath <roland@gnu.org>1996-07-03 18:51:10 +0000
commit8a594e3cb7ea389cec5043cfcfd865d2bd0b8138 (patch)
tree935db58a3859f00a437f60fe675b1748834eee00
parentf0585c83b2b70f4fb04c4c2f3611b2a5150cd888 (diff)
downloadglibc-8a594e3cb7ea389cec5043cfcfd865d2bd0b8138.tar.gz
glibc-8a594e3cb7ea389cec5043cfcfd865d2bd0b8138.tar.xz
glibc-8a594e3cb7ea389cec5043cfcfd865d2bd0b8138.zip
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.

	* elf/rtld.c (dl_main): Set _dl_rtld_map's DT_DEBUG location too.
-rw-r--r--ChangeLog25
-rw-r--r--elf/dl-debug.c2
-rw-r--r--nss/Makefile5
-rw-r--r--stdio/fwrite.c113
-rw-r--r--sysdeps/alpha/dl-machine.h1
-rw-r--r--sysdeps/i386/dl-machine.h1
-rw-r--r--sysdeps/mach/hurd/Makefile3
-rw-r--r--time/strftime.c3
8 files changed, 100 insertions, 53 deletions
diff --git a/ChangeLog b/ChangeLog
index be5ffcef43..166ae2e9db 100644
--- 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@.
diff --git a/elf/dl-debug.c b/elf/dl-debug.c
index 861e0019e8..1c4e3c76aa 100644
--- a/elf/dl-debug.c
+++ b/elf/dl-debug.c
@@ -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;
     }
diff --git a/nss/Makefile b/nss/Makefile
index 4ab774a809..8df173cbdf 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -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
diff --git a/stdio/fwrite.c b/stdio/fwrite.c
index 4d012f1779..790c663aea 100644
--- a/stdio/fwrite.c
+++ b/stdio/fwrite.c
@@ -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.  */
diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h
index a276551b00..bfde6662bf 100644
--- a/sysdeps/alpha/dl-machine.h
+++ b/sysdeps/alpha/dl-machine.h
@@ -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.  */
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index c164d3d47f..406133861d 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -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))
     {
diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile
index bbee3faa65..200f2b02a5 100644
--- a/sysdeps/mach/hurd/Makefile
+++ b/sysdeps/mach/hurd/Makefile
@@ -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
diff --git a/time/strftime.c b/time/strftime.c
index c781841c6a..1af2f83023 100644
--- a/time/strftime.c
+++ b/time/strftime.c
@@ -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;
 	  }