1 // SPDX-License-Identifier: MIT
2 // SPDX-FileCopyrightText: 2024 Michael Jeanson <mjeanson@efficios.com>
16 * Ensure the main executable has at least one TLS variable which will be
17 * allocated before the rseq area, making sure the rseq_offset is not 0. This
18 * allows testing that the rseq_offset variable is properly initialized by
19 * checking it is not 0.
21 * Most toolchains will add at least one main exec TLS variable but it's
22 * currently not the case on RISC-V.
24 __thread
int dummy_tls
= -1;
27 * Check the state of the public symbols when the rseq syscall is unavailable.
29 * This test must be used with an LD_PRELOAD library to deny access to the
30 * syscall, or on a kernel that doesn't implement the syscall.
35 struct rseq_abi
*rseq_abi
;
39 if (rseq_available(RSEQ_AVAILABLE_QUERY_KERNEL
)) {
40 fail("The rseq syscall should be unavailable");
44 /* The rseq syscall is disabled, no registration is possible. */
46 ok(rseq_flags
== 0, "rseq_flags prior to registration is 0 (%d)", rseq_flags
);
47 ok(rseq_size
== 0, "rseq_size prior to registration is 0 (%d)", rseq_size
);
48 ok(rseq_offset
!= 0, "rseq_offset prior to registration is not 0 (%td)", rseq_offset
);
50 rseq_abi
= rseq_get_abi();
51 ok((int32_t) rseq_abi
->cpu_id
== RSEQ_ABI_CPU_ID_UNINITIALIZED
,
52 "rseq->cpu_id is set to RSEQ_ABI_CPU_ID_UNINITIALIZED (%d)",
53 (int32_t) rseq_abi
->cpu_id
);