[Unwind][AArch64] Match sigreturn instructions in big endian (#167139) Since insns are always stored LE, on a BE system the opcodes will be loaded byte-reversed. Therefore, define two sets of opcodes, one for LE and one for BE. NOKEYCHECK=True GitOrigin-RevId: 6214dccbc991abe5a1679bc88e74b8c7d53f3d45
diff --git a/src/UnwindCursor.hpp b/src/UnwindCursor.hpp index d734825..33fcd84 100644 --- a/src/UnwindCursor.hpp +++ b/src/UnwindCursor.hpp
@@ -2865,6 +2865,21 @@ #if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) && \ defined(_LIBUNWIND_TARGET_AARCH64) + +/* + * The linux sigreturn restorer stub will always have the form: + * + * d2801168 movz x8, #0x8b + * d4000001 svc #0x0 + */ +#if defined(__AARCH64EB__) +#define MOVZ_X8_8B 0x681180d2 +#define SVC_0 0x010000d4 +#else +#define MOVZ_X8_8B 0xd2801168 +#define SVC_0 0xd4000001 +#endif + template <typename A, typename R> bool UnwindCursor<A, R>::setInfoForSigReturn(Registers_arm64 &) { // Look for the sigreturn trampoline. The trampoline's body is two @@ -2889,7 +2904,7 @@ return false; auto *instructions = reinterpret_cast<const uint32_t *>(pc); // Look for instructions: mov x8, #0x8b; svc #0x0 - if (instructions[0] != 0xd2801168 || instructions[1] != 0xd4000001) + if (instructions[0] != MOVZ_X8_8B || instructions[1] != SVC_0) return false; _info = {};