Fix ChangeLog formatting
[glibc.git] / elf / tst-noload.c
blob70609e0416c3403c4950bdedf70656db602f2bd8
1 /* Verify that RTLD_NOLOAD works as expected.
3 Copyright (C) 2016-2018 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/>. */
20 #include <dlfcn.h>
21 #include <stdio.h>
22 #include <gnu/lib-names.h>
24 static int
25 do_test (void)
27 /* Test that no object is loaded with RTLD_NOLOAD. */
28 void *h1 = dlopen (LIBM_SO, RTLD_LAZY | RTLD_NOLOAD);
29 if (h1 != NULL)
31 printf ("h1: DSO has been loaded while it should have not\n");
32 return 1;
35 /* This used to segfault in some glibc versions. */
36 void *h2 = dlopen (LIBM_SO, RTLD_LAZY | RTLD_NOLOAD | RTLD_NODELETE);
37 if (h2 != NULL)
39 printf ("h2: DSO has been loaded while it should have not\n");
40 return 1;
43 /* Test that loading an already loaded object returns the same. */
44 void *h3 = dlopen (LIBM_SO, RTLD_LAZY);
45 if (h3 == NULL)
47 printf ("h3: failed to open DSO: %s\n", dlerror ());
48 return 1;
50 void *h4 = dlopen (LIBM_SO, RTLD_LAZY | RTLD_NOLOAD);
51 if (h4 == NULL)
53 printf ("h4: failed to open DSO: %s\n", dlerror ());
54 return 1;
56 if (h4 != h3)
58 printf ("h4: should return the same object\n");
59 return 1;
62 /* Cleanup */
63 if (dlclose (h3) != 0)
65 printf ("h3: dlclose failed: %s\n", dlerror ());
66 return 1;
69 return 0;
72 #include <support/test-driver.c>