Skip to content

Commit 27e1985

Browse files
weliveindetailtstellar
authored andcommitted
[llvm-jitlink] Fix detectStubKind() for big endian systems (llvm#79970)
This function is used in `jitlink-check` lines in LIT tests. In llvm#78371 I missed to swap initial instruction bytes for systems that store the constants as big-endian. (cherry picked from commit 8a5bdd8)
1 parent 8996dcf commit 27e1985

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/tools/llvm-jitlink/llvm-jitlink.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1294,10 +1294,11 @@ class MemoryMatcher {
12941294
};
12951295

12961296
static StringRef detectStubKind(const Session::MemoryRegionInfo &Stub) {
1297-
constexpr uint32_t Armv7MovWTle = 0xe300c000;
1298-
constexpr uint32_t Armv7BxR12le = 0xe12fff1c;
1299-
constexpr uint32_t Thumbv7MovWTle = 0x0c00f240;
1300-
constexpr uint16_t Thumbv7BxR12le = 0x4760;
1297+
using namespace support::endian;
1298+
auto Armv7MovWTle = byte_swap<uint32_t, endianness::little>(0xe300c000);
1299+
auto Armv7BxR12le = byte_swap<uint32_t, endianness::little>(0xe12fff1c);
1300+
auto Thumbv7MovWTle = byte_swap<uint32_t, endianness::little>(0x0c00f240);
1301+
auto Thumbv7BxR12le = byte_swap<uint16_t, endianness::little>(0x4760);
13011302

13021303
MemoryMatcher M(Stub.getContent());
13031304
if (M.matchMask(Thumbv7MovWTle)) {

0 commit comments

Comments
 (0)