1/* Test for re-exec with legacy bitmap.
2 Copyright (C) 2018-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19#include <stdlib.h>
20#include <stdio.h>
21#include <unistd.h>
22#include <getopt.h>
23#include <support/check.h>
24
25/* Nonzero if the program gets called via `exec'. */
26static int restart;
27
28#define CMDLINE_OPTIONS \
29 { "restart", no_argument, &restart, 1 },
30
31extern int do_test (int argc, char *argv[]);
32
33extern int in_dso_1 (void);
34extern int in_dso_2 (void);
35
36static int
37check (void)
38{
39 if (in_dso_1 () != 0x1234678)
40 {
41 puts (s: "in_dso_1 () != 0x1234678");
42 exit (1);
43 }
44
45 if (in_dso_2 () != 0xbadbeef)
46 {
47 puts (s: "in_dso_2 () != 0xbadbeef");
48 exit (1);
49 }
50
51 return 0;
52}
53
54int
55do_test (int argc, char *argv[])
56{
57 /* We must have
58 - one or four parameters left if called initially
59 + path for ld.so optional
60 + "--library-path" optional
61 + the library path optional
62 + the application name
63 */
64
65 if (restart)
66 return check ();
67
68 if (argc != 2 && argc != 5)
69 FAIL_EXIT1 ("wrong number of arguments (%d)", argc);
70
71 if (argc == 5)
72 execl (argv[1], argv[1], argv[2], argv[3], argv[4], "--direct",
73 "--restart", NULL);
74 else
75 execl (argv[1], argv[1], "--direct", "--restart", NULL);
76
77 return -1;
78}
79
80#define TEST_FUNCTION_ARGV do_test
81#include <support/test-driver.c>
82

source code of glibc/sysdeps/x86/tst-cet-legacy-1a.c