x86: Move CET infrastructure to x86_64
[glibc.git] / sysdeps / unix / sysv / linux / x86_64 / tst-cet-property-2.c
blob5274a09509349c544bcac0600028d2b2cfbc983f
1 /* Test CET property note parser for [BZ #23467].
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 <string.h>
22 #include <signal.h>
23 #include <support/check.h>
25 extern void bar (void);
27 void
28 __attribute__ ((noclone, noinline))
29 test (void (*func_p) (void))
31 func_p ();
34 /* bar contains an IBT violation if it is called indirectly via a
35 function pointer. On IBT machines, it should lead to segfault
36 unless IBT is disabled by error. */
38 static void
39 sig_handler (int signo)
41 exit (EXIT_SUCCESS);
44 static int
45 do_test (void)
47 char buf[4];
49 if (scanf ("%3s", buf) != 1)
50 FAIL_UNSUPPORTED ("IBT not supported");
52 if (strcmp (buf, "IBT") != 0)
53 FAIL_UNSUPPORTED ("IBT not supported");
55 TEST_VERIFY_EXIT (signal (SIGSEGV, &sig_handler) != SIG_ERR);
57 /* Call bar via a function pointer to force an IBT violation. */
58 test (bar);
60 return EXIT_FAILURE;
63 #include <support/test-driver.c>