about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/dl-sysdep.c25
-rw-r--r--sysdeps/generic/sbrk.c18
-rw-r--r--sysdeps/unix/sysv/linux/fcntlbits.h11
-rw-r--r--sysdeps/unix/sysv/linux/gnu/types.h1
4 files changed, 34 insertions, 21 deletions
diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c
index 36349a5658..0dfb499d52 100644
--- a/sysdeps/generic/dl-sysdep.c
+++ b/sysdeps/generic/dl-sysdep.c
@@ -31,21 +31,26 @@ Cambridge, MA 02139, USA.  */
 extern int _dl_argc;
 extern char **_dl_argv;
 extern char **_environ;
+extern void _end;
 extern void _start (void);
 
 int __libc_enable_secure;
+int __libc_multiple_libcs;	/* Defining this here avoids the inclusion
+				   of init-first.  */
 
 ElfW(Addr)
 _dl_sysdep_start (void **start_argptr,
 		  void (*dl_main) (const ElfW(Phdr) *phdr, ElfW(Word) phnum,
 				   ElfW(Addr) *user_entry))
 {
-  const ElfW(Phdr) *phdr;
-  ElfW(Word) phnum;
+  const ElfW(Phdr) *phdr = NULL;
+  ElfW(Word) phnum = 0;
   ElfW(Addr) user_entry;
   ElfW(auxv_t) *av;
-  uid_t uid, euid;
-  gid_t gid, egid;
+  uid_t uid = 0;
+  uid_t euid = 0;
+  gid_t gid = 0;
+  gid_t egid = 0;
   unsigned int seen;
 
   user_entry = (ElfW(Addr)) &_start;
@@ -103,6 +108,18 @@ _dl_sysdep_start (void **start_argptr,
   DL_SYSDEP_INIT;
 #endif
 
+  if (__sbrk (0) == &_end)
+    {
+      /* The dynamic linker was run as a program, and so the initial break
+	 starts just after our bss, at &_end.  The malloc in dl-minimal.c
+	 will consume the rest of this page, so tell the kernel to move the
+	 break up that far.  When the user program examines its break, it
+	 will see this new value and not clobber our data.  */
+      size_t pg = __getpagesize ();
+
+      __sbrk (pg - ((&_end - (void *) 0) & (pg - 1)));
+    }
+
   (*dl_main) (phdr, phnum, &user_entry);
   return user_entry;
 }
diff --git a/sysdeps/generic/sbrk.c b/sysdeps/generic/sbrk.c
index d3ea705294..afed5902dc 100644
--- a/sysdeps/generic/sbrk.c
+++ b/sysdeps/generic/sbrk.c
@@ -38,22 +38,8 @@ __sbrk (ptrdiff_t increment)
      instances of __brk and __sbrk can share the heap, returning
      interleaved pieces of it.  */
   if (__curbrk == NULL || __libc_multiple_libcs)
-    {
-      extern void _end;
-
-      if (__brk (0) < 0)		/* Initialize the break.  */
-	return (void *) -1;
-
-      /* Align break address to page boundary if not happened before.  */
-      if (!__libc_multiple_libcs && __curbrk == &_end)
-	{
-	  size_t pg = __getpagesize ();
-	  ptrdiff_t rest = pg - ((&_end - (void *) 0) & (pg - 1));
-
-	  if (__brk (__curbrk + rest) < 0)
-	    return (void *) -1;
-	}
-    }
+    if (__brk (0) < 0)		/* Initialize the break.  */
+      return (void *) -1;
 
   if (increment == 0)
     return __curbrk;
diff --git a/sysdeps/unix/sysv/linux/fcntlbits.h b/sysdeps/unix/sysv/linux/fcntlbits.h
index 8d92ac02b0..9088e6df57 100644
--- a/sysdeps/unix/sysv/linux/fcntlbits.h
+++ b/sysdeps/unix/sysv/linux/fcntlbits.h
@@ -1,5 +1,5 @@
 /* O_*, F_*, FD_* bit values for Linux.
-Copyright (C) 1995 Free Software Foundation, Inc.
+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
@@ -23,4 +23,13 @@ Boston, MA 02111-1307, USA.  */
 #include <sys/types.h>
 #include <linux/fcntl.h>
 
+/* Define some more compatibility macros to be backward compatible with
+   BSD systems which did not managed to hide these kernel macros.  */
+#ifdef	__USE_BSD
+#define	FAPPEND		O_APPEND
+#define	FFSYNC		O_FSYNC
+#define	FNONBLOCK	O_NONBLOCK
+#define	FNDELAY		O_NDELAY
+#endif /* Use BSD.  */
+
 #endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/sysv/linux/gnu/types.h b/sysdeps/unix/sysv/linux/gnu/types.h
index 89b815dd60..abfcb6e9c9 100644
--- a/sysdeps/unix/sysv/linux/gnu/types.h
+++ b/sysdeps/unix/sysv/linux/gnu/types.h
@@ -51,6 +51,7 @@ typedef __kernel_ino_t __ino_t;		/* Type of file serial numbers.  */
 typedef __kernel_mode_t __mode_t;	/* Type of file attribute bitmasks.  */
 typedef __kernel_nlink_t __nlink_t; 	/* Type of file link counts.  */
 typedef __kernel_off_t __off_t;		/* Type of file sizes and offsets.  */
+typedef __kernel_loff_t __loff_t;	/* Type of file sizes and offsets.  */
 typedef __kernel_pid_t __pid_t;		/* Type of process identifications.  */
 typedef __kernel_ssize_t __ssize_t;	/* Type of a byte count, or error.  */
 typedef __kernel_fsid_t __fsid_t;	/* Type of file system IDs.  */