Linux: Assume and consolidate socket wire-up syscall
[glibc.git] / dlfcn / tststatic5.c
blobc286167a158925693756e550dbdcc0b9598ce839
1 /* GLRO(dl_pagesize) initialization DSO test with a static executable.
2 Copyright (C) 2013-2022 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 <https://www.gnu.org/licenses/>. */
19 #include <dlfcn.h>
20 #include <stddef.h>
21 #include <stdio.h>
22 #include <unistd.h>
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. The auxiliary
29 vector and HWCAP/HWCAP2 bits are copied across the static dlopen
30 boundary in __rtld_static_init. */
31 static int
32 do_test (void)
34 int pagesize = getpagesize ();
35 int (*my_getpagesize) (void);
36 int my_pagesize;
37 void *handle;
39 /* Try to map a module. */
40 handle = dlopen ("modstatic5.so", RTLD_LAZY | RTLD_LOCAL);
41 if (handle == NULL)
43 printf ("dlopen (modstatic5.so): %s\n", dlerror ());
44 return 1;
47 /* Get at its symbol. */
48 my_getpagesize = dlsym (handle, "my_getpagesize");
49 if (my_getpagesize == NULL)
51 printf ("dlsym (my_getpagesize): %s\n", dlerror ());
52 return 1;
55 /* Make sure the page size reported is the same either way. */
56 my_pagesize = my_getpagesize ();
57 if (my_pagesize != pagesize)
59 printf ("my_getpagesize: got %i, expected %i\n", my_pagesize, pagesize);
60 return 1;
63 /* All done, clean up. */
64 my_getpagesize = NULL;
65 dlclose (handle);
67 return 0;
70 #define TEST_FUNCTION do_test ()
71 #include "../test-skeleton.c"