1 /* GLRO(dl_pagesize) initialization DSO test with a static executable.
2 Copyright (C) 2013 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, see
17 <http://www.gnu.org/licenses/>. */
24 /* Check that the same page size is reported both directly and by a DSO
25 mapped from a static executable.
27 On targets that support different page sizes, the kernel communicates
28 the size currently in use via the auxiliary vector. This vector is
29 available to initial startup, but not any DSOs loaded later on. As
30 static executables do not export their symbols a DSO cannot access
31 the value obtained by initial startup and the value therefore has to
32 be passed on to the DSO and stored within its data area explicitly.
33 This is performed by a call to DL_STATIC_INIT that is defined in a
34 target-dependent way, and that on variable page size targets stores
35 it in the GLRO(dl_pagesize) variable of the DSO's dynamic linker. */
39 int pagesize
= getpagesize ();
40 int (*my_getpagesize
) (void);
44 /* Try to map a module. */
45 handle
= dlopen ("modstatic5.so", RTLD_LAZY
| RTLD_LOCAL
);
48 printf ("dlopen (modstatic5.so): %s\n", dlerror ());
52 /* Get at its symbol. */
53 my_getpagesize
= dlsym (handle
, "my_getpagesize");
54 if (my_getpagesize
== NULL
)
56 printf ("dlsym (my_getpagesize): %s\n", dlerror ());
60 /* Make sure the page size reported is the same either way. */
61 my_pagesize
= my_getpagesize ();
62 if (my_pagesize
!= pagesize
)
64 printf ("my_getpagesize: got %i, expected %i\n", my_pagesize
, pagesize
);
68 /* All done, clean up. */
69 my_getpagesize
= NULL
;
75 #define TEST_FUNCTION do_test ()
76 #include "../test-skeleton.c"