about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-02-27 06:01:16 +0000
committerUlrich Drepper <drepper@redhat.com>1997-02-27 06:01:16 +0000
commitceb2d9aaa86cc3d3d4accc294751c98d49bdc5c2 (patch)
tree977724555bd3c1007b415b88ed3994e6290f4451
parent867a8743a42f28c5a50de893c82db66ae215f69c (diff)
downloadglibc-ceb2d9aaa86cc3d3d4accc294751c98d49bdc5c2.tar.gz
glibc-ceb2d9aaa86cc3d3d4accc294751c98d49bdc5c2.tar.xz
glibc-ceb2d9aaa86cc3d3d4accc294751c98d49bdc5c2.zip
update from main archive 970226 cvs/libc-970301 cvs/libc-970228 cvs/libc-970227
1997-02-27 05:12  Ulrich Drepper  <drepper@cygnus.com>

	* manual/Makefile: Add rules to run and distribute xtract-typefun.
	* manual/xtract-typefun.awk: New file.  Script to extract function,
	variable, macro anchor to put into the `dir' file.
	* manual/signal.texi: Document difference between SysV and BSD
	signal(3) function and add documentation for sysv_signal.

	* sysdeps/libm-i387/e_acoshl.c: Clear upper half of word containing
	exponent before comparing.

1997-02-27 01:13  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/generic/netinet/in.h (htonl, htons, ntohl, ntohs): Change
	prototypes to use types with explicit width.  `unsigned long' is
	different on 64 bit systems.
	* sysdeps/unix/sysv/linux/netinet/in.h: Likewise.
	* sysdeps/generic/htonl.c: Likewise.
	* sysdeps/generic/htons.c: Likewise.
	* sysdeps/generic/ntohl.c: Likewise.
	* sysdeps/generic/ntohs.c: Likewise.
	Suggested by a sun <asun@zoology.washington.edu>.

1997-02-26 08:30  Andreas Jaeger  <aj@arthur.pfalz.de>

	* math/math.h: Include <__math.h> if __NO_MATH_INLINES is not
	defined and we want optimization.

1997-02-27 01:13  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/generic/netinet/in.h (htonl, htons, ntohl, ntohs): Change
	prototypes to use types with explicit width.  `unsigned long' is
	different on 64 bit systems.
	Suggested by a sun <asun@zoology.washington.edu>.

1997-02-02 19:53  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* misc/getpass.c: Don't disable canonical input.
	Reverted patch of Mon Jan  6 01:35:29 1997.

1996-12-14 22:07  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* libio/libioP.h (_IO_finish_t): Take additional parameter, to
	match the hidden __in_chrg parameter of the destructor.
	(_IO_FINISH): Pass zero for it.
	* libio/genops.c (_IO_default_finish): Add second parameter, which
	is ignored.
	* libio/memstream.c (_IO_mem_finish): Likewise.
	* libio/fileops.c (_IO_mem_finish): Likewise.
	* libio/strops.c (_IO_str_finish): Likewise.  All callers changed.

1997-02-27 00:23  H.J. Lu  <hjl@lucon.org>

	* time/Makefile: Avoid using patterns in dependencies.

1997-02-26 00:56  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* elf/rtld.c: Make _dl_start static.  Otherwise the linker on the
	SPARC will convert the call _dl_start into a call into the PLT.

	* elf/rtld.c (_dl_start): On the SPARC we need to adjust the value
	of arg to make it point to the actual values.

	* sysdeps/sparc/elf/DEFS.h: New ELF specific version.
	* sysdeps/sparc/Dist: Mention sysdeps/sparc/elf/DEFS.h.

	* sysdeps/sparc/bsd-_setjmp.S, sysdeps/sparc/bsd-setjmp.S: Make
	them PIC aware.

	* sysdeps/sparc/dl-machine.h (elf_machine_load_address):
	Implemented.
	(elf_machine_rela): Make it compile; fix existing relocation
	types; add unhandled relocation types.
	(ELF_ADJUST_ARG): Get pointer to arguments at program startup.
	(RTLD_START): Initial implementation, not yet finished.

	* sysdeps/sparc/elf/start.S: Fix.

	* sysdeps/sparc/fpu_control.h: Remove duplicate declaration of
	__setfpucw.

	* sysdeps/sparc/divrem.m4: Make compilable under Linux.
	* sysdeps/sparc/rem.S, sysdeps/sparc/sdiv.S, sysdeps/sparc/udiv.S,
	sysdeps/sparc/urem.S : Regenerated.

	* sysdeps/sparc/setjmp.S: Make it PIC aware.

	* sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S: Define
	__ASSEMBLY__ before using kernel header.

	* sysdeps/unix/sysv/linux/sparc/Makefile: Use -mv8 flag to compile
	rtld.c.

	* sysdeps/unix/sysv/linux/sparc/brk.c: Implement.
	* sysdeps/unix/sysv/linux/sparc/profil-counter.h: Remove code
	to handle old signals.
	* sysdeps/unix/sysv/linux/sparc/sigaction.c: Implements sigaction
	for all Linux/SPARC kernels.
	* sysdeps/unix/sysv/linux/sparc/syscall.S: Add code to store
	errno using __errno_location.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h: Add various handler
	macros for assembler sources.
	* sysdeps/unix/sysv/linux/sparc/errno.c: Define errno.

1997-02-25 16:02  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* elf/rtld.c (dl_main): Remove dead code that is never executed.
	Rename local variable l to main_map where it is used to point to
	the load_map for the executable.

1997-02-25 15:03  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* elf/dl-version.c (_dl_check_all_versions): Ignore libraries that
	could not be found.

1997-02-24 23:18  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* Makerules: Generate implicit object suffix rules automagically.
	(o-iterator): Move before first use.

	* Makeconfig (all-object-suffixes): Add .bo suffix.

1997-02-25 15:11  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/libm-i387/e_acoshf.S (__ieee754_acoshf): Test correct
	word on stack for overflow.

	C++.  Use __exception instead.
-rw-r--r--ChangeLog129
-rw-r--r--Makeconfig2
-rw-r--r--Makerules76
-rw-r--r--elf/dl-version.c2
-rw-r--r--elf/rtld.c116
-rw-r--r--libio/fileops.c6
-rw-r--r--libio/genops.c4
-rw-r--r--libio/libioP.h10
-rw-r--r--libio/memstream.c9
-rw-r--r--libio/strops.c6
-rw-r--r--manual/Makefile17
-rw-r--r--manual/signal.texi24
-rw-r--r--manual/xtract-typefun.awk26
-rw-r--r--math/math.h15
-rw-r--r--misc/getpass.c4
-rw-r--r--sysdeps/generic/htonl.c34
-rw-r--r--sysdeps/generic/htons.c34
-rw-r--r--sysdeps/generic/netinet/in.h15
-rw-r--r--sysdeps/generic/ntohl.c34
-rw-r--r--sysdeps/generic/ntohs.c34
-rw-r--r--sysdeps/libm-i387/e_acoshf.S4
-rw-r--r--sysdeps/libm-i387/e_acoshl.S3
-rw-r--r--sysdeps/mach/hurd/fcntlbits.h34
-rw-r--r--sysdeps/sparc/Dist1
-rw-r--r--sysdeps/sparc/bsd-_setjmp.S47
-rw-r--r--sysdeps/sparc/bsd-setjmp.S44
-rw-r--r--sysdeps/sparc/divrem.m44
-rw-r--r--sysdeps/sparc/dl-machine.h145
-rw-r--r--sysdeps/sparc/elf/DEFS.h5
-rw-r--r--sysdeps/sparc/elf/start.S31
-rw-r--r--sysdeps/sparc/fpu_control.h7
-rw-r--r--sysdeps/sparc/rem.S4
-rw-r--r--sysdeps/sparc/sdiv.S4
-rw-r--r--sysdeps/sparc/setjmp.S44
-rw-r--r--sysdeps/sparc/udiv.S4
-rw-r--r--sysdeps/sparc/urem.S4
-rw-r--r--sysdeps/unix/sysv/linux/netinet/in.h15
-rw-r--r--sysdeps/unix/sysv/linux/sparc/Makefile8
-rw-r--r--sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S109
-rw-r--r--sysdeps/unix/sysv/linux/sparc/errno.c1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/profil-counter.h11
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sigaction.c21
-rw-r--r--sysdeps/unix/sysv/linux/sparc/syscall.S19
-rw-r--r--sysdeps/unix/sysv/linux/sparc/syscalls.list3
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sysdep.S3
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sysdep.h41
-rw-r--r--time/Makefile12
47 files changed, 797 insertions, 428 deletions
diff --git a/ChangeLog b/ChangeLog
index c6bc83d747..45bc59523b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,130 @@
+1997-02-27 05:12  Ulrich Drepper  <drepper@cygnus.com>
+
+	* manual/Makefile: Add rules to run and distribute xtract-typefun.
+	* manual/xtract-typefun.awk: New file.  Script to extract function,
+	variable, macro anchor to put into the `dir' file.
+	* manual/signal.texi: Document difference between SysV and BSD
+	signal(3) function and add documentation for sysv_signal.
+
+	* sysdeps/libm-i387/e_acoshl.c: Clear upper half of word containing
+	exponent before comparing.
+
+1997-02-27 01:13  Ulrich Drepper  <drepper@cygnus.com>
+
+	* sysdeps/generic/netinet/in.h (htonl, htons, ntohl, ntohs): Change
+	prototypes to use types with explicit width.  `unsigned long' is
+	different on 64 bit systems.
+	* sysdeps/unix/sysv/linux/netinet/in.h: Likewise.
+	* sysdeps/generic/htonl.c: Likewise.
+	* sysdeps/generic/htons.c: Likewise.
+	* sysdeps/generic/ntohl.c: Likewise.
+	* sysdeps/generic/ntohs.c: Likewise.
+	Suggested by a sun <asun@zoology.washington.edu>.
+
+1997-02-26 08:30  Andreas Jaeger  <aj@arthur.pfalz.de>
+
+	* math/math.h: Include <__math.h> if __NO_MATH_INLINES is not
+	defined and we want optimization.
+
+1997-02-27 01:13  Ulrich Drepper  <drepper@cygnus.com>
+
+	* sysdeps/generic/netinet/in.h (htonl, htons, ntohl, ntohs): Change
+	prototypes to use types with explicit width.  `unsigned long' is
+	different on 64 bit systems.
+	Suggested by a sun <asun@zoology.washington.edu>.
+
+1997-02-02 19:53  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+	* misc/getpass.c: Don't disable canonical input.
+	Reverted patch of Mon Jan  6 01:35:29 1997.
+
+1996-12-14 22:07  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+	* libio/libioP.h (_IO_finish_t): Take additional parameter, to
+	match the hidden __in_chrg parameter of the destructor.
+	(_IO_FINISH): Pass zero for it.
+	* libio/genops.c (_IO_default_finish): Add second parameter, which
+	is ignored.
+	* libio/memstream.c (_IO_mem_finish): Likewise.
+	* libio/fileops.c (_IO_mem_finish): Likewise.
+	* libio/strops.c (_IO_str_finish): Likewise.  All callers changed.
+
+1997-02-27 00:23  H.J. Lu  <hjl@lucon.org>
+
+	* time/Makefile: Avoid using patterns in dependencies.
+
+1997-02-26 00:56  Miguel de Icaza  <miguel@nuclecu.unam.mx>
+
+	* elf/rtld.c: Make _dl_start static.  Otherwise the linker on the
+	SPARC will convert the call _dl_start into a call into the PLT.
+
+	* elf/rtld.c (_dl_start): On the SPARC we need to adjust the value
+	of arg to make it point to the actual values.
+
+	* sysdeps/sparc/elf/DEFS.h: New ELF specific version.
+	* sysdeps/sparc/Dist: Mention sysdeps/sparc/elf/DEFS.h.
+
+	* sysdeps/sparc/bsd-_setjmp.S, sysdeps/sparc/bsd-setjmp.S: Make
+	them PIC aware.
+
+	* sysdeps/sparc/dl-machine.h (elf_machine_load_address):
+	Implemented.
+	(elf_machine_rela): Make it compile; fix existing relocation
+	types; add unhandled relocation types.
+	(ELF_ADJUST_ARG): Get pointer to arguments at program startup.
+	(RTLD_START): Initial implementation, not yet finished.
+
+	* sysdeps/sparc/elf/start.S: Fix.
+
+	* sysdeps/sparc/fpu_control.h: Remove duplicate declaration of
+	__setfpucw.
+
+	* sysdeps/sparc/divrem.m4: Make compilable under Linux.
+	* sysdeps/sparc/rem.S, sysdeps/sparc/sdiv.S, sysdeps/sparc/udiv.S,
+	sysdeps/sparc/urem.S : Regenerated.
+
+	* sysdeps/sparc/setjmp.S: Make it PIC aware.
+
+	* sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S: Define
+	__ASSEMBLY__ before using kernel header.
+
+	* sysdeps/unix/sysv/linux/sparc/Makefile: Use -mv8 flag to compile
+	rtld.c.
+
+	* sysdeps/unix/sysv/linux/sparc/brk.c: Implement.
+	* sysdeps/unix/sysv/linux/sparc/profil-counter.h: Remove code
+	to handle old signals.
+	* sysdeps/unix/sysv/linux/sparc/sigaction.c: Implements sigaction
+	for all Linux/SPARC kernels.
+	* sysdeps/unix/sysv/linux/sparc/syscall.S: Add code to store
+	errno using __errno_location.
+	* sysdeps/unix/sysv/linux/sparc/sysdep.h: Add various handler
+	macros for assembler sources.
+	* sysdeps/unix/sysv/linux/sparc/errno.c: Define errno.
+
+1997-02-25 16:02  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+	* elf/rtld.c (dl_main): Remove dead code that is never executed.
+	Rename local variable l to main_map where it is used to point to
+	the load_map for the executable.
+
+1997-02-25 15:03  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+	* elf/dl-version.c (_dl_check_all_versions): Ignore libraries that
+	could not be found.
+
+1997-02-24 23:18  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+	* Makerules: Generate implicit object suffix rules automagically.
+	(o-iterator): Move before first use.
+
+	* Makeconfig (all-object-suffixes): Add .bo suffix.
+
+1997-02-25 15:11  Ulrich Drepper  <drepper@cygnus.com>
+
+	* sysdeps/libm-i387/e_acoshf.S (__ieee754_acoshf): Test correct
+	word on stack for overflow.
+
 1997-02-24 23:05  Wolfram Gloger  <wmglo@dent.med.uni-muenchen.de>
 
 	* malloc/malloc.c (malloc_get_state): New function.
@@ -155,7 +282,7 @@
 	__STRICT_ANSI__.
 
 	* math/math.h: Prevent definition of struct exception when using
-	C++.
+	C++.  Use __exception instead.
 
 1997-02-22 01:45  Ulrich Drepper  <drepper@cygnus.com>
 
diff --git a/Makeconfig b/Makeconfig
index 811392b13e..2501789440 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -481,7 +481,7 @@ endif
 # to pass different flags for each flavor.
 libtypes = $(foreach o,$(object-suffixes),$(libtype$o))
 object-suffixes := .o
-all-object-suffixes := .o .so .po .go
+all-object-suffixes := .o .so .po .go .bo
 libtype.o := lib%.a
 ifeq (yes,$(build-shared))
 # Under --enable-shared, we will build a shared library of PIC objects.
diff --git a/Makerules b/Makerules
index c5d5663bda..b4b7610b62 100644
--- a/Makerules
+++ b/Makerules
@@ -80,6 +80,12 @@ ar-symtab-name = __.SYMDEF
 else
 ar-symtab-name = # The null name is used in ELF archives.
 endif
+
+# This variable is used in ``include $(o-iterator)'' after defining
+# $(o-iterator-doit) to produce some desired rule using $o for the object
+# suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
+# is produced for each object suffix in use.
+o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
 
 # Include any system-specific makefiles.
 
@@ -167,23 +173,25 @@ $(common-objpfx)dummy.d:
 # generated sysdep rules in included from sysd-rules below.  When
 # compiling in the source tree, generated sources go into the current
 # directory, and those should be chosen before any sources in sysdeps.
-$(objpfx)%.o: %.S $(before-compile); $(compile-command.S)
-$(objpfx)%.so: %.S $(before-compile); $(compile-command.S)
-$(objpfx)%.po: %.S $(before-compile); $(compile-command.S)
-$(objpfx)%.go: %.S $(before-compile); $(compile-command.S)
-$(objpfx)%.bo: %.S $(before-compile); $(compile-command.S)
+define o-iterator-doit
+$(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
+endef
+object-suffixes-left := $(object-suffixes)
+include $(o-iterator)
 $(objpfx)%.d: %.S $(before-compile); $(+make-deps)
-$(objpfx)%.o: %.s $(before-compile); $(compile-command.s)
-$(objpfx)%.so: %.s $(before-compile); $(compile-command.s)
-$(objpfx)%.po: %.s $(before-compile); $(compile-command.s)
-$(objpfx)%.go: %.s $(before-compile); $(compile-command.s)
-$(objpfx)%.bo: %.s $(before-compile); $(compile-command.s)
+
+define o-iterator-doit
+$(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
+endef
+object-suffixes-left := $(object-suffixes)
+include $(o-iterator)
 $(objpfx)%.d: %.s $(common-objpfx)dummy.d; $(make-dummy-dep)
-$(objpfx)%.o: %.c $(before-compile); $(compile-command.c)
-$(objpfx)%.so: %.c $(before-compile); $(compile-command.c)
-$(objpfx)%.po: %.c $(before-compile); $(compile-command.c)
-$(objpfx)%.go: %.c $(before-compile); $(compile-command.c)
-$(objpfx)%.bo: %.c $(before-compile); $(compile-command.c)
+
+define o-iterator-doit
+$(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
+endef
+object-suffixes-left := $(object-suffixes)
+include $(o-iterator)
 $(objpfx)%.d: %.c $(before-compile); $(+make-deps)
 
 # Omit the objpfx rules when building in the source tree, because
@@ -191,23 +199,25 @@ $(objpfx)%.d: %.c $(before-compile); $(+make-deps)
 ifdef objpfx
 # Define first rules to find the source files in $(objpfx).
 # Generated source files will end up there.
-$(objpfx)%.o: $(objpfx)%.S $(before-compile); $(compile-command.S)
-$(objpfx)%.so: $(objpfx)%.S $(before-compile); $(compile-command.S)
-$(objpfx)%.po: $(objpfx)%.S $(before-compile); $(compile-command.S)
-$(objpfx)%.go: $(objpfx)%.S $(before-compile); $(compile-command.S)
-$(objpfx)%.bo: $(objpfx)%.S $(before-compile); $(compile-command.S)
+define o-iterator-doit
+$(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
+endef
+object-suffixes-left := $(object-suffixes)
+include $(o-iterator)
 $(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps)
-$(objpfx)%.o: $(objpfx)%.s $(before-compile); $(compile-command.s)
-$(objpfx)%.so: $(objpfx)%.s $(before-compile); $(compile-command.s)
-$(objpfx)%.po: $(objpfx)%.s $(before-compile); $(compile-command.s)
-$(objpfx)%.go: $(objpfx)%.s $(before-compile); $(compile-command.s)
-$(objpfx)%.bo: $(objpfx)%.s $(before-compile); $(compile-command.s)
+
+define o-iterator-doit
+$(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
+endef
+object-suffixes-left := $(object-suffixes)
+include $(o-iterator)
 $(objpfx)%.d: $(objpfx)%.s $(common-objpfx)dummy.d; $(make-dummy-dep)
-$(objpfx)%.o: $(objpfx)%.c $(before-compile); $(compile-command.c)
-$(objpfx)%.so: $(objpfx)%.c $(before-compile); $(compile-command.c)
-$(objpfx)%.po: $(objpfx)%.c $(before-compile); $(compile-command.c)
-$(objpfx)%.go: $(objpfx)%.c $(before-compile); $(compile-command.c)
-$(objpfx)%.bo: $(objpfx)%.c $(before-compile); $(compile-command.c)
+
+define o-iterator-doit
+$(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
+endef
+object-suffixes-left := $(object-suffixes)
+include $(o-iterator)
 $(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps)
 endif
 
@@ -391,12 +401,6 @@ headers := $(headers) $(sysdep_headers)
 override objects	:= $(addprefix $(objpfx),$(sources:.c=.o))
 
 
-# This variable is used in ``include $(o-iterator)'' after defining
-# $(o-iterator-doit) to produce some desired rule using $o for the object
-# suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
-# is produced for each object suffix in use.
-o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
-
 # The makefile may define $(extra-libs) with `libfoo libbar'
 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
 ifdef extra-libs
diff --git a/elf/dl-version.c b/elf/dl-version.c
index ae1c2f34f7..2a6f1b94df 100644
--- a/elf/dl-version.c
+++ b/elf/dl-version.c
@@ -334,7 +334,7 @@ _dl_check_all_versions (struct link_map *map, int verbose)
   int result = 0;
 
   for (l = map; l != NULL; l = l->l_next)
-    result |= _dl_check_map_versions (l, verbose);
+    result |= l->l_opencount != 0 && _dl_check_map_versions (l, verbose);
 
   return result;
 }
diff --git a/elf/rtld.c b/elf/rtld.c
index eb7b3bec2a..9f18e23b91 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -79,7 +79,7 @@ RTLD_START
 #error "sysdeps/MACHINE/dl-machine.h fails to define RTLD_START"
 #endif
 
-ElfW(Addr)
+static ElfW(Addr)
 _dl_start (void *arg)
 {
   struct link_map bootstrap_map;
@@ -126,6 +126,10 @@ _dl_start (void *arg)
 			_dl_rtld_map.l_info[DT_STRTAB]->d_un.d_ptr +
 			_dl_rtld_map.l_info[DT_RPATH]->d_un.d_val);
 
+#ifdef ELF_ADJUST_ARG
+  ELF_ADJUST_ARG(arg);
+#endif
+
   /* Call the OS-dependent function to set up life so we can do things like
      file access.  It will call `dl_main' (below) to do all the real work
      of the dynamic linker, and then unwind our frame and run the user
@@ -147,7 +151,7 @@ dl_main (const ElfW(Phdr) *phdr,
 	 ElfW(Addr) *user_entry)
 {
   const ElfW(Phdr) *ph;
-  struct link_map *l;
+  struct link_map *main_map;
   int lazy;
   enum { normal, list, verify, trace } mode;
   struct link_map **preloads;
@@ -235,7 +239,7 @@ of this helper program; chances are you did not intend to run this program.\n",
 	{
 	  void doit (void)
 	    {
-	      l = _dl_map_object (NULL, _dl_argv[0], lt_library, 0);
+	      main_map = _dl_map_object (NULL, _dl_argv[0], lt_library, 0);
 	    }
 	  char *err_str = NULL;
 	  const char *obj_name __attribute__ ((unused));
@@ -248,37 +252,23 @@ of this helper program; chances are you did not intend to run this program.\n",
 	    }
 	}
       else
-	l = _dl_map_object (NULL, _dl_argv[0], lt_library, 0);
+	main_map = _dl_map_object (NULL, _dl_argv[0], lt_library, 0);
 
-      phdr = l->l_phdr;
-      phent = l->l_phnum;
-      l->l_name = (char *) "";
-      *user_entry = l->l_entry;
+      phdr = main_map->l_phdr;
+      phent = main_map->l_phnum;
+      main_map->l_name = (char *) "";
+      *user_entry = main_map->l_entry;
     }
   else
     {
       /* Create a link_map for the executable itself.
 	 This will be what dlopen on "" returns.  */
-      l = _dl_new_object ((char *) "", "", lt_executable);
-      if (l == NULL)
+      main_map = _dl_new_object ((char *) "", "", lt_executable);
+      if (main_map == NULL)
 	_dl_sysdep_fatal ("cannot allocate memory for link map", NULL);
-      l->l_phdr = phdr;
-      l->l_phnum = phent;
-      l->l_entry = *user_entry;
-    }
-
-  if (l != _dl_loaded)
-    {
-      /* GDB assumes that the first element on the chain is the
-	 link_map for the executable itself, and always skips it.
-	 Make sure the first one is indeed that one.  */
-      l->l_prev->l_next = l->l_next;
-      if (l->l_next)
-	l->l_next->l_prev = l->l_prev;
-      l->l_prev = NULL;
-      l->l_next = _dl_loaded;
-      _dl_loaded->l_prev = l;
-      _dl_loaded = l;
+      main_map->l_phdr = phdr;
+      main_map->l_phnum = phent;
+      main_map->l_entry = *user_entry;
     }
 
   /* Scan the program header table for the dynamic section.  */
@@ -288,7 +278,7 @@ of this helper program; chances are you did not intend to run this program.\n",
       case PT_DYNAMIC:
 	/* This tells us where to find the dynamic section,
 	   which tells us everything we need to do.  */
-	l->l_ld = (void *) l->l_addr + ph->p_vaddr;
+	main_map->l_ld = (void *) main_map->l_addr + ph->p_vaddr;
 	break;
       case PT_INTERP:
 	/* This "interpreter segment" was used by the program loader to
@@ -297,7 +287,7 @@ of this helper program; chances are you did not intend to run this program.\n",
 	   dlopen call or DT_NEEDED entry, for something that wants to link
 	   against the dynamic linker as a shared library, will know that
 	   the shared object is already loaded.  */
-	_dl_rtld_libname.name = (const char *) l->l_addr + ph->p_vaddr;
+	_dl_rtld_libname.name = (const char *) main_map->l_addr + ph->p_vaddr;
 	_dl_rtld_libname.next = NULL;
 	_dl_rtld_map.l_libname = &_dl_rtld_libname;
 	has_interp = 1;
@@ -317,25 +307,24 @@ of this helper program; chances are you did not intend to run this program.\n",
   if (mode == verify)
     /* We were called just to verify that this is a dynamic executable
        using us as the program interpreter.  */
-    _exit (l->l_ld == NULL ? 1 : has_interp ? 0 : 2);
+    _exit (main_map->l_ld == NULL ? 1 : has_interp ? 0 : 2);
 
   /* Extract the contents of the dynamic section for easy access.  */
-  elf_get_dynamic_info (l->l_ld, l->l_info);
-  if (l->l_info[DT_HASH])
+  elf_get_dynamic_info (main_map->l_ld, main_map->l_info);
+  if (main_map->l_info[DT_HASH])
     /* Set up our cache of pointers into the hash table.  */
-    _dl_setup_hash (l);
+    _dl_setup_hash (main_map);
 
   /* Put the link_map for ourselves on the chain so it can be found by
-     name.  */
+     name.  Note that at this point the global chain of link maps contains
+     exactly one element, which is pointed to by main_map.  */
   if (! _dl_rtld_map.l_name)
     /* If not invoked directly, the dynamic linker shared object file was
        found by the PT_INTERP name.  */
     _dl_rtld_map.l_name = (char *) _dl_rtld_map.l_libname->name;
   _dl_rtld_map.l_type = lt_library;
-  while (l->l_next)
-    l = l->l_next;
-  l->l_next = &_dl_rtld_map;
-  _dl_rtld_map.l_prev = l;
+  main_map->l_next = &_dl_rtld_map;
+  _dl_rtld_map.l_prev = main_map;
 
   /* We have two ways to specify objects to preload: via environment
      variable and via the file /etc/ld.so.preload.  The later can also
@@ -445,7 +434,7 @@ of this helper program; chances are you did not intend to run this program.\n",
   /* Load all the libraries specified by DT_NEEDED entries.  If LD_PRELOAD
      specified some libraries to load, these are inserted before the actual
      dependencies in the executable's searchlist for symbol resolution.  */
-  _dl_map_object_deps (l, preloads, npreloads, mode == trace);
+  _dl_map_object_deps (main_map, preloads, npreloads, mode == trace);
 
 #ifndef MAP_ANON
   /* We are done mapping things, so close the zero-fill descriptor.  */
@@ -465,11 +454,11 @@ of this helper program; chances are you did not intend to run this program.\n",
 	 chain in symbol search order because gdb uses the chain's order as
 	 its symbol search order.  */
       unsigned int i = 1;
-      while (l->l_searchlist[i] != &_dl_rtld_map)
+      while (main_map->l_searchlist[i] != &_dl_rtld_map)
 	++i;
-      _dl_rtld_map.l_prev = l->l_searchlist[i - 1];
-      _dl_rtld_map.l_next = (i + 1 < l->l_nsearchlist ?
-			     l->l_searchlist[i + 1] : NULL);
+      _dl_rtld_map.l_prev = main_map->l_searchlist[i - 1];
+      _dl_rtld_map.l_next = (i + 1 < main_map->l_nsearchlist ?
+			     main_map->l_searchlist[i + 1] : NULL);
       assert (_dl_rtld_map.l_prev->l_next == _dl_rtld_map.l_next);
       _dl_rtld_map.l_prev->l_next = &_dl_rtld_map;
       if (_dl_rtld_map.l_next)
@@ -484,7 +473,7 @@ of this helper program; chances are you did not intend to run this program.\n",
   {
     void doit (void)
       {
-	if (_dl_check_all_versions (l, 1) && mode == normal)
+	if (_dl_check_all_versions (main_map, 1) && mode == normal)
 	  /* We cannot start the application.  Abort now.  */
 	  _exit (1);
       }
@@ -504,22 +493,26 @@ of this helper program; chances are you did not intend to run this program.\n",
       if (! _dl_loaded->l_info[DT_NEEDED])
 	_dl_sysdep_message ("\t", "statically linked\n", NULL);
       else
-	for (l = _dl_loaded->l_next; l; l = l->l_next)
-	  if (l->l_opencount == 0)
-	    /* The library was not found.  */
-	    _dl_sysdep_message ("\t", l->l_libname->name, " => not found\n",
-				NULL);
-	  else
-	    {
-	      char buf[20], *bp;
-	      buf[sizeof buf - 1] = '\0';
-	      bp = _itoa (l->l_addr, &buf[sizeof buf - 1], 16, 0);
-	      while ((size_t) (&buf[sizeof buf - 1] - bp)
-		     < sizeof l->l_addr * 2)
-		*--bp = '0';
-	      _dl_sysdep_message ("\t", l->l_libname->name, " => ", l->l_name,
-				  " (0x", bp, ")\n", NULL);
-	    }
+	{
+	  struct link_map *l;
+
+	  for (l = _dl_loaded->l_next; l; l = l->l_next)
+	    if (l->l_opencount == 0)
+	      /* The library was not found.  */
+	      _dl_sysdep_message ("\t", l->l_libname->name, " => not found\n",
+				  NULL);
+	    else
+	      {
+		char buf[20], *bp;
+		buf[sizeof buf - 1] = '\0';
+		bp = _itoa (l->l_addr, &buf[sizeof buf - 1], 16, 0);
+		while ((size_t) (&buf[sizeof buf - 1] - bp)
+		       < sizeof l->l_addr * 2)
+		  *--bp = '0';
+		_dl_sysdep_message ("\t", l->l_libname->name, " => ",
+				    l->l_name, " (0x", bp, ")\n", NULL);
+	      }
+	}
 
       if (mode != trace)
 	for (i = 1; i < _dl_argc; ++i)
@@ -544,6 +537,7 @@ of this helper program; chances are you did not intend to run this program.\n",
       else if (lazy >= 0)
 	{
 	  /* We have to do symbol dependency testing.  */
+	  struct link_map *l;
 	  void doit (void)
 	    {
 	      _dl_relocate_object (l, _dl_object_relocation_scope (l), lazy);
@@ -576,6 +570,7 @@ of this helper program; chances are you did not intend to run this program.\n",
        the dynamic linker out of order because it has no copy relocs (we
        know that because it is self-contained).  */
 
+    struct link_map *l;
     l = _dl_loaded;
     while (l->l_next)
       l = l->l_next;
@@ -605,6 +600,7 @@ of this helper program; chances are you did not intend to run this program.\n",
   {
     /* Initialize _r_debug.  */
     struct r_debug *r = _dl_debug_initialize (_dl_rtld_map.l_addr);
+    struct link_map *l;
 
     l = _dl_loaded;
 
diff --git a/libio/fileops.c b/libio/fileops.c
index 12b2ead125..3a0bdaaa62 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -138,8 +138,8 @@ DEFUN(_IO_file_close_it, (fp),
 }
 
 void
-DEFUN(_IO_file_finish, (fp),
-      register _IO_FILE* fp)
+DEFUN(_IO_file_finish, (fp, dummy),
+      register _IO_FILE* fp AND int dummy)
 {
   if (_IO_file_is_open(fp))
     {
@@ -147,7 +147,7 @@ DEFUN(_IO_file_finish, (fp),
       if (!(fp->_flags & _IO_DELETE_DONT_CLOSE))
 	_IO_SYSCLOSE (fp);
     }
-  _IO_default_finish(fp);
+  _IO_default_finish(fp, 0);
 }
 
 _IO_FILE *
diff --git a/libio/genops.c b/libio/genops.c
index e57328d529..db7fb180a3 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -481,8 +481,8 @@ DEFUN(_IO_default_sync, (fp),
    current implementation, this function can get called twice! */
 
 void
-DEFUN(_IO_default_finish, (fp),
-      _IO_FILE *fp)
+DEFUN(_IO_default_finish, (fp, dummy),
+      _IO_FILE *fp AND int dummy)
 {
   struct _IO_marker *mark;
   if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
diff --git a/libio/libioP.h b/libio/libioP.h
index c80bdf30c6..8fe11084df 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -101,8 +101,8 @@ extern "C" {
 /* The 'finish' function does any final cleaning up of an _IO_FILE object.
    It does not delete (free) it, but does everything else to finalize it/
    It matches the streambuf::~streambuf virtual destructor.  */
-typedef void (*_IO_finish_t) __P((_IO_FILE*)); /* finalize */
-#define _IO_FINISH(FP) JUMP0(__finish, FP)
+typedef void (*_IO_finish_t) __P((_IO_FILE*, int)); /* finalize */
+#define _IO_FINISH(FP) JUMP1(__finish, FP, 0)
 
 /* The 'overflow' hook flushes the buffer.
    The second argument is a character, or EOF.
@@ -295,7 +295,7 @@ extern int _IO_seekmark __P((_IO_FILE *, struct _IO_marker *, int));
 extern int _IO_default_underflow __P((_IO_FILE*));
 extern int _IO_default_uflow __P((_IO_FILE*));
 extern int _IO_default_doallocate __P((_IO_FILE*));
-extern void _IO_default_finish __P((_IO_FILE *));
+extern void _IO_default_finish __P((_IO_FILE *, int));
 extern int _IO_default_pbackfail __P((_IO_FILE*, int));
 extern _IO_FILE* _IO_default_setbuf __P((_IO_FILE *, char*, _IO_ssize_t));
 extern _IO_size_t _IO_default_xsputn __P((_IO_FILE *, const void*, _IO_size_t));
@@ -352,7 +352,7 @@ extern _IO_ssize_t _IO_file_read __P((_IO_FILE*, void*, _IO_ssize_t));
 extern int _IO_file_sync __P((_IO_FILE*));
 extern int _IO_file_close_it __P((_IO_FILE*));
 extern _IO_fpos_t _IO_file_seek __P((_IO_FILE *, _IO_off_t, int));
-extern void _IO_file_finish __P((_IO_FILE*));
+extern void _IO_file_finish __P((_IO_FILE*, int));
 
 /* Other file functions. */
 extern _IO_FILE* _IO_file_attach __P((_IO_FILE *, int));
@@ -366,7 +366,7 @@ extern int _IO_str_underflow __P((_IO_FILE*));
 extern int _IO_str_overflow __P((_IO_FILE *, int));
 extern int _IO_str_pbackfail __P((_IO_FILE*, int));
 extern _IO_fpos_t _IO_str_seekoff __P((_IO_FILE*,_IO_off_t,int,int));
-extern void _IO_str_finish __P ((_IO_FILE*));
+extern void _IO_str_finish __P ((_IO_FILE*, int));
 
 /* Other strfile functions */
 extern void _IO_str_init_static __P((_IO_FILE *, char*, int, char*));
diff --git a/libio/memstream.c b/libio/memstream.c
index e3c34d0b34..f03fc6e67d 100644
--- a/libio/memstream.c
+++ b/libio/memstream.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997 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
@@ -31,7 +31,7 @@ struct _IO_FILE_memstream
 
 
 static int _IO_mem_sync __P ((_IO_FILE* fp));
-static void _IO_mem_finish __P ((_IO_FILE* fp));
+static void _IO_mem_finish __P ((_IO_FILE* fp, int));
 
 
 static const struct _IO_jump_t _IO_mem_jumps =
@@ -124,8 +124,9 @@ _IO_mem_sync (fp)
 
 
 static void
-_IO_mem_finish (fp)
+_IO_mem_finish (fp, dummy)
      _IO_FILE* fp;
+     int dummy;
 {
   struct _IO_FILE_memstream *mp = (struct _IO_FILE_memstream *) fp;
 
@@ -139,5 +140,5 @@ _IO_mem_finish (fp)
 
   fp->_IO_buf_base = NULL;
 
-  _IO_default_finish (fp);
+  _IO_default_finish (fp, 0);
 }
diff --git a/libio/strops.c b/libio/strops.c
index 31c5df4e80..9c2650f352 100644
--- a/libio/strops.c
+++ b/libio/strops.c
@@ -258,14 +258,14 @@ DEFUN(_IO_str_pbackfail, (fp, c),
 }
 
 void
-DEFUN (_IO_str_finish, (fp),
-      register _IO_FILE* fp)
+DEFUN (_IO_str_finish, (fp, dummy),
+      register _IO_FILE* fp AND int dummy)
 {
   if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
     (((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base);
   fp->_IO_buf_base = NULL;
 
-  _IO_default_finish(fp);
+  _IO_default_finish(fp, 0);
 }
 
 struct _IO_jump_t _IO_str_jumps = {
diff --git a/manual/Makefile b/manual/Makefile
index 0f525be731..0e8ae85dc7 100644
--- a/manual/Makefile
+++ b/manual/Makefile
@@ -21,6 +21,9 @@
 subdir := manual
 export subdir := $(subdir)
 
+# We need GNU awk for the xtract-typefun script.
+GAWK = gawk
+
 .PHONY: all dvi info
 all: dvi info
 dvi: libc.dvi
@@ -60,6 +63,17 @@ stamp-summary: summary.awk $(chapters) $(chapters-incl)
 # touch is broken on our machines.  Sigh.
 	date > $@
 
+# Generate a file which can be added to the `dir' content to provide direct
+# access to the documentation of the function, variables, and other
+# definitions.
+dir-add.texi: manual/xtract-typefun.awk $(chapters-incl)
+	if test -n "$(chapters-incl)"; then \
+	  (for i in $(chapters-incl); do \
+	     $(GAWK) -f $< < $i; \
+	   done) | sort > $@.new; \
+	   ./move-if-change $@.new $@; \
+	fi
+
 # Generate Texinfo files from the C source for the example programs.
 %.c.texi: examples/%.c
 	sed -e 's,[{}],@&,g'				\
@@ -78,7 +92,8 @@ distribute = $(minimal-dist)	       					\
 	     $(patsubst examples/%.c,%.c.texi,$(filter examples/%.c,	\
 			$(minimal-dist)))				\
 	     libc.info* libc.?? libc.??s texinfo.tex summary.texi	\
-	     stamp-summary chapters chapters-incl
+	     stamp-summary chapters chapters-incl			\
+	     xtract-typefun.awk
 export distribute := $(distribute)
 
 tar-it = tar chovf $@ $^
diff --git a/manual/signal.texi b/manual/signal.texi
index 1a4f866876..767ddabb41 100644
--- a/manual/signal.texi
+++ b/manual/signal.texi
@@ -1040,6 +1040,18 @@ a handler for @code{SIGKILL} or @code{SIGSTOP}.
 @end table
 @end deftypefun
 
+@strong{Compatibility Note:} A problem when working with the
+@code{signal} function is that it has a different semantic on BSD and
+SVID system.  The difference is that on SVID systems the signal handler
+is deinstalled after an signal was delivered.  On BSD systems the
+handler must be explicitly deinstalled.  In the GNU C Library we use the
+BSD version by default.  To use the SVID version you can either use the
+function @code{sysv_signal} (see below) or use the @code{_XOPEN_SOURCE}
+feature select macro (@pxref{Feature Test Macros})  Generally it should
+be avoided to use this functions due to the compatibility problems.  It
+is better to use @code{sigaction} if it is available since the results
+are much more reliable.
+
 Here is a simple example of setting up a handler to delete temporary
 files when certain fatal signals happen:
 
@@ -1080,6 +1092,18 @@ example because these are designed to provide information for debugging
 (a core dump), and the temporary files may give useful information.
 
 @comment signal.h
+@comment GNU
+@deftypefun sighandler_t sysv_signal (int @var{signum}, sighandler_t @var{action})
+The @code{sysv_signal} implements the behaviour of the standard
+@code{signal} function as found on SVID systems.  The difference to BSD
+systems is that the handler is deinstalled after a delivery of a signal.
+
+@strong{Compatibility Note:} As said above for @code{signal}, this
+function should be avoided when possible.  @code{sigaction} is the
+preferred method.
+@end deftypefun
+
+@comment signal.h
 @comment SVID
 @deftypefun sighandler_t ssignal (int @var{signum}, sighandler_t @var{action})
 The @code{ssignal} function does the same thing as @code{signal}; it is
diff --git a/manual/xtract-typefun.awk b/manual/xtract-typefun.awk
new file mode 100644
index 0000000000..6450ac10eb
--- /dev/null
+++ b/manual/xtract-typefun.awk
@@ -0,0 +1,26 @@
+#! /usr/local/bin/gawk -f
+BEGIN {
+  last_node="";
+}
+
+/^@node/ {
+  last_node = gensub (/@node +([^@,]+).*/, "\\1", 1);
+}
+
+/^@deftypefun/ {
+  printf ("* %s: (libc)%s.\n",
+	  gensub (/@deftypefun +([^{ ]+|\{[^}]+\}) +([[:alpha:]_][[:alnum:]_]+).*/, "\\2", 1),
+    last_node);
+}
+
+/^@deftypevr/ {
+  printf ("* %s: (libc)%s.\n",
+	  gensub (/@deftypevr +([^{ ]+|\{[^}]+\}) +([^{ ]+|\{[^}]+\}) +([[:alpha:]_][[:alnum:]_]+).*/, "\\3", 1),
+    last_node);
+}
+
+/^@deftypefn/ {
+  printf ("* %s: (libc)%s.\n",
+	  gensub (/@deftypefn +([^{ ]+|\{[^}]+\}) +[^{ ]*(\{[^}]+\})? +([[:alpha:]_][[:alnum:]_]+).*/, "\\3", 1),
+    last_node);
+}
diff --git a/math/math.h b/math/math.h
index eb8a4f202d..dce06e798b 100644
--- a/math/math.h
+++ b/math/math.h
@@ -99,13 +99,17 @@ extern _LIB_VERSION_TYPE _LIB_VERSION;
 #endif
 
 
-#if defined __USE_SVID && !defined __cplusplus
+#ifdef __USE_SVID
 /* In SVID error handling, `matherr' is called with this description
    of the exceptional condition.
 
    We have a problem when using C++ since `exception' is reserved in
    C++.  */
+#ifdef __cplusplus
+struct __exception
+#else
 struct exception
+#endif
   {
     int type;
     char *name;
@@ -114,8 +118,13 @@ struct exception
     double retval;
   };
 
+#ifdef __cplusplus
+extern int __matherr __P ((struct __exception *));
+extern int matherr __P ((struct __exception *));
+#else
 extern int __matherr __P ((struct exception *));
 extern int matherr __P ((struct exception *));
+#endif
 
 #define X_TLOSS		1.41484755040568800000e+16
 
@@ -131,7 +140,7 @@ extern int matherr __P ((struct exception *));
 #define HUGE		FLT_MAX
 #include <float.h>		/* Defines FLT_MAX.  */
 
-#endif	/* SVID && !C++ */
+#endif	/* SVID */
 
 
 #ifdef __USE_BSD
@@ -164,7 +173,7 @@ extern int matherr __P ((struct exception *));
 
 
 /* Get machine-dependent inline versions (if there are any).  */
-#if defined (__NO_MATH_INLINES) || defined (__OPTIMIZE__)
+#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
 #include <__math.h>
 #endif
 
diff --git a/misc/getpass.c b/misc/getpass.c
index 74af9b5dc7..2caeb18668 100644
--- a/misc/getpass.c
+++ b/misc/getpass.c
@@ -59,9 +59,7 @@ getpass (prompt)
       /* Save the old one. */
       s = t;
       /* Tricky, tricky. */
-      t.c_lflag &= ~(ECHO|ISIG|ICANON);
-      t.c_cc[VTIME] = 0;
-      t.c_cc[VMIN] = 1;
+      t.c_lflag &= ~(ECHO|ISIG);
       tty_changed = (tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0);
     }
   else
diff --git a/sysdeps/generic/htonl.c b/sysdeps/generic/htonl.c
index 724ef54639..f1e077ae1a 100644
--- a/sysdeps/generic/htonl.c
+++ b/sysdeps/generic/htonl.c
@@ -1,28 +1,28 @@
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1993, 1997 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 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.
+   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.  */
+   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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
-#include <ansidecl.h>
 #include <netinet/in.h>
 
 #undef	htonl
 
-unsigned long int
-DEFUN(htonl, (x), unsigned long int x)
+u_int32_t
+htonl (x)
+     u_int32_t x;
 {
 #if BYTE_ORDER == LITTLE_ENDIAN
   x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
diff --git a/sysdeps/generic/htons.c b/sysdeps/generic/htons.c
index e3209f3e68..3aaf28551c 100644
--- a/sysdeps/generic/htons.c
+++ b/sysdeps/generic/htons.c
@@ -1,28 +1,28 @@
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1993, 1997 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 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.
+   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.  */
+   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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
-#include <ansidecl.h>
 #include <netinet/in.h>
 
 #undef	htons
 
-unsigned short int
-DEFUN(htons, (x), unsigned short int x)
+u_int16_t
+htons (x)
+     u_int16_t x;
 {
 #if BYTE_ORDER == LITTLE_ENDIAN
   x = (x << 8) | (x >> 8);
diff --git a/sysdeps/generic/netinet/in.h b/sysdeps/generic/netinet/in.h
index ad77c8be7d..5531fc2ece 100644
--- a/sysdeps/generic/netinet/in.h
+++ b/sysdeps/generic/netinet/in.h
@@ -190,12 +190,17 @@ struct ip_mreq
   struct in_addr imr_interface;	/* local IP address of interface */
 };
 
-/* Functions to convert between host and network byte order.  */
+/* Functions to convert between host and network byte order.
 
-extern unsigned long int ntohl __P ((unsigned long int));
-extern unsigned short int ntohs __P ((unsigned short int));
-extern unsigned long int htonl __P ((unsigned long int));
-extern unsigned short int htons __P ((unsigned short int));
+   Please note that these functions normally take `unsigned long int' or
+   `unsigned short int' values as arguments and also return them.  But
+   this was a short-sighted decision since on different systems the types
+   may have different representations but the values are always the same.  */
+
+extern u_int32_t ntohl __P ((u_int32_t __netlong));
+extern u_int16_t ntohs __P ((u_int16_t __netshort));
+extern u_int32_t htonl __P ((u_int32_t __hostlong));
+extern u_int16_t htons __P ((u_int16_t __hostshort));
 
 #include <endian.h>
 
diff --git a/sysdeps/generic/ntohl.c b/sysdeps/generic/ntohl.c
index 389cc9ffc0..0cb83c5aa4 100644
--- a/sysdeps/generic/ntohl.c
+++ b/sysdeps/generic/ntohl.c
@@ -1,28 +1,28 @@
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1993, 1997 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 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.
+   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.  */
+   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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
-#include <ansidecl.h>
 #include <netinet/in.h>
 
 #undef	ntohl
 
-unsigned long int
-DEFUN(ntohl, (x), unsigned long int x)
+u_int32_t
+ntohl (x)
+     u_int32_t x;
 {
 #if BYTE_ORDER == LITTLE_ENDIAN
   x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
diff --git a/sysdeps/generic/ntohs.c b/sysdeps/generic/ntohs.c
index 1ac462a6d2..f4f37eec93 100644
--- a/sysdeps/generic/ntohs.c
+++ b/sysdeps/generic/ntohs.c
@@ -1,28 +1,28 @@
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1993, 1997 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 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.
+   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.  */
+   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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
-#include <ansidecl.h>
 #include <netinet/in.h>
 
 #undef	ntohs
 
-unsigned short int
-DEFUN(ntohs, (x), unsigned short int x)
+u_int16_t
+ntohs (x)
+     u_int16_t x;
 {
 #if BYTE_ORDER == LITTLE_ENDIAN
   x = (x << 8) | (x >> 8);
diff --git a/sysdeps/libm-i387/e_acoshf.S b/sysdeps/libm-i387/e_acoshf.S
index a4f50ba7ac..8aa78957e2 100644
--- a/sysdeps/libm-i387/e_acoshf.S
+++ b/sysdeps/libm-i387/e_acoshf.S
@@ -1,5 +1,5 @@
 /* ix87 specific implementation of arcsinh.
-   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -42,7 +42,7 @@ limit:	.double 0.29
 
 	.text
 ENTRY(__ieee754_acoshf)
-	movl	8(%esp), %ecx
+	movl	4(%esp), %ecx
 	cmpl	$0x3f800000, %ecx
 	jl	5f			// < 1 => invalid
 	fldln2				// log(2)
diff --git a/sysdeps/libm-i387/e_acoshl.S b/sysdeps/libm-i387/e_acoshl.S
index b0fa45c44e..0c81daaebe 100644
--- a/sysdeps/libm-i387/e_acoshl.S
+++ b/sysdeps/libm-i387/e_acoshl.S
@@ -1,5 +1,5 @@
 /* ix87 specific implementation of arcsinh.
-   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -49,6 +49,7 @@ limit:	.double 0.29
 	.text
 ENTRY(__ieee754_acoshl)
 	movl	12(%esp), %ecx
+	andl	$0xffff, %ecx
 	cmpl	$0x3fff, %ecx
 	jl	5f			// < 1 => invalid
 	fldln2				// log(2)
diff --git a/sysdeps/mach/hurd/fcntlbits.h b/sysdeps/mach/hurd/fcntlbits.h
index efa7069107..9906c97eb3 100644
--- a/sysdeps/mach/hurd/fcntlbits.h
+++ b/sysdeps/mach/hurd/fcntlbits.h
@@ -1,21 +1,21 @@
 /* O_*, F_*, FD_* bit values for GNU.
-Copyright (C) 1993, 1994, 1996, 1997 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.  */
+   Copyright (C) 1993, 1994, 1996, 1997 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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #ifndef	_FCNTLBITS_H
 
diff --git a/sysdeps/sparc/Dist b/sysdeps/sparc/Dist
index ef6c44f78e..55f26143fd 100644
--- a/sysdeps/sparc/Dist
+++ b/sysdeps/sparc/Dist
@@ -1,4 +1,5 @@
 DEFS.h
+elf/DEFS.h
 dotmul.S umul.S
 divrem.m4 sdiv.S udiv.S rem.S urem.S
 alloca.S
diff --git a/sysdeps/sparc/bsd-_setjmp.S b/sysdeps/sparc/bsd-_setjmp.S
index 5b685d5496..522fe0e3a1 100644
--- a/sysdeps/sparc/bsd-_setjmp.S
+++ b/sysdeps/sparc/bsd-_setjmp.S
@@ -1,26 +1,43 @@
 /* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'.  Sparc version.
-Copyright (C) 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1994, 1997 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 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.
+   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.  */
+   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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #include <sysdep.h>
 
-ENTRY (setjmp)
+ENTRY (_setjmp)
+#ifdef PIC
+1:
+	jmpl  2f,%o1
+	nop
+2:
+	sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)),%l7
+	or    %l7,%lo(_GLOBAL_OFFSET_TABLE_-(1b-.)),%l7
+	add   %l7,%o1,%l7
+	sethi %hi(C_SYMBOL_NAME (__sigsetjmp)),%g1
+	or    %g1,%lo(C_SYMBOL_NAME (__sigsetjmp)),%g1
+	ld    [%l7+%g1],%g1
+	ld    [%g1],%g1
+	jmpl  %g1,%g0
+	mov   %g0,%o1           /* Pass second argument of zero */
+#else
+
 	sethi %hi(C_SYMBOL_NAME (__sigsetjmp)), %g1
 	or %lo(C_SYMBOL_NAME (__sigsetjmp)), %g1, %g1
 	jmp %g1
 	mov %g0, %o1		/* Pass second argument of zero.  */
+#endif
diff --git a/sysdeps/sparc/bsd-setjmp.S b/sysdeps/sparc/bsd-setjmp.S
index b0a6326a2c..09aee661da 100644
--- a/sysdeps/sparc/bsd-setjmp.S
+++ b/sysdeps/sparc/bsd-setjmp.S
@@ -1,26 +1,42 @@
 /* BSD `setjmp' entry point to `sigsetjmp (..., 1)'.  Sparc version.
-Copyright (C) 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1994, 1997 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 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.
+   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.  */
+   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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #include <sysdep.h>
 
 ENTRY (setjmp)
+#ifdef PIC
+1:
+	jmpl  2f,%o1
+	nop
+2:
+	sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)),%l7
+	or    %l7,%lo(_GLOBAL_OFFSET_TABLE_-(1b-.)),%l7
+	add   %l7,%o1,%l7
+	sethi %hi(C_SYMBOL_NAME (__sigsetjmp)),%g1
+	or    %g1,%lo(C_SYMBOL_NAME (__sigsetjmp)),%g1
+	ld    [%l7+%g1],%g1
+	ld    [%g1],%g1
+	jmpl  %g1,%g0
+	mov   1,%o1
+#else
 	sethi %hi(C_SYMBOL_NAME (__sigsetjmp)), %g1
 	or %lo(C_SYMBOL_NAME (__sigsetjmp)), %g1, %g1
 	jmp %g1
 	mov 1, %o1		/* Pass second argument of one.  */
+#endif
diff --git a/sysdeps/sparc/divrem.m4 b/sysdeps/sparc/divrem.m4
index bde8a21e29..cada804706 100644
--- a/sysdeps/sparc/divrem.m4
+++ b/sysdeps/sparc/divrem.m4
@@ -83,11 +83,15 @@ L.$1.eval(2**N+$2):
 	ifelse($1, 1, `9:')')dnl
 
 #include "DEFS.h"
+#ifdef __linux__
+#include <asm/traps.h>
+#else
 #ifdef __svr4__
 #include <sys/trap.h>
 #else
 #include <machine/trap.h>
 #endif
+#endif
 
 FUNC(NAME)
 ifelse(S, `true',
diff --git a/sysdeps/sparc/dl-machine.h b/sysdeps/sparc/dl-machine.h
index ad288e15b2..5240b0cf81 100644
--- a/sysdeps/sparc/dl-machine.h
+++ b/sysdeps/sparc/dl-machine.h
@@ -1,5 +1,5 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  SPARC version.
-   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997 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,13 +36,7 @@
 static inline int
 elf_machine_matches_host (Elf32_Half e_machine)
 {
-  switch (e_machine)
-    {
-    case EM_SPARC:
-      return 1;
-    default:
-      return 0;
-    }
+  return e_machine == EM_SPARC;
 }
 
 
@@ -62,28 +56,50 @@ static inline Elf32_Addr
 elf_machine_load_address (void)
 {
   Elf32_Addr addr;
-???
+
+  asm (
+       "add   %%fp,0x44,%%o2\n\t"	/* o2 = point to argc */
+       "ld    [%%o2 - 4],%%o0\n\t"	/* o0 = load argc     */
+       "sll   %%o0, 2, %%o0\n\t"	/* o0 = argc * sizeof (int) */
+       "add   %%o2,%%o0,%%o2\n\t"	/* o2 = skip over argv */
+       "add   %%o2,4,%%o2\n\t"		/* skip over null after argv */
+
+       /* Now %o2 is pointing to env, skip over that as well.  */
+       "1:\n\t"
+       "ld    [%%o2],%%o0\n\t"
+        "cmp   %%o0,0\n\t"
+       "bnz   1b\n\t"
+       "add   %%o2,4,%%o2\n\t"
+
+       /* Note that above, we want to advance the NULL after envp so
+	  we always add 4.  */
+
+       /* Now, search for the AT_BASE property.  */
+       "2:\n\t"
+       "ld   [%%o2],%%o0\n\t"
+       "cmp  %%o0,0\n\t"
+       "be,a 3f\n\t"
+       "or   %%g0,%%g0,%0\n\t"
+       "cmp  %%o0,7\n\t"	/* AT_BASE = 7 */
+       "be,a 3f\n\t"
+       "ld   [%%o2+4],%0\n\t"
+       "b    2b\n\t"
+       "add  %%o2,8,%%o2\n\t"
+       /* At this point %0 has the load address for the interpreter */
+       "3:\n\t"
+       : "=r" (addr)
+       : /* no inputs */
+       : "o0", "o2");
   return addr;
 }
 
-/* The `subl' insn above will contain an R_68K_RELATIVE relocation
-   entry intended to insert the run-time address of the label `here'.
-   This will be the first relocation in the text of the dynamic
-   linker; we skip it to avoid trying to modify read-only text in this
-   early stage.  */
-#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) \
-  ((dynamic_info)[DT_RELA]->d_un.d_ptr += sizeof (Elf32_Rela), \
-   (dynamic_info)[DT_RELASZ]->d_un.d_val -= sizeof (Elf32_Rela))
-
+#ifdef RESOLVE
 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
    MAP is the object containing the reloc.  */
 
 static inline void
 elf_machine_rela (struct link_map *map,
-		  const Elf32_Rela *reloc, const Elf32_Sym *sym,
-		  Elf32_Addr (*resolve) (const Elf32_Sym **ref,
-					 Elf32_Addr reloc_addr,
-					 int noplt))
+		  const Elf32_Rela *reloc, const Elf32_Sym *sym)
 {
   Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
   Elf32_Addr loadbase;
@@ -91,21 +107,17 @@ elf_machine_rela (struct link_map *map,
   switch (ELF32_R_TYPE (reloc->r_info))
     {
     case R_SPARC_COPY:
-      loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0);
+      loadbase = RESOLVE (&sym, DL_LOOKUP_NOEXEC);
       memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size);
       break;
     case R_SPARC_GLOB_DAT:
     case R_SPARC_32:
-      loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0) :
-		  /* RESOLVE is null during bootstrap relocation.  */
-		  map->l_addr);
+      loadbase = RESOLVE (&sym, 0);
       *reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
 		     + reloc->r_addend);
       break;
     case R_SPARC_JMP_SLOT:
-      loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 1) :
-		  /* RESOLVE is null during bootstrap relocation.  */
-		  map->l_addr);
+      loadbase = RESOLVE (&sym, DL_LOOKUP_NOPLT);
       {
 	Elf32_Addr value = ((sym ? (loadbase + sym->st_value) : 0)
 			    + reloc->r_addend);
@@ -114,25 +126,20 @@ elf_machine_rela (struct link_map *map,
       }
       break;
     case R_SPARC_8:
-      loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0);
+      loadbase = RESOLVE (&sym, 0);
       *(char *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
 			      + reloc->r_addend);
       break;
     case R_SPARC_16:
-      loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0);
+      loadbase = RESOLVE (&sym, 0);
       *(short *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
 			       + reloc->r_addend);
       break;
-    case R_SPARC_32:
-      loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0) :
-		  /* RESOLVE is null during bootstrap relocation.  */
-		  map->l_addr);
-      break;
     case R_SPARC_RELATIVE:
-      *reloc_addr = map->l_addr + reloc->r_addend;
+      *reloc_addr += map->l_addr + reloc->r_addend;
       break;
     case R_SPARC_DISP8:
-      loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0);
+      loadbase = RESOLVE (&sym, 0);
       *(char *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
 			      + reloc->r_addend
 			      - (Elf32_Addr) reloc_addr);
@@ -144,11 +151,31 @@ elf_machine_rela (struct link_map *map,
 			       - (Elf32_Addr) reloc_addr);
       break;
     case R_SPARC_DISP32:
-      loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0);
+      loadbase = RESOLVE (&sym, 0);
       *reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
 		     + reloc->r_addend
 		     - (Elf32_Addr) reloc_addr);
       break;
+      case R_SPARC_LO10:
+	{
+	  unsigned int saddr;
+
+	  loadbase = RESOLVE (&sym, 0);
+	  saddr = (loadbase ? loadbase : map->l_addr) + reloc->r_addend;
+
+	  *reloc_addr = (*reloc_addr & ~0x3ff) | (saddr & 0x3ff);
+	}
+       break;
+    case R_SPARC_HI22:
+      {
+	unsigned int saddr;
+
+	loadbase = RESOLVE (&sym, 0);
+	saddr = (loadbase ? loadbase : map->l_addr) + reloc->r_addend;
+
+	*reloc_addr = (*reloc_addr & 0xffc00000)|(saddr >> 10);
+      }
+      break;
     case R_SPARC_NONE:		/* Alright, Wilbur.  */
       break;
     default:
@@ -172,6 +199,10 @@ elf_machine_lazy_rel (struct link_map *map, const Elf32_Rela *reloc)
     }
 }
 
+#define ELF_ADJUST_ARG(arg) __asm__("\tadd %%fp,64,%0\n" : "=r" (arg))
+
+#endif	/* RESOLV */
+
 /* Nonzero iff TYPE describes relocation of a PLT entry, so
    PLT entries should not be allowed to define the value.  */
 #define elf_machine_pltrel_p(type) ((type) == R_SPARC_JMP_SLOT)
@@ -213,26 +244,27 @@ elf_machine_runtime_setup (struct link_map *l, int lazy)
       plt[1] = OPCODE_CALL | (((Elf32_Addr) &_dl_runtime_resolve -
 			       (Elf32_Addr) &plt[1]) >> 2);
       plt[2] = OPCODE_NOP;	/* Fill call delay slot.  */
-      plt[3] = l;
+      plt[3] = (Elf32_Addr *) l;
     }
 
   /* This code is used in dl-runtime.c to call the `fixup' function
      and then redirect to the address it returns.  */
 #define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
-| Trampoline for _dl_runtime_resolver
+# Trampoline for _dl_runtime_resolver
 	.globl _dl_runtime_resolve
 	.type _dl_runtime_resolve, @function
 _dl_runtime_resolve:
-	| Pass two args to fixup: the PLT address computed from the PC saved
-	| in the PLT's call insn, and the reloc offset passed in %g1.
-	ld [%o7 + 8], %o1	| Second arg, loaded from PLTPC[2].
-	call fixup
-	shrl %g1, 22, %o0	| First arg, set in delay slot of call.
-	| Jump to the real function.
-	jmpl %o0, %g0
-	| In the delay slot of that jump, restore the register window
-	| saved by the first insn of the PLT.
-	restore
+	#call  %g0
+	# Pass two args to fixup: the PLT address computed from the PC saved
+	# in the PLT's call insn, and the reloc offset passed in %g1.
+	#ld [%o7 + 8], %o1      | Second arg, loaded from PLTPC[2].
+	#call fixup
+	#shrl %g1, 22, %o0      | First arg, set in delay slot of call.
+	# Jump to the real function.
+	#jmpl %o0, %g0
+	# In the delay slot of that jump, restore the register window
+	# saved by the first insn of the PLT.
+	#restore
 	.size _dl_runtime_resolve, . - _dl_runtime_resolve
 ");
 /* The PLT uses Elf32_Rela relocs.  */
@@ -248,4 +280,13 @@ _dl_runtime_resolve:
    The C function `_dl_start' is the real entry point;
    its return value is the user program's entry point.  */
 
-#define RTLD_START asm (???)
+#define RTLD_START __asm__ ( \
+".text\n\
+ .globl _start\n\
+ .type _start,@function\n\
+_start:\n\
+  call _dl_start\n\
+  nop\n\
+  call %o0\n\
+  nop\n\
+");
diff --git a/sysdeps/sparc/elf/DEFS.h b/sysdeps/sparc/elf/DEFS.h
new file mode 100644
index 0000000000..84f078ae40
--- /dev/null
+++ b/sysdeps/sparc/elf/DEFS.h
@@ -0,0 +1,5 @@
+#define	FUNC(name)		\
+	.global name;		\
+	.type name,@function;	\
+	.align 4;		\
+	name:
diff --git a/sysdeps/sparc/elf/start.S b/sysdeps/sparc/elf/start.S
index 6dae08bafa..db407d7bae 100644
--- a/sysdeps/sparc/elf/start.S
+++ b/sysdeps/sparc/elf/start.S
@@ -1,21 +1,21 @@
 /* Startup code compliant to the ELF SPARC ABI.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1996, 1997 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 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.
+   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.  */
+   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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 /* This is the canonical entry point, usually the first thing in the text
    segment.  The SVR4/SPARC ABI (NOTE: I don't actually have it) says that
@@ -82,7 +82,7 @@ nofini:
 	sll ENVP, 2, ENVP
 	add ARGV, ENVP, ENVP
 	/* Store ENVP in the global variable `_environ'.  */
-	st [TMP + %lo(_environ)], ENVP
+	ld [TMP + %lo(_environ)], ENVP
 
 	/* Call `_init', which is the entry point to our own `.init'
 	   section; and register with `atexit' to have `exit' call
@@ -100,6 +100,7 @@ nofini:
 	mov ENVP, %o2
 
 	call exit		/* This should never return.  */
+	nop
 	unimp 0			/* Crash if somehow it does return.  */
 
 /* Define a symbol for the first piece of initialized data.  */
diff --git a/sysdeps/sparc/fpu_control.h b/sysdeps/sparc/fpu_control.h
index a8015abc29..cfd85844c3 100644
--- a/sysdeps/sparc/fpu_control.h
+++ b/sysdeps/sparc/fpu_control.h
@@ -53,13 +53,6 @@
 /* private namespace. It should only be used by crt0.o. */
 extern unsigned short __fpu_control;
 
-__BEGIN_DECLS
-
-/* called by crt0.o. It can be used to manipulate 387 control word. */
-extern void __setfpucw __P ((unsigned short));
-
-__END_DECLS
-
 /* Type of the control word.  */
 typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
 
diff --git a/sysdeps/sparc/rem.S b/sysdeps/sparc/rem.S
index 17662f7fd4..565fc0f678 100644
--- a/sysdeps/sparc/rem.S
+++ b/sysdeps/sparc/rem.S
@@ -38,11 +38,15 @@
 
 
 #include "DEFS.h"
+#ifdef __linux__
+#include <asm/traps.h>
+#else
 #ifdef __svr4__
 #include <sys/trap.h>
 #else
 #include <machine/trap.h>
 #endif
+#endif
 
 FUNC(.rem)
 	! compute sign of result; if neither is negative, no problem
diff --git a/sysdeps/sparc/sdiv.S b/sysdeps/sparc/sdiv.S
index dadbb36b0a..7397e5edb8 100644
--- a/sysdeps/sparc/sdiv.S
+++ b/sysdeps/sparc/sdiv.S
@@ -38,11 +38,15 @@
 
 
 #include "DEFS.h"
+#ifdef __linux__
+#include <asm/traps.h>
+#else
 #ifdef __svr4__
 #include <sys/trap.h>
 #else
 #include <machine/trap.h>
 #endif
+#endif
 
 FUNC(.div)
 	! compute sign of result; if neither is negative, no problem
diff --git a/sysdeps/sparc/setjmp.S b/sysdeps/sparc/setjmp.S
index db8a3c2916..d9599079c2 100644
--- a/sysdeps/sparc/setjmp.S
+++ b/sysdeps/sparc/setjmp.S
@@ -1,20 +1,20 @@
-/* Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1993, 1994, 1996, 1997 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 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.
+   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.  */
+   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., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #include <sysdep.h>
 
@@ -25,9 +25,25 @@ ENTRY (__sigsetjmp)
 	/* Save our SP and FP; in the delay slot of the jump, save our
 	   return PC.  Save the signal mask if requested with a tail-call
 	   for simplicity; it always returns zero.  */
+#ifdef PIC
+2:
+	jmpl 1f,%g2
+	nop
+1:
+	sethi %hi(_GLOBAL_OFFSET_TABLE_-(2b-.)),%l7
+	sethi %hi(C_SYMBOL_NAME (__sigjmp_save)), %g3
+	st    %sp, [%o0 + (JB_SP * 4)]
+	or    %l7,%lo(_GLOBAL_OFFSET_TABLE_-(2b-.)),%l7
+	or    %g3,%lo(C_SYMBOL_NAME (__sigjmp_save)), %g3
+	st    %fp, [%o0 + (JB_FP * 4)]
+	ld    [%l7+%g3],%g1
+	jmp   %g1
+	st   %o7, [%o0+(JB_PC*4)]
+#else
 	sethi %hi(C_SYMBOL_NAME (__sigjmp_save)), %g1
 	st %sp, [%o0 + (JB_SP*4)]
 	or %lo(C_SYMBOL_NAME (__sigjmp_save)), %g1, %g1
 	st %fp, [%o0 + (JB_FP*4)]
 	jmp %g1
 	 st %o7, [%o0 + (JB_PC*4)]
+#endif /* PIC */
diff --git a/sysdeps/sparc/udiv.S b/sysdeps/sparc/udiv.S
index 826d01183d..252afd0193 100644
--- a/sysdeps/sparc/udiv.S
+++ b/sysdeps/sparc/udiv.S
@@ -38,11 +38,15 @@
 
 
 #include "DEFS.h"
+#ifdef __linux__
+#include <asm/traps.h>
+#else
 #ifdef __svr4__
 #include <sys/trap.h>
 #else
 #include <machine/trap.h>
 #endif
+#endif
 
 FUNC(.udiv)
 
diff --git a/sysdeps/sparc/urem.S b/sysdeps/sparc/urem.S
index 9f64c8859e..99a5acf40a 100644
--- a/sysdeps/sparc/urem.S
+++ b/sysdeps/sparc/urem.S
@@ -38,11 +38,15 @@
 
 
 #include "DEFS.h"
+#ifdef __linux__
+#include <asm/traps.h>
+#else
 #ifdef __svr4__
 #include <sys/trap.h>
 #else
 #include <machine/trap.h>
 #endif
+#endif
 
 FUNC(.urem)
 
diff --git a/sysdeps/unix/sysv/linux/netinet/in.h b/sysdeps/unix/sysv/linux/netinet/in.h
index 53be934968..5b6cc78821 100644
--- a/sysdeps/unix/sysv/linux/netinet/in.h
+++ b/sysdeps/unix/sysv/linux/netinet/in.h
@@ -233,12 +233,17 @@ struct ip_mreq
     struct in_addr imr_interface;	/* local IP address of interface */
   };
 
-/* Functions to convert between host and network byte order.  */
+/* Functions to convert between host and network byte order.
 
-extern unsigned long int ntohl __P ((unsigned long int));
-extern unsigned short int ntohs __P ((unsigned short int));
-extern unsigned long int htonl __P ((unsigned long int));
-extern unsigned short int htons __P ((unsigned short int));
+   Please note that these functions normally take `unsigned long int' or
+   `unsigned short int' values as arguments and also return them.  But
+   this was a short-sighted decision since on different systems the types
+   may have different representations but the values are always the same.  */
+
+extern u_int32_t ntohl __P ((u_int32_t __netlong));
+extern u_int16_t ntohs __P ((u_int16_t __netshort));
+extern u_int32_t htonl __P ((u_int32_t __hostlong));
+extern u_int16_t htons __P ((u_int16_t __hostshort));
 
 #include <endian.h>
 
diff --git a/sysdeps/unix/sysv/linux/sparc/Makefile b/sysdeps/unix/sysv/linux/sparc/Makefile
index 629e6b37df..30ef946c19 100644
--- a/sysdeps/unix/sysv/linux/sparc/Makefile
+++ b/sysdeps/unix/sysv/linux/sparc/Makefile
@@ -1,3 +1,11 @@
 ifeq ($(subdir),signal)
 sysdep_routines += __sigtrampoline
 endif
+
+# When I get this to work, this is the right thing
+ifeq ($(subdir),elf)
+CFLAGS-rtld.c += -mv8
+#rtld-routines += dl-sysdepsparc
+endif   # elf
+
+asm-CPPFLAGS = -fPIC
diff --git a/sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S b/sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S
index 4fea850ee3..2dd13062fc 100644
--- a/sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S
+++ b/sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S
@@ -4,10 +4,10 @@
 /* Contributed by Miguel de Icaza (miguel@gnu.ai.mit.edu)       */
 /* Many thanks go to David Miller for explaining all this to me */
 /* miguel@nuclecu.unam.mx                                       */
-/* Sources:	 David Miller, 4.4BSD/SPARC code 	        */
+/* Sources:     David Miller, 4.4BSD/SPARC code                */
 
 #include <sysdep.h>
-
+#define __ASSEMBLY__
 /* For REGWIN_SZ */
 #include <asm/ptrace.h>
 #include <asm/psr.h>
@@ -18,13 +18,13 @@
 	.text
 
 ENTRY(____sparc_signal_trampoline)
-	.global SYMBOL_NAME(____sig_table)
+	.global C_SYMBOL_NAME(____sig_table)
 
 	/* Make room for 32 %f registers + %fsr
-         * this is 132 bytes + alignement = 136
-         * 96 is the C frame size
-         */
-	save  	%sp,-136-CCFSZ,%sp
+	 * this is 132 bytes + alignement = 136
+	 * 96 is the C frame size
+	 */
+	save    %sp,-136-CCFSZ,%sp
 
 	/* save regular registers */
 	mov	%g2,%l2
@@ -34,31 +34,31 @@ ENTRY(____sparc_signal_trampoline)
 	mov	%g6,%l6
 	mov	%g7,%l7
 
-	/* save fpu registers */
-	ld	[%fp+64+16+20],%l0      /* load the psr from sigcontext */
+       /* save fpu registers */
+	ld	[%fp+64+16+20],%l0	/* load the psr from sigcontext */
 	sethi	%hi(PSR_EF),%l1
-	andcc	%l0,%l1,%l0	        /* is floating point enabled?   */
+	andcc	%l0,%l1,%l0		/* is floating point enabled?   */
 	be	1f
 	rd	%y,%l1			/* save y anyways */
 
 	/* save fpu registers */
-	st      %fsr, [%sp + CCFSZ + 0]
-        std     %f0, [%sp + CCFSZ + 8]
-        std     %f2, [%sp + CCFSZ + 16]
-        std     %f4, [%sp + CCFSZ + 24]
-        std     %f6, [%sp + CCFSZ + 32]
-        std     %f8, [%sp + CCFSZ + 40]
-        std     %f10, [%sp + CCFSZ + 48]
-        std     %f12, [%sp + CCFSZ + 56]
-        std     %f14, [%sp + CCFSZ + 64]
-        std     %f16, [%sp + CCFSZ + 72]
-        std     %f18, [%sp + CCFSZ + 80]
-        std     %f20, [%sp + CCFSZ + 88]
-        std     %f22, [%sp + CCFSZ + 96]
-        std     %f24, [%sp + CCFSZ + 104]
-        std     %f26, [%sp + CCFSZ + 112]
-        std     %f28, [%sp + CCFSZ + 120]
-        std     %f30, [%sp + CCFSZ + 128]
+	st	%fsr, [%sp + CCFSZ + 0]
+	std	%f0, [%sp + CCFSZ + 8]
+	std	%f2, [%sp + CCFSZ + 16]
+	std	%f4, [%sp + CCFSZ + 24]
+	std	%f6, [%sp + CCFSZ + 32]
+	std	%f8, [%sp + CCFSZ + 40]
+	std	%f10, [%sp + CCFSZ + 48]
+	std	%f12, [%sp + CCFSZ + 56]
+	std	%f14, [%sp + CCFSZ + 64]
+	std	%f16, [%sp + CCFSZ + 72]
+	std	%f18, [%sp + CCFSZ + 80]
+	std	%f20, [%sp + CCFSZ + 88]
+	std	%f22, [%sp + CCFSZ + 96]
+	std	%f24, [%sp + CCFSZ + 104]
+	std	%f26, [%sp + CCFSZ + 112]
+	std	%f28, [%sp + CCFSZ + 120]
+	std	%f30, [%sp + CCFSZ + 128]
 
 1:
 	/* Load signal number */
@@ -69,7 +69,7 @@ ENTRY(____sparc_signal_trampoline)
 	/* Sanity check */
 	cmp	%o0,33
 	bl	1f
-	or	%g0,%g0,%g1	/*Call sys_setup */
+	or	%g0,%g0,%g1     /*Call sys_setup */
 	t	0x10
 1:
 #ifdef __PIC__
@@ -79,16 +79,16 @@ ___sxx:
 	call	___syy
 	nop
 ___syy:
-	sethi   %hi(_GLOBAL_OFFSET_TABLE_-(___sxx-.)),%o5
-	or      %o5,%lo(_GLOBAL_OFFSET_TABLE_-(___sxx-.)),%o5
+	sethi	%hi(_GLOBAL_OFFSET_TABLE_-(___sxx-.)),%o5
+	or	%o5,%lo(_GLOBAL_OFFSET_TABLE_-(___sxx-.)),%o5
 	add	%o7,%o5,%o5
 	/* restore return address */
 	mov	%o4,%o7
 	mov	%o5,%o4
 	/* o4 has the GOT pointer */
 #endif
-	sethi	%hi(SYMBOL_NAME(____sig_table)),%o5
-	or	%o5,%lo(SYMBOL_NAME(____sig_table)),%o5
+	sethi	%hi(C_SYMBOL_NAME(____sig_table)),%o5
+	or	%o5,%lo(C_SYMBOL_NAME(____sig_table)),%o5
 #ifdef __PIC__
 	add	%o5,%o4,%o4
 	ld	[%o4],%o5
@@ -97,9 +97,10 @@ ___syy:
 	add	%o5,%o4,%o4
 	ld	[%o4],%o4
 	ld	[%fp + REGWIN_SZ + 4],%o1         /* Load subcode */
-	ld      [%fp + REGWIN_SZ + 8],%o2         /* pointer to sigcontext */
+	ld	[%fp + REGWIN_SZ + 8],%o2         /* pointer to sigcontext */
 	call	%o4
-	ld      [%fp + REGWIN_SZ + 12],%o3        /* Address where signal occurred */
+	ld	[%fp + REGWIN_SZ + 12],%o3        /* Address where signal ocurre
+ */
 
 	/* handler returned, restore state */
 	tst	%l0
@@ -107,23 +108,23 @@ ___syy:
 	wr	%l1,%g0,%y
 
 	/* fpu restoration */
-	ld      [%sp + CCFSZ + 0], %fsr
-        ldd     [%sp + CCFSZ + 8], %f0
-        ldd     [%sp + CCFSZ + 16], %f2
-        ldd     [%sp + CCFSZ + 24], %f4
-        ldd     [%sp + CCFSZ + 32], %f6
-        ldd     [%sp + CCFSZ + 40], %f8
-        ldd     [%sp + CCFSZ + 48], %f10
-        ldd     [%sp + CCFSZ + 56], %f12
-        ldd     [%sp + CCFSZ + 64], %f14
-        ldd     [%sp + CCFSZ + 72], %f16
-        ldd     [%sp + CCFSZ + 80], %f18
-        ldd     [%sp + CCFSZ + 88], %f20
-        ldd     [%sp + CCFSZ + 96], %f22
-        ldd     [%sp + CCFSZ + 104], %f24
-        ldd     [%sp + CCFSZ + 112], %f26
-        ldd     [%sp + CCFSZ + 120], %f28
-        ldd     [%sp + CCFSZ + 128], %f30
+	ld	[%sp + CCFSZ + 0], %fsr
+	ldd	[%sp + CCFSZ + 8], %f0
+	ldd	[%sp + CCFSZ + 16], %f2
+	ldd	[%sp + CCFSZ + 24], %f4
+	ldd	[%sp + CCFSZ + 32], %f6
+	ldd	[%sp + CCFSZ + 40], %f8
+	ldd	[%sp + CCFSZ + 48], %f10
+	ldd	[%sp + CCFSZ + 56], %f12
+	ldd	[%sp + CCFSZ + 64], %f14
+	ldd	[%sp + CCFSZ + 72], %f16
+	ldd	[%sp + CCFSZ + 80], %f18
+	ldd	[%sp + CCFSZ + 88], %f20
+	ldd	[%sp + CCFSZ + 96], %f22
+	ldd	[%sp + CCFSZ + 104], %f24
+	ldd	[%sp + CCFSZ + 112], %f26
+	ldd	[%sp + CCFSZ + 120], %f28
+	ldd	[%sp + CCFSZ + 128], %f30
 
 1:
 	mov	%l2,%g2
@@ -133,10 +134,10 @@ ___syy:
 	mov	%l6,%g6
 	mov	%l7,%g7
 
-	/* call sigreturn */
-	restore	%g0,SYS_sigreturn,%g1 	 /* register back and set syscall */
+       /* call sigreturn */
+	restore	%g0,SYS_ify(sigreturn),%g1	/* register back and set syscal */
 	add	%sp,64+16,%o0
 	t	0x10
 	/* if we return, sysreturn failed */
-	mov	SYS_exit,%g1
+	mov	SYS_ify(exit),%g1
 	t	0x10
diff --git a/sysdeps/unix/sysv/linux/sparc/errno.c b/sysdeps/unix/sysv/linux/sparc/errno.c
new file mode 100644
index 0000000000..663ab33e93
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/errno.c
@@ -0,0 +1 @@
+itn errno;
diff --git a/sysdeps/unix/sysv/linux/sparc/profil-counter.h b/sysdeps/unix/sysv/linux/sparc/profil-counter.h
index 1998c34ed5..258df5ba93 100644
--- a/sysdeps/unix/sysv/linux/sparc/profil-counter.h
+++ b/sysdeps/unix/sysv/linux/sparc/profil-counter.h
@@ -22,14 +22,5 @@
 void
 profil_counter (int signo, __siginfo_t si)
 {
-  extern int __sparc_old_signals;
-
-  if (__sparc_old_signals)
-    {
-      struct sigcontext_struct *s = (void *) &si;
-
-      profil_count ((void *) s->sigc_pc);
-    }
-  else
-    profil_count ((void *) si.si_regs.pc);
+  profil_count ((void *) si.si_regs.pc);
 }
diff --git a/sysdeps/unix/sysv/linux/sparc/sigaction.c b/sysdeps/unix/sysv/linux/sparc/sigaction.c
index e7bda77de2..d39eb7cc76 100644
--- a/sysdeps/unix/sysv/linux/sparc/sigaction.c
+++ b/sysdeps/unix/sysv/linux/sparc/sigaction.c
@@ -22,6 +22,10 @@
 #include <sys/signal.h>
 #include <errno.h>
 
+/* Commented out while I figure out what the fuck goes on */
+long ____sig_table [NSIG];
+#if 0
+
 /* The kernel will deliver signals in the old way if the signal
    number is a positive number.  The kernel will deliver a signal
    with the new stack layout if the signal number is a negative number.
@@ -30,7 +34,6 @@
    using at runtime.  */
 
 extern void ____sparc_signal_trampoline (int);
-long ____sig_table [NSIG];
 
 int
 __trampoline_sigaction (int sig, struct sigaction *new, struct sigaction *old)
@@ -60,7 +63,7 @@ __trampoline_sigaction (int sig, struct sigaction *new, struct sigaction *old)
 	  "1:"
 	  : "=r" (ret), "=r" ((long int) sig), "=r" ((long int) new),
 	    "=r" ((long int) old)
-	  : "0" (SYS_sigaction), "1" (sig), "2" (new), "3" (old)
+	  : "0" (__NR_sigaction), "1" (sig), "2" (new), "3" (old)
 	  : "g1", "o0", "o1", "o2");
 
   if (ret >= 0)
@@ -79,9 +82,12 @@ __trampoline_sigaction (int sig, struct sigaction *new, struct sigaction *old)
   __set_errno (-ret);
   return -1;
 }
+#else
+#    define __new_sigaction __sigaction
+#endif
 
 int
-__new_sigaction (int sig, struct sigaction *new, struct sigaction *old)
+__new_sigaction (int sig, __const struct sigaction *new, struct sigaction *old)
 {
   int ret;
 
@@ -98,7 +104,7 @@ __new_sigaction (int sig, struct sigaction *new, struct sigaction *old)
 	  "1:"
 	  : "=r" (ret), "=r" ((long int) sig), "=r" ((long int) new),
 	    "=r" ((long int) old)
-	  : "0" (SYS_sigaction), "1" (sig), "2" (new), "3" (old)
+	  : "0" (__NR_sigaction), "1" (sig), "2" (new), "3" (old)
 	  : "g1", "o0", "o1", "o2");
   if (ret >= 0)
     return 0;
@@ -106,10 +112,11 @@ __new_sigaction (int sig, struct sigaction *new, struct sigaction *old)
   return -1;
 }
 
+#if 0
 int
-__sigaction (int sig, struct sigaction *new, struct sigaction *old)
+__sigaction (int sig, __const struct sigaction *new, struct sigaction *old)
 {
-  static (*sigact_routine) (int, struct sigaction *, struct sigaction *);
+  static (*sigact_routine) (int, __const struct sigaction *, struct sigaction *);
   int ret;
   struct sigaction sa;
 
@@ -124,4 +131,6 @@ __sigaction (int sig, struct sigaction *new, struct sigaction *old)
 
   return __sigaction (sig, new, old);
 }
+#endif
+
 weak_alias (__sigaction, sigaction);
diff --git a/sysdeps/unix/sysv/linux/sparc/syscall.S b/sysdeps/unix/sysv/linux/sparc/syscall.S
index 4166e4231b..3921ca52dc 100644
--- a/sysdeps/unix/sysv/linux/sparc/syscall.S
+++ b/sysdeps/unix/sysv/linux/sparc/syscall.S
@@ -16,15 +16,26 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#define DONT_LOAD_G1
 #include <sysdep.h>
-ENTRY (__libc_syscall)
+	.text
+ENTRY (syscall)
 	or	%o0,%g0,%g1
 	or	%o1,%g0,%o0
 	or	%o2,%g0,%o1
 	or	%o3,%g0,%o2
 	or	%o4,%g0,%o3
 	or	%o5,%g0,%o4
-PSEUDO_NOENT(__libc_syscall, syscall, 5)
+	ta	0x10
+	bcc	1f
+	nop
+	save %sp, -96, %sp
+	call __errno_location
+	nop
+	st %i0,[%o0]
+	restore
+	retl
+	mov -1, %o0
+1:
 	ret
-SYSCALL__POST(syscall,5)
+
+PSEUDO_END (syscall)
diff --git a/sysdeps/unix/sysv/linux/sparc/syscalls.list b/sysdeps/unix/sysv/linux/sparc/syscalls.list
new file mode 100644
index 0000000000..7883d70719
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/syscalls.list
@@ -0,0 +1,3 @@
+# File name	Caller	Syscall name	# args	Strong name	Weak names
+
+s_llseek	llseek	_llseek		5	__sys_llseek
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.S b/sysdeps/unix/sysv/linux/sparc/sysdep.S
new file mode 100644
index 0000000000..7e9023901b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.S
@@ -0,0 +1,3 @@
+/* Define errno */
+
+	.common errno,4,4
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 0251a1f014..5ae440152b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -20,6 +20,11 @@
 #ifndef _LINUX_SPARC_SYSDEP_H
 #define _LINUX_SPARC_SYSDEP_H 1
 
+/* Kernel headers use __ASSEMBLY__ */
+#ifdef ASSEMBLER
+#define __ASSEMBLY__
+#endif
+
 #include <sysdeps/unix/sparc/sysdep.h>
 
 #undef SYS_ify
@@ -30,12 +35,34 @@
 #ifdef DONT_LOAD_G1
 # define LOADSYSCALL(x)
 #else
-# define LOADSYSCALL(x) mov SYS_##n, %g1
+# define LOADSYSCALL(x) mov __NR_##x, %g1
 #endif
 
-/* Linux/SPARC uses a different trap number and uses __errno_location always */
+/* Linux/SPARC uses a different trap number */
 #undef PSEUDO
 
+#ifdef PIC
+#define SYSCALL_ERROR_HANDLER \
+	.global C_SYMBOL_NAME(__errno_location);\
+        .type   C_SYMBOL_NAME(__errno_location),@function;\
+	save   %sp,-96,%sp;\
+	call   __errno_location;\
+	nop;\
+	st %i0,[%o0];\
+	restore;\
+	retl;\
+	mov -1,%o0;
+#else
+#define SYSCALL_ERROR_HANDLER \
+	save %sp,-96,%sp;						      \
+	call __errno_location;						      \
+	nop;								      \
+	st %i0,[%o0];							      \
+	restore;							      \
+	retl;								      \
+	mov -1,%o0;
+#endif   /* PIC */
+
 #define PSEUDO(name, syscall_name, args) \
 	.text;								      \
 	ENTRY(name);							      \
@@ -43,14 +70,8 @@
 	ta 0x10;							      \
 	bcc,a 1f;							      \
 	nop;								      \
-	save %sp,96,%sp;						      \
-	call __errno_location;						      \
-	nop;								      \
-	st %i0,[%o0];							      \
-	restore;							      \
-	retl;								      \
-	mov -1,%o0;							      \
-1:
+	SYSCALL_ERROR_HANDLER;						      \
+1:;
 
 #endif	/* ASSEMBLER */
 
diff --git a/time/Makefile b/time/Makefile
index fb9ef32535..0798e0838e 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -106,12 +106,12 @@ $(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
 	 echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))'		    ;\
 	 echo 'ifdef $*-zones'						    ;\
 	 if test x$(findstring $*, $(tzlinks)) != x; then		     \
-	   echo '$$(addprefix $$(inst_datadir)/zone%/right/,$$($*-zones)) \';\
-	   echo '$$(addprefix $$(inst_datadir)/zone%/posix/,$$($*-zones)) \';\
-	   echo '$$(addprefix $$(inst_datadir)/zone%/,$$($*-zones)): \'	    ;\
-	   echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_datadir)/zone%/right/,$$($$t-zones))) \' ;\
-	   echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_datadir)/zone%/posix/,$$($$t-zones))) \' ;\
-	   echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_datadir)/zone%/,$$($$t-zones)))' ;\
+	   echo '$$(addprefix $$(inst_zonedir)/right/,$$($*-zones)) \';\
+	   echo '$$(addprefix $$(inst_zonedir)/posix/,$$($*-zones)) \';\
+	   echo '$$(addprefix $$(inst_zonedir)/,$$($*-zones)): \'	    ;\
+	   echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/right/,$$($$t-zones))) \' ;\
+	   echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/posix/,$$($$t-zones))) \' ;\
+	   echo '$$(foreach t,$$(tzbases),$$(addprefix $$(inst_zonedir)/,$$($$t-zones)))' ;\
 	 fi								    ;\
 	 echo '$$(addprefix $$(inst_datadir)/zone%/right/,$$($*-zones)): \' ;\
 	 echo '$< $$(objpfx)zic leapseconds yearistype'			    ;\