summary refs log tree commit diff
path: root/sysdeps/generic
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/machine-gmon.h4
-rw-r--r--sysdeps/generic/sbrk.c18
2 files changed, 18 insertions, 4 deletions
diff --git a/sysdeps/generic/machine-gmon.h b/sysdeps/generic/machine-gmon.h
index 115962a601..43bf62d663 100644
--- a/sysdeps/generic/machine-gmon.h
+++ b/sysdeps/generic/machine-gmon.h
@@ -46,6 +46,6 @@ static inline void mcount_internal (frompc, selfpc)
 #define MCOUNT \
 void _mcount (void)							      \
 {									      \
-  mcount_internal ((u_long) __builtin_return_address (0),		      \
-		   (u_long) __builtin_return_address (1));		      \
+  mcount_internal ((u_long) __builtin_return_address (1),		      \
+		   (u_long) __builtin_return_address (0));		      \
 }
diff --git a/sysdeps/generic/sbrk.c b/sysdeps/generic/sbrk.c
index f63195adb3..d3ea705294 100644
--- a/sysdeps/generic/sbrk.c
+++ b/sysdeps/generic/sbrk.c
@@ -38,8 +38,22 @@ __sbrk (ptrdiff_t increment)
      instances of __brk and __sbrk can share the heap, returning
      interleaved pieces of it.  */
   if (__curbrk == NULL || __libc_multiple_libcs)
-    if (__brk (0) < 0)
-      return (void *) -1;
+    {
+      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 (increment == 0)
     return __curbrk;