arm: Fix big endian, introduce RSEQ_ASM_U64_PTR
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 29 Feb 2024 14:22:28 +0000 (09:22 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 29 Feb 2024 14:36:46 +0000 (09:36 -0500)
Fix support for Big endian ARM by introducing RSEQ_ASM_U64_PTR.

This will allow moving __RSEQ_ASM_DEFINE_TABLE and
RSEQ_ASM_DEFINE_EXIT_POINT to a generic common header file.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6271f217b0e1463968bd7d520ddd0fb61678bb84

include/rseq/arch/arm.h

index 7b7e64d8d7d6b5d4e3a075e6693ab9cf9ade8e8b..1a6ad12c09aba522608189f6ae89f66f767ef83e 100644 (file)
@@ -99,6 +99,12 @@ do {                                                                 \
        RSEQ_WRITE_ONCE(*(p), v);                                       \
 } while (0)
 
+#ifdef __ARMEB__       /* Big endian */
+# define RSEQ_ASM_U64_PTR(x)           ".word 0x0, " x
+#else                  /* Little endian */
+# define RSEQ_ASM_U64_PTR(x)           ".word " x ", 0x0"
+#endif
+
 /* Only used in RSEQ_ASM_DEFINE_TABLE. */
 #define __RSEQ_ASM_DEFINE_TABLE(label, version, flags, start_ip,       \
                                post_commit_offset, abort_ip)           \
@@ -106,10 +112,12 @@ do {                                                                      \
                ".balign 32\n\t"                                        \
                __rseq_str(label) ":\n\t"                               \
                ".word " __rseq_str(version) ", " __rseq_str(flags) "\n\t" \
-               ".word " __rseq_str(start_ip) ", 0x0, " __rseq_str(post_commit_offset) ", 0x0, " __rseq_str(abort_ip) ", 0x0\n\t" \
+               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
+               RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n\t" \
+               RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n\t"           \
                ".popsection\n\t"                                       \
                ".pushsection __rseq_cs_ptr_array, \"aw\"\n\t"          \
-               ".word " __rseq_str(label) "b, 0x0\n\t"                 \
+               RSEQ_ASM_U64_PTR(__rseq_str(label) "b") "\n\t"          \
                ".popsection\n\t"
 
 /*
@@ -151,7 +159,8 @@ do {                                                                        \
  */
 #define RSEQ_ASM_DEFINE_EXIT_POINT(start_ip, exit_ip)                  \
                ".pushsection __rseq_exit_point_array, \"aw\"\n\t"      \
-               ".word " __rseq_str(start_ip) ", 0x0, " __rseq_str(exit_ip) ", 0x0\n\t" \
+               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
+               RSEQ_ASM_U64_PTR(__rseq_str(exit_ip)) "\n\t"            \
                ".popsection\n\t"
 
 /*
@@ -181,7 +190,9 @@ do {                                                                        \
                ".balign 32\n\t"                                        \
                __rseq_str(table_label) ":\n\t"                         \
                ".word " __rseq_str(version) ", " __rseq_str(flags) "\n\t" \
-               ".word " __rseq_str(start_ip) ", 0x0, " __rseq_str(post_commit_offset) ", 0x0, " __rseq_str(abort_ip) ", 0x0\n\t" \
+               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
+               RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n\t" \
+               RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n\t"           \
                ".word " __rseq_str(RSEQ_SIG) "\n\t"                    \
                __rseq_str(label) ":\n\t"                               \
                teardown                                                \
This page took 0.027035 seconds and 4 git commands to generate.