Allow _Qp_fgt in sparc64 localplt.data
[glibc.git] / elf / tst-audit25a.c
blob9d2b316576fce3365160814a9193cb0542e31be2
1 /* Check LD_AUDIT and LD_BIND_NOW.
2 Copyright (C) 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 <array_length.h>
20 #include <errno.h>
21 #include <getopt.h>
22 #include <limits.h>
23 #include <inttypes.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include <support/capture_subprocess.h>
27 #include <support/check.h>
28 #include <support/xstdio.h>
29 #include <support/support.h>
30 #include <sys/auxv.h>
32 #include "tst-audit25.h"
34 static int restart;
35 #define CMDLINE_OPTIONS \
36 { "restart", no_argument, &restart, 1 },
38 void tst_audit25mod1_func1 (void);
39 void tst_audit25mod1_func2 (void);
40 void tst_audit25mod2_func1 (void);
41 void tst_audit25mod2_func2 (void);
43 static int
44 handle_restart (void)
46 tst_audit25mod1_func1 ();
47 tst_audit25mod1_func2 ();
48 tst_audit25mod2_func1 ();
49 tst_audit25mod2_func2 ();
51 return 0;
54 static int
55 do_test (int argc, char *argv[])
57 /* We must have either:
58 - One or four parameters left if called initially:
59 + path to ld.so optional
60 + "--library-path" optional
61 + the library path optional
62 + the application name */
64 if (restart)
65 return handle_restart ();
67 setenv ("LD_AUDIT", "tst-auditmod25.so", 0);
69 char *spargv[9];
70 int i = 0;
71 for (; i < argc - 1; i++)
72 spargv[i] = argv[i + 1];
73 spargv[i++] = (char *) "--direct";
74 spargv[i++] = (char *) "--restart";
75 spargv[i] = NULL;
76 TEST_VERIFY_EXIT (i < array_length (spargv));
79 struct support_capture_subprocess result
80 = support_capture_subprogram (spargv[0], spargv);
81 support_capture_subprocess_check (&result, "tst-audit25a", 0,
82 sc_allow_stderr);
84 /* tst-audit25a is build with -Wl,-z,lazy and tst-audit25mod1 with
85 -Wl,-z,now; so only tst_audit25mod3_func1 should be expected to
86 have LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT. */
87 const char *expected[] =
89 "la_symbind: tst_audit25mod1_func1 0\n",
90 "la_symbind: tst_audit25mod1_func2 0\n",
91 "la_symbind: tst_audit25mod2_func1 0\n",
92 "la_symbind: tst_audit25mod2_func2 0\n",
93 "la_symbind: tst_audit25mod3_func1 1\n",
94 "la_symbind: tst_audit25mod4_func1 0\n",
96 compare_output (result.err.buffer, result.err.length,
97 expected, array_length(expected));
99 support_capture_subprocess_free (&result);
103 setenv ("LD_BIND_NOW", "1", 0);
104 struct support_capture_subprocess result
105 = support_capture_subprogram (spargv[0], spargv);
106 support_capture_subprocess_check (&result, "tst-audit25a", 0,
107 sc_allow_stderr);
109 /* With LD_BIND_NOW all symbols are expected to have
110 LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT. Also the resolution
111 order is done in breadth-first order. */
112 const char *expected[] =
114 "la_symbind: tst_audit25mod1_func1 1\n",
115 "la_symbind: tst_audit25mod1_func2 1\n",
116 "la_symbind: tst_audit25mod2_func1 1\n",
117 "la_symbind: tst_audit25mod2_func2 1\n",
118 "la_symbind: tst_audit25mod3_func1 1\n",
119 "la_symbind: tst_audit25mod4_func1 1\n",
121 compare_output (result.err.buffer, result.err.length,
122 expected, array_length(expected));
124 support_capture_subprocess_free (&result);
127 return 0;
130 #define TEST_FUNCTION_ARGV do_test
131 #include <support/test-driver.c>