summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/alpha/dl-machine.h42
-rw-r--r--sysdeps/generic/a.out.h339
-rw-r--r--sysdeps/i386/dl-machine.h39
-rw-r--r--sysdeps/m68k/dl-machine.h39
-rw-r--r--sysdeps/mach/hurd/libc-ldscript3
-rw-r--r--sysdeps/mach/hurd/libc_p-ldscript3
-rw-r--r--sysdeps/mips/dl-machine.h49
-rw-r--r--sysdeps/posix/getcwd.c41
-rw-r--r--sysdeps/posix/ttyname.c30
-rw-r--r--sysdeps/posix/ttyname_r.c30
-rw-r--r--sysdeps/sparc/dl-machine.h39
-rw-r--r--sysdeps/stub/dl-machine.h36
-rw-r--r--sysdeps/unix/alpha/sysdep.S40
-rw-r--r--sysdeps/unix/readdir_r.c32
-rw-r--r--sysdeps/unix/sysv/linux/a.out.h1
15 files changed, 553 insertions, 210 deletions
diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h
index 415549d205..1c71ec8ab2 100644
--- a/sysdeps/alpha/dl-machine.h
+++ b/sysdeps/alpha/dl-machine.h
@@ -1,22 +1,22 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  Alpha version.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Contributed by Richard Henderson <rth@tamu.edu>.
+   Copyright (C) 1996 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Richard Henderson <rth@tamu.edu>.
 
-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 was written in the absence of an ABI -- don't expect
    it to remain unchanged.  */
@@ -37,13 +37,13 @@ elf_machine_matches_host (Elf64_Word e_machine)
   return e_machine == EM_ALPHA;
 }
 
-/* Return the run-time address of the _GLOBAL_OFFSET_TABLE_.
-   Must be inlined in a function which uses global data.  */
-static inline Elf64_Addr *
-elf_machine_got (void)
+/* Return the link-time address of _DYNAMIC.  The multiple-got-capable
+   linker no longer allocates the first .got entry for this.  But not to
+   worry, no special tricks are needed.  */
+static inline Elf64_Addr
+elf_machine_dynamic (void)
 {
-  register Elf64_Addr gp __asm__("$29");
-  return (Elf64_Addr *)(gp - 0x8000);
+  return (Elf64_Addr) &_DYNAMIC;
 }
 
 /* Return the run-time load address of the shared object.  */
diff --git a/sysdeps/generic/a.out.h b/sysdeps/generic/a.out.h
new file mode 100644
index 0000000000..2c13762703
--- /dev/null
+++ b/sysdeps/generic/a.out.h
@@ -0,0 +1,339 @@
+#ifndef __A_OUT_GNU_H__
+#define __A_OUT_GNU_H__
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#define __GNU_EXEC_MACROS__
+
+#ifndef __STRUCT_EXEC_OVERRIDE__
+
+struct exec
+{
+  unsigned long a_info;		/* Use macros N_MAGIC, etc for access */
+  unsigned a_text;		/* size of text, in bytes */
+  unsigned a_data;		/* size of data, in bytes */
+  unsigned a_bss;		/* size of uninitialized data area, in bytes */
+  unsigned a_syms;		/* length of symbol table data, in bytes */
+  unsigned a_entry;		/* start address */
+  unsigned a_trsize;		/* size of reloc info for text, in bytes */
+  unsigned a_drsize;		/* size of reloc info for data, in bytes */
+
+#if defined (sequent) && defined (i386)
+  struct gdtbl
+    {				/* Global Descriptor Table */
+      unsigned g_code[2];
+      unsigned g_data[2];
+      unsigned g_desc[2];
+    } a_gdtbl;
+   unsigned a_shdata;		/* size of initialized shared data */
+   unsigned a_shbss;		/* size of uninitialized shared data */
+   unsigned a_shdrsize;		/* size of shared data relocation */
+   unsigned a_bootstrap[11];	/* bootstrap for standalone */
+   unsigned a_reserved[3];	/* reserved for future use */
+   unsigned a_version;		/* object version */
+#endif /* Sequent Symmetry, Dynix 3.x */
+};
+
+#endif /* __STRUCT_EXEC_OVERRIDE__ */
+
+/* these go in the N_MACHTYPE field */
+enum machine_type {
+#if defined (M_OLDSUN2)
+  M__OLDSUN2 = M_OLDSUN2,
+#else
+  M_OLDSUN2 = 0,
+#endif
+#if defined (M_68010)
+  M__68010 = M_68010,
+#else
+  M_68010 = 1,
+#endif
+#if defined (M_68020)
+  M__68020 = M_68020,
+#else
+  M_68020 = 2,
+#endif
+#if defined (M_SPARC)
+  M__SPARC = M_SPARC,
+#else
+  M_SPARC = 3,
+#endif
+  /* skip a bunch so we don't run into any of sun's numbers */
+  M_386 = 100
+};
+
+#if defined (sequent) && defined (i386)
+
+/* Dynix 3 wants the magic number to be the whole first longword.  */
+
+#define N_MAGIC(exec)		((exec).a_info)
+#define N_MACHTYPE(exec)	0
+#define N_FLAGS(exec)		0
+#define N_SET_INFO(exec, magic, type, flags) N_SET_MAGIC ((exec), (magic))
+#define N_SET_MAGIC(exec, magic)	((exec).a_info = (magic))
+#define N_SET_MACHTYPE(exec, machtype)	((void) 0)
+#define N_SET_FLAGS(exec, flags)	((void) 0)
+#define	OMAGIC		0x12eb	/* impure format - for .o's */
+#define	ZMAGIC		0x22eb	/* demand load format - zero at zero */
+#define NMAGIC		you lose /* syntax error -- no pure format */
+#define N_BADMAG(x)	(N_MAGIC(x) != OMAGIC && N_MAGIC(x) != ZMAGIC)
+#define N_ADDRADJ(x)	(N_MAGIC(x) == ZMAGIC ? SEGMENT_SIZE : 0)
+#define N_DATOFF(x)	(N_TXTOFF(x) + (x).a_text - N_ADDRADJ(x))
+#define N_TRELOFF(x)	(N_DATOFF(x) + (x).a_data + (x).a_shdata)
+#define N_SYMOFF(x)	(N_DRELOFF(x) + (x).a_drsize + (x).a_shdrsize)
+#define N_TXTADDR(x)	SEGMENT_SIZE
+#define N_COMM		0x0a	/** conflicts with N_INDR **/
+#define N_FN		0x0c
+/* Note that the Dynix binutils believe that N_SET[TDB] are
+   N_SH{DATA,BSS,COMM} -- be wary when mixing GNU & Dynix objects.  */
+#define PAGE_SIZE	4096
+#define SEGMENT_SIZE	PAGE_SIZE
+
+#else /* !(sequent && i386) */
+
+#if !defined (N_MAGIC)
+#define N_MAGIC(exec) ((exec).a_info & 0xffff)
+#endif
+#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
+#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
+#define N_SET_INFO(exec, magic, type, flags) \
+	((exec).a_info = ((magic) & 0xffff) \
+	 | (((int)(type) & 0xff) << 16) \
+	 | (((flags) & 0xff) << 24))
+#define N_SET_MAGIC(exec, magic) \
+	((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
+
+#define N_SET_MACHTYPE(exec, machtype) \
+	((exec).a_info = \
+	 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
+
+#define N_SET_FLAGS(exec, flags) \
+	((exec).a_info = \
+	 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
+
+#endif	/* sequent && i386 */
+
+#ifndef OMAGIC
+/* Code indicating object file or impure executable.  */
+#define OMAGIC 0407
+/* Code indicating pure executable.  */
+#define NMAGIC 0410
+/* Code indicating demand-paged executable.  */
+#define ZMAGIC 0413
+#endif /* not OMAGIC */
+
+#if !defined (N_BADMAG)
+#define N_BADMAG(x)					\
+ (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC		\
+  && N_MAGIC(x) != ZMAGIC)
+#endif
+
+#define _N_BADMAG(x)					\
+ (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC		\
+  && N_MAGIC(x) != ZMAGIC)
+
+#ifndef	sparc
+#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec))
+#else
+#define _N_HDROFF(x) (- sizeof (struct exec))
+#endif
+
+#if !defined (N_TXTOFF)
+#define N_TXTOFF(x) \
+ (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
+#endif
+
+#if !defined (N_DATOFF)
+#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
+#endif
+
+#if !defined (N_TRELOFF)
+#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
+#endif
+
+#if !defined (N_DRELOFF)
+#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
+#endif
+
+#if !defined (N_SYMOFF)
+#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
+#endif
+
+#if !defined (N_STROFF)
+#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
+#endif
+
+/* Address of text segment in memory after it is loaded.  */
+#if !defined (N_TXTADDR)
+#define N_TXTADDR(x) 0
+#endif
+
+/* Address of data segment in memory after it is loaded.
+   Note that it is up to you to define SEGMENT_SIZE
+   on machines not listed here.  */
+#if	defined (hp300) || defined (mips)
+#define	PAGE_SIZE	4096
+#endif
+#if	defined (sparc) || defined (NeXT)
+#define	PAGE_SIZE	0x2000
+#endif
+#if	defined (sony) || (defined (sun) && defined (mc68000))
+#define	SEGMENT_SIZE	0x2000
+#endif	/* Sony or 68k Sun.  */
+#ifdef is68k
+#define SEGMENT_SIZE 0x20000
+#endif
+#if defined(m68k) && defined(PORTAR)
+#define PAGE_SIZE 0x400
+#endif
+#if defined(i386) && !defined(sequent)
+/* For COFF encapsulation.  */
+#define SEGMENT_SIZE 0x400000
+#endif
+#ifndef	SEGMENT_SIZE
+/* This used to be first in this paragraph and under:
+   if (defined(vax) || defined(hp300) || defined(pyr) || defined(sparc) \
+     || (defined(m68k) && defined(PORTAR)) \
+     || defined (NeXT) || defined (mips)) */
+#define SEGMENT_SIZE PAGE_SIZE
+#endif
+#ifndef	PAGE_SIZE
+/* This value is for i386-minix, but that has no predefine.
+   Making it default will only cause confusion on machines
+   which have no proper value defined.  */
+#define	PAGE_SIZE 16
+#endif
+
+#define	PAGSIZ	PAGE_SIZE
+#define	SEGSIZ	SEGMENT_SIZE
+
+#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
+
+#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
+
+#ifndef N_DATADDR
+#define N_DATADDR(x) \
+    (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
+     : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
+#endif
+
+/* Address of bss segment in memory after it is loaded.  */
+#if !defined (N_BSSADDR)
+#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
+#endif
+
+#if !defined (N_NLIST_DECLARED)
+struct nlist {
+  union {
+    char *n_name;
+    struct nlist *n_next;
+    long n_strx;
+  } n_un;
+  unsigned char n_type;
+  char n_other;
+  short n_desc;
+  unsigned long n_value;
+};
+#endif /* no N_NLIST_DECLARED.  */
+
+#if !defined (N_UNDF)
+#define N_UNDF 0
+#endif
+#if !defined (N_ABS)
+#define N_ABS 2
+#endif
+#if !defined (N_TEXT)
+#define N_TEXT 4
+#endif
+#if !defined (N_DATA)
+#define N_DATA 6
+#endif
+#if !defined (N_BSS)
+#define N_BSS 8
+#endif
+#if !defined (N_COMM)
+#define N_COMM 18
+#endif
+#if !defined (N_FN)
+#define N_FN 15
+#endif
+
+#if !defined (N_EXT)
+#define N_EXT 1
+#endif
+#if !defined (N_TYPE)
+#define N_TYPE 036
+#endif
+#if !defined (N_STAB)
+#define N_STAB 0340
+#endif
+
+/* The following type indicates the definition of a symbol as being
+   an indirect reference to another symbol.  The other symbol
+   appears as an undefined reference, immediately following this symbol.
+
+   Indirection is asymmetrical.  The other symbol's value will be used
+   to satisfy requests for the indirect symbol, but not vice versa.
+   If the other symbol does not have a definition, libraries will
+   be searched to find a definition.  */
+#define N_INDR 0xa
+
+/* The following symbols refer to set elements.
+   All the N_SET[ATDB] symbols with the same name form one set.
+   Space is allocated for the set in the text section, and each set
+   element's value is stored into one word of the space.
+   The first word of the space is the length of the set (number of elements).
+
+   The address of the set is made into an N_SETV symbol
+   whose name is the same as the name of the set.
+   This symbol acts like a N_DATA global symbol
+   in that it can satisfy undefined external references.  */
+
+/* These appear as input to LD, in a .o file.  */
+#define	N_SETA	0x14		/* Absolute set element symbol */
+#define	N_SETT	0x16		/* Text set element symbol */
+#define	N_SETD	0x18		/* Data set element symbol */
+#define	N_SETB	0x1A		/* Bss set element symbol */
+
+/* This is output from LD.  */
+#define N_SETV	0x1C		/* Pointer to set vector in data area.  */
+
+#if !defined (N_RELOCATION_INFO_DECLARED)
+/* This structure describes a single relocation to be performed.
+   The text-relocation section of the file is a vector of these structures,
+   all of which apply to the text section.
+   Likewise, the data-relocation section applies to the data section.  */
+
+struct relocation_info
+{
+  /* Address (within segment) to be relocated.  */
+  int r_address;
+  /* The meaning of r_symbolnum depends on r_extern.  */
+  unsigned int r_symbolnum:24;
+  /* Nonzero means value is a pc-relative offset
+     and it should be relocated for changes in its own address
+     as well as for changes in the symbol or section specified.  */
+  unsigned int r_pcrel:1;
+  /* Length (as exponent of 2) of the field to be relocated.
+     Thus, a value of 2 indicates 1<<2 bytes.  */
+  unsigned int r_length:2;
+  /* 1 => relocate with value of symbol.
+          r_symbolnum is the index of the symbol
+	  in file's the symbol table.
+     0 => relocate with the address of a segment.
+          r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
+	  (the N_EXT bit may be set also, but signifies nothing).  */
+  unsigned int r_extern:1;
+  /* Four bits that aren't used, but when writing an object file
+     it is desirable to clear them.  */
+  unsigned int r_pad:4;
+};
+#endif /* no N_RELOCATION_INFO_DECLARED.  */
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* __A_OUT_GNU_H__ */
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 5bd0f8254b..e1b0f4780f 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -1,21 +1,21 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  i386 version.
-Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-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.  */
 
 #ifndef dl_machine_h
 #define dl_machine_h
@@ -39,13 +39,14 @@ elf_machine_matches_host (Elf32_Half e_machine)
 }
 
 
-/* Return the run-time address of the _GLOBAL_OFFSET_TABLE_.
-   Must be inlined in a function which uses global data.  */
-static inline Elf32_Addr * __attribute__ ((unused))
-elf_machine_got (void)
+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
+   first element of the GOT.  This must be inlined in a function which
+   uses global data.  */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
 {
   register Elf32_Addr *got asm ("%ebx");
-  return got;
+  return *got;
 }
 
 
diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
index 8b9872c15a..a4b1edcdd9 100644
--- a/sysdeps/m68k/dl-machine.h
+++ b/sysdeps/m68k/dl-machine.h
@@ -1,21 +1,21 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  m68k version.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 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
-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.  */
 
 #ifndef dl_machine_h
 #define dl_machine_h
@@ -38,13 +38,14 @@ elf_machine_matches_host (Elf32_Half e_machine)
 }
 
 
-/* Return the run-time address of the _GLOBAL_OFFSET_TABLE_.
-   Must be inlined in a function which uses global data.  */
-static inline Elf32_Addr *
-elf_machine_got (void)
+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
+   first element of the GOT.  This must be inlined in a function which
+   uses global data.  */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
 {
   register Elf32_Addr *got asm ("%a5");
-  return got;
+  return *got;
 }
 
 
diff --git a/sysdeps/mach/hurd/libc-ldscript b/sysdeps/mach/hurd/libc-ldscript
index 26aca50272..499a2b2b99 100644
--- a/sysdeps/mach/hurd/libc-ldscript
+++ b/sysdeps/mach/hurd/libc-ldscript
@@ -1,4 +1,5 @@
-/* This linker script is installed as /lib/libc.a.
+/* GNU ld script
+   This linker script is installed as /lib/libc.a.
    It makes -lc become just like -( -lcrt -lmachuser -lhurduser -).
    */
 
diff --git a/sysdeps/mach/hurd/libc_p-ldscript b/sysdeps/mach/hurd/libc_p-ldscript
index d809998a1f..7dcd52eec4 100644
--- a/sysdeps/mach/hurd/libc_p-ldscript
+++ b/sysdeps/mach/hurd/libc_p-ldscript
@@ -1,4 +1,5 @@
-/* This linker script is installed as /lib/libc_p.a.
+/* GNU ld script
+   This linker script is installed as /lib/libc_p.a.
    It makes -lc_p become just like -( -lcrt_p -lmachuser_p -lhurduser_p -).
    */
 
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
index c0ac649144..c00afbe549 100644
--- a/sysdeps/mips/dl-machine.h
+++ b/sysdeps/mips/dl-machine.h
@@ -1,22 +1,22 @@
-/* Machine-dependent ELF dynamic relocation inline functions.  mips version.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Contributed by Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
-
-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.  */
+/* Machine-dependent ELF dynamic relocation inline functions.  MIPS version.
+   Copyright (C) 1996 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
+
+   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.  */
 
 #define ELF_MACHINE_NAME "MIPS"
 
@@ -67,13 +67,14 @@ elf_mips_got_from_gpreg (ElfW(Addr) gpreg)
   /* FIXME: the offset of gp from GOT may be system-dependent. */
   return (ElfW(Addr) *) (gpreg - 0x7ff0);
 }
-/* Return the run-time address of the _GLOBAL_OFFSET_TABLE_.
-   Must be inlined in a function which uses global data.  */
-static inline ElfW(Addr) *
-elf_machine_got (void)
+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
+   first element of the GOT.  This must be inlined in a function which
+   uses global data.  */
+static inline ElfW(Addr)
+elf_machine_dynamic (void)
 {
   register ElfW(Addr) gp asm ("$28");
-  return (ElfW(Addr) *) (gp - 0x7ff0);
+  return * (ElfW(Addr) *) (gp - 0x7ff0);
 }
 
 
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index 5f3f628fb5..92196ac50a 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -1,20 +1,20 @@
 /* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   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.  */
 
 /* Wants:
    AC_STDC_HEADERS
@@ -187,6 +187,10 @@ extern char *alloca ();
 #define __getcwd getcwd
 #endif
 
+#if defined HAVE_READDIR_R && !defined _LIBC
+#define __readdir_r readdir_r
+#endif
+
 /* Get the pathname of the current working directory, and put it in SIZE
    bytes of BUF.  Returns NULL if the directory couldn't be determined or
    SIZE was too small.  If successful, returns BUF.  In GNU, if BUF is
@@ -250,6 +254,9 @@ __getcwd (buf, size)
     {
       register DIR *dirstream;
       register struct dirent *d;
+#if defined HAVE_READDIR_R || defined _LIBC
+      struct dirent dirbuf;
+#endif
       dev_t dotdev;
       ino_t dotino;
       char mount_point;
@@ -292,7 +299,13 @@ __getcwd (buf, size)
       dirstream = __opendir (dotp);
       if (dirstream == NULL)
 	goto lose;
-      while ((d = __readdir (dirstream)) != NULL)
+      while (
+#if defined HAVE_READDIR_R || defined _LIBC
+	     __readdir_r (dirstream, &dirbuf, &d) >= 0
+#else
+	     (d = __readdir (dirstream)) != NULL
+#endif
+	     )
 	{
 	  if (d->d_name[0] == '.' &&
 	      (d->d_name[1] == '\0' ||
diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c
index 9668117b47..043e91b084 100644
--- a/sysdeps/posix/ttyname.c
+++ b/sysdeps/posix/ttyname.c
@@ -1,20 +1,20 @@
 /* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   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 <errno.h>
 #include <limits.h>
@@ -41,7 +41,7 @@ ttyname (fd)
   dev_t mydev;
   ino_t myino;
   DIR *dirstream;
-  struct dirent *d;
+  struct dirent dirbuf, *d;
   int save = errno;
 
   if (!__isatty (fd))
@@ -56,7 +56,7 @@ ttyname (fd)
   if (dirstream == NULL)
     return NULL;
 
-  while ((d = readdir (dirstream)) != NULL)
+  while (__readdir_r (dirstream, &dirbuf, &d) >= 0)
     if ((ino_t) d->d_fileno == myino)
       {
 	size_t dlen = _D_ALLOC_NAMLEN (d);
diff --git a/sysdeps/posix/ttyname_r.c b/sysdeps/posix/ttyname_r.c
index 5b62826a19..c7cf21aeee 100644
--- a/sysdeps/posix/ttyname_r.c
+++ b/sysdeps/posix/ttyname_r.c
@@ -1,20 +1,20 @@
 /* Copyright (C) 1991, 92, 93, 95, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   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 <errno.h>
 #include <limits.h>
@@ -43,7 +43,7 @@ __ttyname_r (fd, buf, buflen)
   dev_t mydev;
   ino_t myino;
   DIR *dirstream;
-  struct dirent *d;
+  struct dirent dirbuf, *d;
   int save = errno;
 
   /* Test for the absolute minimal size.  This makes life easier inside
@@ -74,7 +74,7 @@ __ttyname_r (fd, buf, buflen)
   buf[sizeof (dev) - 1] = '/';
   buflen -= sizeof (dev);
 
-  while ((d = readdir (dirstream)) != NULL)
+  while (__readdir_r (dirstream, &dirbuf, &d) >= 0)
     if ((ino_t) d->d_fileno == myino)
       {
 	char *cp;
diff --git a/sysdeps/sparc/dl-machine.h b/sysdeps/sparc/dl-machine.h
index 695b9d6af3..ad288e15b2 100644
--- a/sysdeps/sparc/dl-machine.h
+++ b/sysdeps/sparc/dl-machine.h
@@ -1,21 +1,21 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  SPARC version.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 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
-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.  */
 
 #define ELF_MACHINE_NAME "sparc"
 
@@ -46,13 +46,14 @@ elf_machine_matches_host (Elf32_Half e_machine)
 }
 
 
-/* Return the run-time address of the _GLOBAL_OFFSET_TABLE_.
-   Must be inlined in a function which uses global data.  */
-static inline Elf32_Addr *
-elf_machine_got (void)
+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
+   first element of the GOT.  This must be inlined in a function which
+   uses global data.  */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
 {
   register Elf32_Addr *got asm ("%l7");
-  return got;
+  return *got;
 }
 
 
diff --git a/sysdeps/stub/dl-machine.h b/sysdeps/stub/dl-machine.h
index 1fdb461da7..f44266f7b7 100644
--- a/sysdeps/stub/dl-machine.h
+++ b/sysdeps/stub/dl-machine.h
@@ -1,21 +1,21 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  Stub version.
-Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-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.  */
 
 #define ELF_MACHINE_NAME "stub"
 
@@ -36,11 +36,11 @@ elf_machine_matches_host (Elf32_Half e_machine)
 }
 
 
-/* Return the run-time address of the _GLOBAL_OFFSET_TABLE_.  */
-static inline Elf32_Addr *
-elf_machine_got (void)
+/* Return the link-time address of _DYNAMIC.  */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
 {
-#error "GOT not got"
+#error "Damn, no _DYNAMIC"
 }
 
 
diff --git a/sysdeps/unix/alpha/sysdep.S b/sysdeps/unix/alpha/sysdep.S
index 08dc3b4851..9df313422c 100644
--- a/sysdeps/unix/alpha/sysdep.S
+++ b/sysdeps/unix/alpha/sysdep.S
@@ -1,20 +1,20 @@
 /* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
    Contributed by Brendan Kehoe (brendan@zen.org).
 
-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>
 #include <features.h>
@@ -63,22 +63,6 @@ __syscall_error:
 	lda	sp, 16(sp)
 	ret
 	.end __syscall_error
-
-/* A default non-threaded version of __errno_location that just returns
-   the address of errno.  */
-
-	.weak	__errno_location
-	.ent	__errno_location
-__errno_location:
-	.frame	sp, 0, ra
-	ldgp	gp, 0(t12)
-	.mask	0, 0
-	.prologue 1
-
-	lda	v0, errno
-	ret
-	.end __errno_location
-
 #else
 
 ENTRY(__syscall_error)
diff --git a/sysdeps/unix/readdir_r.c b/sysdeps/unix/readdir_r.c
index ef75c36234..fca3eeeb5f 100644
--- a/sysdeps/unix/readdir_r.c
+++ b/sysdeps/unix/readdir_r.c
@@ -1,20 +1,20 @@
 /* Copyright (C) 1991, 92, 93, 94, 95, 96 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.  */
+   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.  */
 
 #include <errno.h>
 #include <limits.h>
diff --git a/sysdeps/unix/sysv/linux/a.out.h b/sysdeps/unix/sysv/linux/a.out.h
new file mode 100644
index 0000000000..027c49ad55
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/a.out.h
@@ -0,0 +1 @@
+#include <linux/a.out.h>