Allow _Qp_fgt in sparc64 localplt.data
[glibc.git] / elf / tst-dlmopen-dlerror-mod.c
blob2b7d1a4f7c4e33f9adfdf9ca2417dd43866fbd5d
1 /* Check that dlfcn errors are reported properly after dlmopen. Test module.
2 Copyright (C) 2021-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 <http://www.gnu.org/licenses/>. */
19 #include <dlfcn.h>
20 #include <stddef.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <support/check.h>
25 /* Note: This object is not linked into the main program, so we cannot
26 use delayed test failure reporting via TEST_VERIFY etc., and have
27 to use FAIL_EXIT1 (or something else that calls exit). */
29 void
30 call_dlsym (const char *name)
32 void *ptr = dlsym (NULL, name);
33 if (ptr != NULL)
34 FAIL_EXIT1 ("dlsym did not fail as expected for: %s", name);
35 const char *message = dlerror ();
36 if (strstr (message, ": undefined symbol: does not exist X") == NULL)
37 FAIL_EXIT1 ("invalid dlsym error message for [[%s]]: %s", name, message);
38 message = dlerror ();
39 if (message != NULL)
40 FAIL_EXIT1 ("second dlsym for [[%s]]: %s", name, message);
43 void
44 call_dlopen (const char *name)
46 void *handle = dlopen (name, RTLD_NOW);
47 if (handle != NULL)
48 FAIL_EXIT1 ("dlopen did not fail as expected for: %s", name);
49 const char *message = dlerror ();
50 if (strstr (message, "X: cannot open shared object file:"
51 " No such file or directory") == NULL
52 && strstr (message, "X: cannot open shared object file:"
53 " File name too long") == NULL)
54 FAIL_EXIT1 ("invalid dlopen error message for [[%s]]: %s", name, message);
55 message = dlerror ();
56 if (message != NULL)
57 FAIL_EXIT1 ("second dlopen for [[%s]]: %s", name, message);