1 /* Verify that RTLD_NOLOAD works as expected.
3 Copyright (C) 2016 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
22 #include <gnu/lib-names.h>
27 /* Test that no object is loaded with RTLD_NOLOAD. */
28 void *h1
= dlopen (LIBM_SO
, RTLD_LAZY
| RTLD_NOLOAD
);
31 printf ("h1: DSO has been loaded while it should have not\n");
35 /* This used to segfault in some glibc versions. */
36 void *h2
= dlopen (LIBM_SO
, RTLD_LAZY
| RTLD_NOLOAD
| RTLD_NODELETE
);
39 printf ("h2: DSO has been loaded while it should have not\n");
43 /* Test that loading an already loaded object returns the same. */
44 void *h3
= dlopen (LIBM_SO
, RTLD_LAZY
);
47 printf ("h3: failed to open DSO: %s\n", dlerror ());
50 void *h4
= dlopen (LIBM_SO
, RTLD_LAZY
| RTLD_NOLOAD
);
53 printf ("h4: failed to open DSO: %s\n", dlerror ());
58 printf ("h4: should return the same object\n");
63 if (dlclose (h3
) != 0)
65 printf ("h3: dlclose failed: %s\n", dlerror ());
72 #define TEST_FUNCTION do_test ()
73 #include "../test-skeleton.c"