From: Michael Jeanson Date: Wed, 31 Jul 2024 18:30:07 +0000 (-0400) Subject: Add dummy TLS variable to rseq_offset tests X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=21e4133660f47873df59aceb8814ab496102e64a;p=librseq.git Add dummy TLS variable to rseq_offset tests Ensure the main executable has at least one TLS variable which will be allocated before the rseq area, making sure the rseq_offset is not 0. This allows testing that the rseq_offset variable is properly initialized by checking it is not 0. Most toolchains will add at least one main exec TLS variable but it's currently not the case on RISC-V. Change-Id: I1c50640c4f32ea5ef65b0b823e7be75fd92b303d Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/basic_test.c b/tests/basic_test.c index fcde879..6cbd732 100644 --- a/tests/basic_test.c +++ b/tests/basic_test.c @@ -18,6 +18,17 @@ #include "tap.h" +/* + * Ensure the main executable has at least one TLS variable which will be + * allocated before the rseq area, making sure the rseq_offset is not 0. This + * allows testing that the rseq_offset variable is properly initialized by + * checking it is not 0. + * + * Most toolchains will add at least one main exec TLS variable but it's + * currently not the case on RISC-V. + */ +__thread int dummy_tls = -1; + static void test_registered(void) { struct rseq_abi *rseq_abi = rseq_get_abi(); diff --git a/tests/unregistered_test.c b/tests/unregistered_test.c index fc7c182..5aed17f 100644 --- a/tests/unregistered_test.c +++ b/tests/unregistered_test.c @@ -12,6 +12,17 @@ #define NR_TESTS 4 +/* + * Ensure the main executable has at least one TLS variable which will be + * allocated before the rseq area, making sure the rseq_offset is not 0. This + * allows testing that the rseq_offset variable is properly initialized by + * checking it is not 0. + * + * Most toolchains will add at least one main exec TLS variable but it's + * currently not the case on RISC-V. + */ +__thread int dummy_tls = -1; + /* * Check the state of the public symbols when the rseq syscall is available but * no thread has registered.