Add dummy TLS variable to rseq_offset tests
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 31 Jul 2024 18:30:07 +0000 (14:30 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 31 Jul 2024 19:45:09 +0000 (15:45 -0400)
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 <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/basic_test.c
tests/unregistered_test.c

index fcde879bc29974634caf445a962e1328f6b301e4..6cbd73270c84f8601c6e8e7cd6559e1f7d329567 100644 (file)
 
 #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();
index fc7c18270d29ad7499d5116d13a4ce0e72607085..5aed17fc4019b4a4441696d410032c0e1c3dcd07 100644 (file)
 
 #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.
This page took 0.02431 seconds and 4 git commands to generate.