(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / unix / sysv / linux / dl-sysdep.c
blob79f95df0a22a345459c324fb93b8af8307dfe52d
1 /* Dynamic linker system dependencies for Linux.
2 Copyright (C) 1995, 1997, 2001, 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 /* Linux needs some special initialization, but otherwise uses
21 the generic dynamic linker system interface code. */
23 #include <unistd.h>
24 #include <ldsodefs.h>
25 #include "kernel-features.h"
27 #define DL_SYSDEP_INIT frob_brk ()
29 static inline void
30 frob_brk (void)
32 __brk (0); /* Initialize the break. */
34 #if ! __ASSUME_BRK_PAGE_ROUNDED
35 /* If the dynamic linker was executed as a program, then the break may
36 start immediately after our data segment. However, dl-minimal.c has
37 already stolen the remainder of the page for internal allocations.
38 If we don't adjust the break location recorded by the kernel, the
39 normal program startup will inquire, find the value at our &_end,
40 and start allocating its own data there, clobbering dynamic linker
41 data structures allocated there during startup.
43 Later Linux kernels have changed this behavior so that the initial
44 break value is rounded up to the page boundary before we start. */
46 extern void *__curbrk attribute_hidden;
47 extern void _end attribute_hidden;
48 void *const endpage = (void *) 0 + (((__curbrk - (void *) 0)
49 + GLRO(dl_pagesize) - 1)
50 & -GLRO(dl_pagesize));
51 if (__builtin_expect (__curbrk >= &_end && __curbrk < endpage, 0))
52 __brk (endpage);
53 #endif
56 #include <sysdeps/generic/dl-sysdep.c>