x86: Move CET infrastructure to x86_64
[glibc.git] / sysdeps / x86_64 / tst-cet-legacy-1a.c
blob205e0892b3db1db9bfc122b47b6b07b97d65c820
1 /* Test for re-exec with legacy bitmap.
2 Copyright (C) 2018-2024 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 <stdlib.h>
20 #include <stdio.h>
21 #include <unistd.h>
22 #include <getopt.h>
23 #include <support/check.h>
25 /* Nonzero if the program gets called via `exec'. */
26 static int restart;
28 #define CMDLINE_OPTIONS \
29 { "restart", no_argument, &restart, 1 },
31 extern int do_test (int argc, char *argv[]);
33 extern int in_dso_1 (void);
34 extern int in_dso_2 (void);
36 static int
37 check (void)
39 if (in_dso_1 () != 0x1234678)
41 puts ("in_dso_1 () != 0x1234678");
42 exit (1);
45 if (in_dso_2 () != 0xbadbeef)
47 puts ("in_dso_2 () != 0xbadbeef");
48 exit (1);
51 return 0;
54 int
55 do_test (int argc, char *argv[])
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
65 if (restart)
66 return check ();
68 if (argc != 2 && argc != 5)
69 FAIL_EXIT1 ("wrong number of arguments (%d)", argc);
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);
77 return -1;
80 #define TEST_FUNCTION_ARGV do_test
81 #include <support/test-driver.c>