[llvm] [JITLink][AArch32] Unittest for error paths of readAddend and applyFixup functionality (PR #69636)
Eymen Ünay via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 10:48:54 PST 2023
https://github.com/eymay updated https://github.com/llvm/llvm-project/pull/69636
>From 7bc32c17c3fef33f1cbbf4b9324350c8f03d315b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Thu, 19 Oct 2023 22:38:05 +0300
Subject: [PATCH 01/10] [JITLink][AArch32] Unittest for error paths of
readAddend functionality
This commit is part of an effort to increase coverage of AArch32 backend.
---
.../ExecutionEngine/JITLink/AArch32Tests.cpp | 94 +++++++++++++++++++
1 file changed, 94 insertions(+)
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
index dcc8d3b237ff318..1df59edcd769407 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
@@ -9,6 +9,7 @@
#include <llvm/BinaryFormat/ELF.h>
#include <llvm/ExecutionEngine/JITLink/aarch32.h>
+#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
using namespace llvm;
@@ -67,6 +68,99 @@ TEST(AArch32_ELF, EdgeKinds) {
}
}
+struct ThumbRelocation {
+ /// Create a read-only reference to a Thumb32 fixup.
+ ThumbRelocation(const char *FixupPtr)
+ : Hi{*reinterpret_cast<const support::ulittle16_t *>(FixupPtr)},
+ Lo{*reinterpret_cast<const support::ulittle16_t *>(FixupPtr + 2)} {}
+
+ const support::ulittle16_t &Hi; // First halfword
+ const support::ulittle16_t &Lo; // Second halfword
+};
+
+struct ArmRelocation {
+
+ ArmRelocation(const char *FixupPtr)
+ : Wd{*reinterpret_cast<const support::ulittle32_t *>(FixupPtr)} {}
+
+ const support::ulittle32_t &Wd;
+};
+
+std::string makeUnexpectedOpcodeError(const LinkGraph &G,
+ const ThumbRelocation &R,
+ Edge::Kind Kind) {
+ return formatv("Invalid opcode [ {0:x4}, {1:x4} ] for relocation: {2}",
+ static_cast<uint16_t>(R.Hi), static_cast<uint16_t>(R.Lo),
+ G.getEdgeKindName(Kind));
+}
+
+std::string makeUnexpectedOpcodeError(const LinkGraph &G,
+ const ArmRelocation &R, Edge::Kind Kind) {
+ return formatv("Invalid opcode {0:x8} for relocation: {1}",
+ static_cast<uint32_t>(R.Wd), G.getEdgeKindName(Kind));
+}
+
+TEST(AArch32_ELF, readAddends) {
+ auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"), 4,
+ llvm::endianness::little,
+ getGenericEdgeKindName);
+
+ ArrayRef<char> Content = "hello, world!";
+ auto &Sec =
+ G->createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
+ orc::ExecutorAddr B1Addr(0x1000);
+ auto &B = G->createContentBlock(Sec, Content, B1Addr, 4, 0);
+
+ Symbol &TargetSymbol = G->addAnonymousSymbol(B, 0, 4, false, false);
+ Edge InvalidEdge(FirstDataRelocation - 1, 0, TargetSymbol, 0);
+
+ auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
+
+ auto makeReadAddendError = [](LinkGraph &G, Block &B, Edge &E) {
+ return ("In graph " + G.getName() + ", section " +
+ B.getSection().getName() +
+ " can not read implicit addend for aarch32 edge kind " +
+ G.getEdgeKindName(E.getKind()))
+ .str();
+ };
+
+ EXPECT_THAT_EXPECTED(
+ readAddend(*G, B, InvalidEdge, ArmCfg),
+ FailedWithMessage(makeReadAddendError(*G, B, InvalidEdge)));
+
+ ArmRelocation R_Arm(B.getContent().data());
+ ThumbRelocation R_Thumb(B.getContent().data());
+
+ for (Edge::Kind K = FirstDataRelocation; K < LastDataRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_EXPECTED(readAddendData(*G, B, E), Succeeded());
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ }
+ for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(
+ readAddendArm(*G, B, E),
+ FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Arm, K)));
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ }
+ for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(
+ readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Thumb, K)));
+ }
+}
+
namespace llvm {
namespace jitlink {
namespace aarch32 {
>From 482d8d7572f83248b6e7d3c471aa9747689f41c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Wed, 25 Oct 2023 13:03:53 +0300
Subject: [PATCH 02/10] Move test to another file
---
.../JITLink/AArch32ErrorTests.cpp | 112 ++++++++++++++++++
.../ExecutionEngine/JITLink/AArch32Tests.cpp | 92 --------------
.../ExecutionEngine/JITLink/CMakeLists.txt | 1 +
3 files changed, 113 insertions(+), 92 deletions(-)
create mode 100644 llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
new file mode 100644
index 000000000000000..0a1155443345c3e
--- /dev/null
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
@@ -0,0 +1,112 @@
+//===------- AArch32ErrorTests.cpp - Unit tests for AArch32 error handling -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <llvm/ExecutionEngine/JITLink/aarch32.h>
+
+
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace llvm::jitlink;
+using namespace llvm::jitlink::aarch32;
+using namespace llvm::support;
+using namespace llvm::support::endian;
+
+struct ThumbRelocation {
+ /// Create a read-only reference to a Thumb32 fixup.
+ ThumbRelocation(const char *FixupPtr)
+ : Hi{*reinterpret_cast<const support::ulittle16_t *>(FixupPtr)},
+ Lo{*reinterpret_cast<const support::ulittle16_t *>(FixupPtr + 2)} {}
+
+ const support::ulittle16_t &Hi; // First halfword
+ const support::ulittle16_t &Lo; // Second halfword
+};
+
+struct ArmRelocation {
+
+ ArmRelocation(const char *FixupPtr)
+ : Wd{*reinterpret_cast<const support::ulittle32_t *>(FixupPtr)} {}
+
+ const support::ulittle32_t &Wd;
+};
+
+std::string makeUnexpectedOpcodeError(const LinkGraph &G,
+ const ThumbRelocation &R,
+ Edge::Kind Kind) {
+ return formatv("Invalid opcode [ {0:x4}, {1:x4} ] for relocation: {2}",
+ static_cast<uint16_t>(R.Hi), static_cast<uint16_t>(R.Lo),
+ G.getEdgeKindName(Kind));
+}
+
+std::string makeUnexpectedOpcodeError(const LinkGraph &G,
+ const ArmRelocation &R, Edge::Kind Kind) {
+ return formatv("Invalid opcode {0:x8} for relocation: {1}",
+ static_cast<uint32_t>(R.Wd), G.getEdgeKindName(Kind));
+}
+
+TEST(AArch32_ELF, readAddends) {
+ auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"), 4,
+ llvm::endianness::little,
+ getGenericEdgeKindName);
+
+ ArrayRef<char> Content = "hello, world!";
+ auto &Sec =
+ G->createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
+ orc::ExecutorAddr B1Addr(0x1000);
+ auto &B = G->createContentBlock(Sec, Content, B1Addr, 4, 0);
+
+ Symbol &TargetSymbol = G->addAnonymousSymbol(B, 0, 4, false, false);
+ Edge InvalidEdge(FirstDataRelocation - 1, 0, TargetSymbol, 0);
+
+ auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
+
+ auto makeReadAddendError = [](LinkGraph &G, Block &B, Edge &E) {
+ return ("In graph " + G.getName() + ", section " +
+ B.getSection().getName() +
+ " can not read implicit addend for aarch32 edge kind " +
+ G.getEdgeKindName(E.getKind()))
+ .str();
+ };
+
+ EXPECT_THAT_EXPECTED(
+ readAddend(*G, B, InvalidEdge, ArmCfg),
+ FailedWithMessage(makeReadAddendError(*G, B, InvalidEdge)));
+
+ ArmRelocation R_Arm(B.getContent().data());
+ ThumbRelocation R_Thumb(B.getContent().data());
+
+ for (Edge::Kind K = FirstDataRelocation; K < LastDataRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_EXPECTED(readAddendData(*G, B, E), Succeeded());
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ }
+ for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(
+ readAddendArm(*G, B, E),
+ FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Arm, K)));
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ }
+ for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(
+ readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Thumb, K)));
+ }
+}
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
index 1df59edcd769407..5bcfb85ac44bfb5 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
@@ -68,98 +68,6 @@ TEST(AArch32_ELF, EdgeKinds) {
}
}
-struct ThumbRelocation {
- /// Create a read-only reference to a Thumb32 fixup.
- ThumbRelocation(const char *FixupPtr)
- : Hi{*reinterpret_cast<const support::ulittle16_t *>(FixupPtr)},
- Lo{*reinterpret_cast<const support::ulittle16_t *>(FixupPtr + 2)} {}
-
- const support::ulittle16_t &Hi; // First halfword
- const support::ulittle16_t &Lo; // Second halfword
-};
-
-struct ArmRelocation {
-
- ArmRelocation(const char *FixupPtr)
- : Wd{*reinterpret_cast<const support::ulittle32_t *>(FixupPtr)} {}
-
- const support::ulittle32_t &Wd;
-};
-
-std::string makeUnexpectedOpcodeError(const LinkGraph &G,
- const ThumbRelocation &R,
- Edge::Kind Kind) {
- return formatv("Invalid opcode [ {0:x4}, {1:x4} ] for relocation: {2}",
- static_cast<uint16_t>(R.Hi), static_cast<uint16_t>(R.Lo),
- G.getEdgeKindName(Kind));
-}
-
-std::string makeUnexpectedOpcodeError(const LinkGraph &G,
- const ArmRelocation &R, Edge::Kind Kind) {
- return formatv("Invalid opcode {0:x8} for relocation: {1}",
- static_cast<uint32_t>(R.Wd), G.getEdgeKindName(Kind));
-}
-
-TEST(AArch32_ELF, readAddends) {
- auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"), 4,
- llvm::endianness::little,
- getGenericEdgeKindName);
-
- ArrayRef<char> Content = "hello, world!";
- auto &Sec =
- G->createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
- orc::ExecutorAddr B1Addr(0x1000);
- auto &B = G->createContentBlock(Sec, Content, B1Addr, 4, 0);
-
- Symbol &TargetSymbol = G->addAnonymousSymbol(B, 0, 4, false, false);
- Edge InvalidEdge(FirstDataRelocation - 1, 0, TargetSymbol, 0);
-
- auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
-
- auto makeReadAddendError = [](LinkGraph &G, Block &B, Edge &E) {
- return ("In graph " + G.getName() + ", section " +
- B.getSection().getName() +
- " can not read implicit addend for aarch32 edge kind " +
- G.getEdgeKindName(E.getKind()))
- .str();
- };
-
- EXPECT_THAT_EXPECTED(
- readAddend(*G, B, InvalidEdge, ArmCfg),
- FailedWithMessage(makeReadAddendError(*G, B, InvalidEdge)));
-
- ArmRelocation R_Arm(B.getContent().data());
- ThumbRelocation R_Thumb(B.getContent().data());
-
- for (Edge::Kind K = FirstDataRelocation; K < LastDataRelocation; K += 1) {
- Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(readAddendData(*G, B, E), Succeeded());
- EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
- }
- for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
- Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
- EXPECT_THAT_EXPECTED(
- readAddendArm(*G, B, E),
- FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Arm, K)));
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
- }
- for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
- Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
- EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
- EXPECT_THAT_EXPECTED(
- readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Thumb, K)));
- }
-}
namespace llvm {
namespace jitlink {
diff --git a/llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt b/llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt
index e535bcf47fc801e..d4886754f0a9ca4 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt
+++ b/llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt
@@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
add_llvm_unittest(JITLinkTests
AArch32Tests.cpp
+ AArch32ErrorTests.cpp
EHFrameSupportTests.cpp
JITLinkMocks.cpp
LinkGraphTests.cpp
>From dea3d426cc43e859ec4bd3c604757d1f6bc45b90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Wed, 25 Oct 2023 16:39:43 +0300
Subject: [PATCH 03/10] replace Error functions with string matchers
---
.../JITLink/AArch32ErrorTests.cpp | 59 ++++---------------
1 file changed, 10 insertions(+), 49 deletions(-)
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
index 0a1155443345c3e..47b6b1c9d469746 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
@@ -18,37 +18,6 @@ using namespace llvm::jitlink::aarch32;
using namespace llvm::support;
using namespace llvm::support::endian;
-struct ThumbRelocation {
- /// Create a read-only reference to a Thumb32 fixup.
- ThumbRelocation(const char *FixupPtr)
- : Hi{*reinterpret_cast<const support::ulittle16_t *>(FixupPtr)},
- Lo{*reinterpret_cast<const support::ulittle16_t *>(FixupPtr + 2)} {}
-
- const support::ulittle16_t &Hi; // First halfword
- const support::ulittle16_t &Lo; // Second halfword
-};
-
-struct ArmRelocation {
-
- ArmRelocation(const char *FixupPtr)
- : Wd{*reinterpret_cast<const support::ulittle32_t *>(FixupPtr)} {}
-
- const support::ulittle32_t &Wd;
-};
-
-std::string makeUnexpectedOpcodeError(const LinkGraph &G,
- const ThumbRelocation &R,
- Edge::Kind Kind) {
- return formatv("Invalid opcode [ {0:x4}, {1:x4} ] for relocation: {2}",
- static_cast<uint16_t>(R.Hi), static_cast<uint16_t>(R.Lo),
- G.getEdgeKindName(Kind));
-}
-
-std::string makeUnexpectedOpcodeError(const LinkGraph &G,
- const ArmRelocation &R, Edge::Kind Kind) {
- return formatv("Invalid opcode {0:x8} for relocation: {1}",
- static_cast<uint32_t>(R.Wd), G.getEdgeKindName(Kind));
-}
TEST(AArch32_ELF, readAddends) {
auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"), 4,
@@ -66,47 +35,39 @@ TEST(AArch32_ELF, readAddends) {
auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
- auto makeReadAddendError = [](LinkGraph &G, Block &B, Edge &E) {
- return ("In graph " + G.getName() + ", section " +
- B.getSection().getName() +
- " can not read implicit addend for aarch32 edge kind " +
- G.getEdgeKindName(E.getKind()))
- .str();
- };
EXPECT_THAT_EXPECTED(
readAddend(*G, B, InvalidEdge, ArmCfg),
- FailedWithMessage(makeReadAddendError(*G, B, InvalidEdge)));
+ FailedWithMessage(testing::HasSubstr("can not read implicit addend for aarch32 edge kind Keep-Alive")));
- ArmRelocation R_Arm(B.getContent().data());
- ThumbRelocation R_Thumb(B.getContent().data());
+ std::string ReadAddendError = "can not read implicit addend for aarch32 edge kind <Unrecognized edge kind>";
for (Edge::Kind K = FirstDataRelocation; K < LastDataRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_EXPECTED(readAddendData(*G, B, E), Succeeded());
EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
}
for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
EXPECT_THAT_EXPECTED(
readAddendArm(*G, B, E),
- FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Arm, K)));
+ FailedWithMessage(testing::StartsWith("Invalid opcode")));
EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
}
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
- FailedWithMessage(makeReadAddendError(*G, B, E)));
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
EXPECT_THAT_EXPECTED(
readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Thumb, K)));
+ FailedWithMessage(testing::StartsWith("Invalid opcode")));
}
}
>From b9b7656e61dce4f7a7d7127cc24d28550cf54e0b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Wed, 25 Oct 2023 18:29:00 +0300
Subject: [PATCH 04/10] Add applyFixup Error checking
---
.../JITLink/AArch32ErrorTests.cpp | 70 ++++++++++++++++---
.../ExecutionEngine/JITLink/AArch32Tests.cpp | 1 -
2 files changed, 59 insertions(+), 12 deletions(-)
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
index 47b6b1c9d469746..1b784fd9297aeaf 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
@@ -1,4 +1,4 @@
-//===------- AArch32ErrorTests.cpp - Unit tests for AArch32 error handling -===//
+//===------- AArch32ErrorTests.cpp - Test AArch32 error handling ----------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,24 +18,23 @@ using namespace llvm::jitlink::aarch32;
using namespace llvm::support;
using namespace llvm::support::endian;
+auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"), 4,
+ llvm::endianness::little,
+ getGenericEdgeKindName);
+auto &Sec =
+ G->createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
+orc::ExecutorAddr B1Addr(0x1000);
-TEST(AArch32_ELF, readAddends) {
- auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"), 4,
- llvm::endianness::little,
- getGenericEdgeKindName);
+auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
+
+TEST(AArch32_ELF, readAddendErrors) {
ArrayRef<char> Content = "hello, world!";
- auto &Sec =
- G->createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
- orc::ExecutorAddr B1Addr(0x1000);
auto &B = G->createContentBlock(Sec, Content, B1Addr, 4, 0);
Symbol &TargetSymbol = G->addAnonymousSymbol(B, 0, 4, false, false);
Edge InvalidEdge(FirstDataRelocation - 1, 0, TargetSymbol, 0);
- auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
-
-
EXPECT_THAT_EXPECTED(
readAddend(*G, B, InvalidEdge, ArmCfg),
FailedWithMessage(testing::HasSubstr("can not read implicit addend for aarch32 edge kind Keep-Alive")));
@@ -71,3 +70,52 @@ TEST(AArch32_ELF, readAddends) {
FailedWithMessage(testing::StartsWith("Invalid opcode")));
}
}
+
+TEST(AArch32_ELF, applyFixupErrors) {
+ char ContentArray[] = "hello, world!";
+ MutableArrayRef<char> MutableContent(ContentArray);
+ auto &B = G->createMutableContentBlock(Sec, MutableContent, B1Addr, 4, 0);
+
+ Symbol &TargetSymbol = G->addAnonymousSymbol(B, 0, 4, false, false);
+ Edge InvalidEdge(FirstDataRelocation - 1, 0, TargetSymbol, 0);
+
+ EXPECT_THAT_ERROR(applyFixup(*G, B, InvalidEdge, ArmCfg),
+ FailedWithMessage(testing::HasSubstr(
+ "encountered unfixable aarch32 edge kind Keep-Alive")));
+
+ std::string UnfixableEdgeError =
+ "encountered unfixable aarch32 edge kind <Unrecognized edge kind>";
+
+ for (Edge::Kind K = FirstDataRelocation; K < LastDataRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_ERROR(applyFixupData(*G, B, E), Succeeded());
+ EXPECT_THAT_ERROR(
+ applyFixupArm(*G, B, E),
+ FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
+ EXPECT_THAT_ERROR(
+ applyFixupThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
+ }
+ for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_ERROR(
+ applyFixupData(*G, B, E),
+ FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
+ EXPECT_THAT_ERROR(applyFixupArm(*G, B, E),
+ FailedWithMessage(testing::StartsWith("Invalid opcode")));
+ EXPECT_THAT_ERROR(
+ applyFixupThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
+ }
+ for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_ERROR(
+ applyFixupData(*G, B, E),
+ FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
+ EXPECT_THAT_ERROR(
+ applyFixupArm(*G, B, E),
+ FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
+ EXPECT_THAT_ERROR(applyFixupThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(testing::StartsWith("Invalid opcode")));
+ }
+}
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
index 5bcfb85ac44bfb5..0ff1798fc73bb4e 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
@@ -68,7 +68,6 @@ TEST(AArch32_ELF, EdgeKinds) {
}
}
-
namespace llvm {
namespace jitlink {
namespace aarch32 {
>From b35fe801df9bd9d6d840bd23d511b2738ddd2d55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Wed, 25 Oct 2023 18:38:42 +0300
Subject: [PATCH 05/10] remove Error.h
---
llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
index 0ff1798fc73bb4e..dcc8d3b237ff318 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
@@ -9,7 +9,6 @@
#include <llvm/BinaryFormat/ELF.h>
#include <llvm/ExecutionEngine/JITLink/aarch32.h>
-#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
using namespace llvm;
>From 3ec0b2f15e8789ad6ae04c00c1b9c51b7e19da16 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Thu, 26 Oct 2023 10:44:08 +0300
Subject: [PATCH 06/10] clang-format whole file
---
.../JITLink/AArch32ErrorTests.cpp | 37 +++++++++++--------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
index 1b784fd9297aeaf..e06c223c37398d8 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
@@ -8,7 +8,6 @@
#include <llvm/ExecutionEngine/JITLink/aarch32.h>
-
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
@@ -37,34 +36,42 @@ TEST(AArch32_ELF, readAddendErrors) {
EXPECT_THAT_EXPECTED(
readAddend(*G, B, InvalidEdge, ArmCfg),
- FailedWithMessage(testing::HasSubstr("can not read implicit addend for aarch32 edge kind Keep-Alive")));
+ FailedWithMessage(testing::HasSubstr(
+ "can not read implicit addend for aarch32 edge kind Keep-Alive")));
- std::string ReadAddendError = "can not read implicit addend for aarch32 edge kind <Unrecognized edge kind>";
+ std::string ReadAddendError = "can not read implicit addend for aarch32 edge "
+ "kind <Unrecognized edge kind>";
for (Edge::Kind K = FirstDataRelocation; K < LastDataRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_EXPECTED(readAddendData(*G, B, E), Succeeded());
- EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
+ EXPECT_THAT_EXPECTED(
+ readAddendArm(*G, B, E),
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
+ EXPECT_THAT_EXPECTED(
+ readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
}
for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
+ EXPECT_THAT_EXPECTED(
+ readAddendData(*G, B, E),
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
EXPECT_THAT_EXPECTED(
readAddendArm(*G, B, E),
FailedWithMessage(testing::StartsWith("Invalid opcode")));
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
+ EXPECT_THAT_EXPECTED(
+ readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
}
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
- EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
+ EXPECT_THAT_EXPECTED(
+ readAddendData(*G, B, E),
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
+ EXPECT_THAT_EXPECTED(
+ readAddendArm(*G, B, E),
+ FailedWithMessage(testing::HasSubstr(ReadAddendError)));
EXPECT_THAT_EXPECTED(
readAddendThumb(*G, B, E, ArmCfg),
FailedWithMessage(testing::StartsWith("Invalid opcode")));
>From 4ec533374da5f154bf972c6189c82bf806365036 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Tue, 7 Nov 2023 09:41:29 +0300
Subject: [PATCH 07/10] Removed redundant checking and replaced magic numbers
with readable names
---
.../JITLink/AArch32ErrorTests.cpp | 131 ++++++++----------
1 file changed, 58 insertions(+), 73 deletions(-)
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
index e06c223c37398d8..de5e0a3f2947e14 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
@@ -17,61 +17,55 @@ using namespace llvm::jitlink::aarch32;
using namespace llvm::support;
using namespace llvm::support::endian;
-auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"), 4,
- llvm::endianness::little,
+constexpr unsigned PointerSize = 4;
+auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"),
+ PointerSize, llvm::endianness::little,
getGenericEdgeKindName);
auto &Sec =
G->createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
-orc::ExecutorAddr B1Addr(0x1000);
+orc::ExecutorAddr B1DummyAddr(0x1000);
auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
TEST(AArch32_ELF, readAddendErrors) {
+ // Permanently undefined instruction
+ // 11110:op:imm4:1:op1:imm12
+ // op = 1111111 Permanent undefined
+ // op1 = 010
+ ArrayRef<char> Content = "0xf7f0a000";
+ constexpr uint64_t Alignment = 4;
+ constexpr uint64_t AlignmentOffset = 0;
+ auto &B = G->createContentBlock(Sec, Content, B1DummyAddr, Alignment,
+ AlignmentOffset);
+ constexpr orc::ExecutorAddrDiff Offset = 0;
+ constexpr orc::ExecutorAddrDiff Size = 4;
+ Symbol &TargetSymbol = G->addAnonymousSymbol(B, Offset, Size, false, false);
+ Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
+ 0 /*Addend*/);
+
+ EXPECT_THAT_EXPECTED(readAddendData(*G, B, InvalidEdge),
+ FailedWithMessage(testing::HasSubstr(
+ "can not read implicit addend for aarch32 edge kind "
+ "INVALID RELOCATION")));
+
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, B, InvalidEdge),
+ FailedWithMessage(testing::HasSubstr(
+ "can not read implicit addend for aarch32 edge kind "
+ "INVALID RELOCATION")));
+
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, InvalidEdge, ArmCfg),
+ FailedWithMessage(testing::HasSubstr(
+ "can not read implicit addend for aarch32 edge kind "
+ "INVALID RELOCATION")));
- ArrayRef<char> Content = "hello, world!";
- auto &B = G->createContentBlock(Sec, Content, B1Addr, 4, 0);
-
- Symbol &TargetSymbol = G->addAnonymousSymbol(B, 0, 4, false, false);
- Edge InvalidEdge(FirstDataRelocation - 1, 0, TargetSymbol, 0);
-
- EXPECT_THAT_EXPECTED(
- readAddend(*G, B, InvalidEdge, ArmCfg),
- FailedWithMessage(testing::HasSubstr(
- "can not read implicit addend for aarch32 edge kind Keep-Alive")));
-
- std::string ReadAddendError = "can not read implicit addend for aarch32 edge "
- "kind <Unrecognized edge kind>";
-
- for (Edge::Kind K = FirstDataRelocation; K < LastDataRelocation; K += 1) {
- Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(readAddendData(*G, B, E), Succeeded());
- EXPECT_THAT_EXPECTED(
- readAddendArm(*G, B, E),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
- EXPECT_THAT_EXPECTED(
- readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
- }
for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(
- readAddendData(*G, B, E),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
EXPECT_THAT_EXPECTED(
readAddendArm(*G, B, E),
FailedWithMessage(testing::StartsWith("Invalid opcode")));
- EXPECT_THAT_EXPECTED(
- readAddendThumb(*G, B, E, ArmCfg),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
}
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(
- readAddendData(*G, B, E),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
- EXPECT_THAT_EXPECTED(
- readAddendArm(*G, B, E),
- FailedWithMessage(testing::HasSubstr(ReadAddendError)));
EXPECT_THAT_EXPECTED(
readAddendThumb(*G, B, E, ArmCfg),
FailedWithMessage(testing::StartsWith("Invalid opcode")));
@@ -79,49 +73,40 @@ TEST(AArch32_ELF, readAddendErrors) {
}
TEST(AArch32_ELF, applyFixupErrors) {
- char ContentArray[] = "hello, world!";
+ // Permanently undefined instruction
+ char ContentArray[] = "0xf7f0a000";
MutableArrayRef<char> MutableContent(ContentArray);
- auto &B = G->createMutableContentBlock(Sec, MutableContent, B1Addr, 4, 0);
-
- Symbol &TargetSymbol = G->addAnonymousSymbol(B, 0, 4, false, false);
- Edge InvalidEdge(FirstDataRelocation - 1, 0, TargetSymbol, 0);
-
- EXPECT_THAT_ERROR(applyFixup(*G, B, InvalidEdge, ArmCfg),
- FailedWithMessage(testing::HasSubstr(
- "encountered unfixable aarch32 edge kind Keep-Alive")));
-
- std::string UnfixableEdgeError =
- "encountered unfixable aarch32 edge kind <Unrecognized edge kind>";
+ constexpr uint64_t Alignment = 4;
+ constexpr uint64_t AlignmentOffset = 0;
+ auto &B = G->createMutableContentBlock(Sec, MutableContent, B1DummyAddr,
+ Alignment, AlignmentOffset);
+
+ constexpr orc::ExecutorAddrDiff Offset = 0;
+ constexpr orc::ExecutorAddrDiff Size = 4;
+ Symbol &TargetSymbol = G->addAnonymousSymbol(B, Offset, Size, false, false);
+ Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
+ 0 /*Addend*/);
+
+ EXPECT_THAT_ERROR(
+ applyFixupData(*G, B, InvalidEdge),
+ FailedWithMessage(testing::HasSubstr(
+ "encountered unfixable aarch32 edge kind INVALID RELOCATION")));
+ EXPECT_THAT_ERROR(
+ applyFixupArm(*G, B, InvalidEdge),
+ FailedWithMessage(testing::HasSubstr(
+ "encountered unfixable aarch32 edge kind INVALID RELOCATION")));
+ EXPECT_THAT_ERROR(
+ applyFixupThumb(*G, B, InvalidEdge, ArmCfg),
+ FailedWithMessage(testing::HasSubstr(
+ "encountered unfixable aarch32 edge kind INVALID RELOCATION")));
- for (Edge::Kind K = FirstDataRelocation; K < LastDataRelocation; K += 1) {
- Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_ERROR(applyFixupData(*G, B, E), Succeeded());
- EXPECT_THAT_ERROR(
- applyFixupArm(*G, B, E),
- FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
- EXPECT_THAT_ERROR(
- applyFixupThumb(*G, B, E, ArmCfg),
- FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
- }
for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_ERROR(
- applyFixupData(*G, B, E),
- FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
EXPECT_THAT_ERROR(applyFixupArm(*G, B, E),
FailedWithMessage(testing::StartsWith("Invalid opcode")));
- EXPECT_THAT_ERROR(
- applyFixupThumb(*G, B, E, ArmCfg),
- FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
}
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_ERROR(
- applyFixupData(*G, B, E),
- FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
- EXPECT_THAT_ERROR(
- applyFixupArm(*G, B, E),
- FailedWithMessage(testing::HasSubstr(UnfixableEdgeError)));
EXPECT_THAT_ERROR(applyFixupThumb(*G, B, E, ArmCfg),
FailedWithMessage(testing::StartsWith("Invalid opcode")));
}
>From 315b8fcb8b52c449e80af24103ef564332a29cd4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Tue, 7 Nov 2023 21:09:35 +0300
Subject: [PATCH 08/10] Add udf instruction to both Arm and Thumb
---
.../llvm/ExecutionEngine/JITLink/aarch32.h | 8 +-
.../JITLink/AArch32ErrorTests.cpp | 105 +++++++++++++-----
2 files changed, 84 insertions(+), 29 deletions(-)
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
index 3f36b53d6684a79..0f766ee63eeeaea 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
@@ -192,14 +192,14 @@ template <> struct FixupInfo<Arm_MovwAbsNC> : public FixupInfo<Arm_MovtAbs> {
};
template <> struct FixupInfo<Thumb_Jump24> {
- static constexpr HalfWords Opcode{0xf000, 0x8000};
- static constexpr HalfWords OpcodeMask{0xf800, 0x8000};
+ static constexpr HalfWords Opcode{0xf000, 0x9000};
+ static constexpr HalfWords OpcodeMask{0xf800, 0xd000};
static constexpr HalfWords ImmMask{0x07ff, 0x2fff};
};
template <> struct FixupInfo<Thumb_Call> {
- static constexpr HalfWords Opcode{0xf000, 0xc000};
- static constexpr HalfWords OpcodeMask{0xf800, 0xc000};
+ static constexpr HalfWords Opcode{0xf000, 0xd000};
+ static constexpr HalfWords OpcodeMask{0xf800, 0xd000};
static constexpr HalfWords ImmMask{0x07ff, 0x2fff};
static constexpr uint16_t LoBitH = 0x0001;
static constexpr uint16_t LoBitNoBlx = 0x1000;
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
index de5e0a3f2947e14..d155a3799036aeb 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
@@ -23,37 +23,57 @@ auto G = std::make_unique<LinkGraph>("foo", Triple("armv7-linux-gnueabi"),
getGenericEdgeKindName);
auto &Sec =
G->createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
-orc::ExecutorAddr B1DummyAddr(0x1000);
auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
TEST(AArch32_ELF, readAddendErrors) {
+
+ constexpr orc::ExecutorAddr B1DummyAddr(0x1000);
+ constexpr orc::ExecutorAddr B2DummyAddr(0x2000);
+
// Permanently undefined instruction
// 11110:op:imm4:1:op1:imm12
// op = 1111111 Permanent undefined
// op1 = 010
- ArrayRef<char> Content = "0xf7f0a000";
- constexpr uint64_t Alignment = 4;
+ uint8_t ArmWord[] = {0xf0, 0x00, 0xf0, 0xe7};
+ ArrayRef<char> ArmContent(reinterpret_cast<const char *>(&ArmWord),
+ sizeof(ArmWord));
+ // Permanently undefined instruction in Thumb
+ // udf #0
+ //
+ // 11110:op:imm4:1:op1:imm12
+ // op = 1111111 Permanent undefined
+ // op1 = 010
+ //
+ constexpr HalfWords ThumbHalfWords{0xf7f0, 0xa000};
+ ArrayRef<char> ThumbContent(reinterpret_cast<const char *>(&ThumbHalfWords),
+ sizeof(ThumbHalfWords));
+ constexpr uint64_t ArmAlignment = 4;
+ constexpr uint64_t ThumbAlignment = 2;
constexpr uint64_t AlignmentOffset = 0;
- auto &B = G->createContentBlock(Sec, Content, B1DummyAddr, Alignment,
- AlignmentOffset);
+ auto &BArm = G->createContentBlock(Sec, ArmContent, B1DummyAddr, ArmAlignment,
+ AlignmentOffset);
+ auto &BThumb = G->createContentBlock(Sec, ThumbContent, B2DummyAddr,
+ ThumbAlignment, AlignmentOffset);
constexpr orc::ExecutorAddrDiff Offset = 0;
constexpr orc::ExecutorAddrDiff Size = 4;
- Symbol &TargetSymbol = G->addAnonymousSymbol(B, Offset, Size, false, false);
+ Symbol &TargetSymbol =
+ G->addAnonymousSymbol(BArm, Offset, Size, false, false);
Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
0 /*Addend*/);
- EXPECT_THAT_EXPECTED(readAddendData(*G, B, InvalidEdge),
+ // Since invalid edge kind case is tested content of block is not significant
+ EXPECT_THAT_EXPECTED(readAddendData(*G, BArm, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
"can not read implicit addend for aarch32 edge kind "
"INVALID RELOCATION")));
- EXPECT_THAT_EXPECTED(readAddendArm(*G, B, InvalidEdge),
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, BArm, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
"can not read implicit addend for aarch32 edge kind "
"INVALID RELOCATION")));
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, InvalidEdge, ArmCfg),
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, BArm, InvalidEdge, ArmCfg),
FailedWithMessage(testing::HasSubstr(
"can not read implicit addend for aarch32 edge kind "
"INVALID RELOCATION")));
@@ -61,53 +81,88 @@ TEST(AArch32_ELF, readAddendErrors) {
for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_EXPECTED(
- readAddendArm(*G, B, E),
+ readAddendArm(*G, BArm, E),
FailedWithMessage(testing::StartsWith("Invalid opcode")));
}
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_EXPECTED(
- readAddendThumb(*G, B, E, ArmCfg),
+ readAddendThumb(*G, BThumb, E, ArmCfg),
FailedWithMessage(testing::StartsWith("Invalid opcode")));
}
}
TEST(AArch32_ELF, applyFixupErrors) {
- // Permanently undefined instruction
- char ContentArray[] = "0xf7f0a000";
- MutableArrayRef<char> MutableContent(ContentArray);
- constexpr uint64_t Alignment = 4;
+
+ struct MutableHalfWords {
+ constexpr MutableHalfWords(HalfWords Preset)
+ : Hi(Preset.Hi), Lo(Preset.Lo) {}
+
+ uint16_t Hi; // First halfword
+ uint16_t Lo; // Second halfword
+ };
+
+ constexpr orc::ExecutorAddr B3DummyAddr(0x5000);
+ constexpr orc::ExecutorAddr B4DummyAddr(0x6000);
+
+ // Permanently undefined instruction in ARM
+ // udf #0
+ uint8_t ArmWord[] = {0xf0, 0x00, 0xf0, 0xe7};
+ MutableArrayRef<char> MutableArmContent(reinterpret_cast<char *>(ArmWord),
+ sizeof(ArmWord));
+ // Permanently undefined instruction in Thumb
+ // udf #0
+ //
+ // 11110:op:imm4:1:op1:imm12
+ // op = 1111111 Permanent undefined
+ // op1 = 010
+ //
+ constexpr HalfWords ThumbHalfWords{0xf7f0, 0xa000};
+ MutableHalfWords MutableThumbHalfWords{ThumbHalfWords};
+ MutableArrayRef<char> MutableThumbContent(
+ reinterpret_cast<char *>(&MutableThumbHalfWords),
+ sizeof(MutableThumbHalfWords));
+ constexpr uint64_t ArmAlignment = 4;
+ constexpr uint64_t ThumbAlignment = 2;
constexpr uint64_t AlignmentOffset = 0;
- auto &B = G->createMutableContentBlock(Sec, MutableContent, B1DummyAddr,
- Alignment, AlignmentOffset);
+ auto &BArm = G->createMutableContentBlock(Sec, MutableArmContent, B3DummyAddr,
+ ArmAlignment, AlignmentOffset);
+ auto &BThumb = G->createMutableContentBlock(
+ Sec, MutableThumbContent, B4DummyAddr, ThumbAlignment, AlignmentOffset);
constexpr orc::ExecutorAddrDiff Offset = 0;
constexpr orc::ExecutorAddrDiff Size = 4;
- Symbol &TargetSymbol = G->addAnonymousSymbol(B, Offset, Size, false, false);
+ Symbol &TargetSymbol =
+ G->addAnonymousSymbol(BArm, Offset, Size, false, false);
Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
0 /*Addend*/);
+ // Since invalid edge kind case is tested content of block is not significant
EXPECT_THAT_ERROR(
- applyFixupData(*G, B, InvalidEdge),
+ applyFixupData(*G, BArm, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
"encountered unfixable aarch32 edge kind INVALID RELOCATION")));
EXPECT_THAT_ERROR(
- applyFixupArm(*G, B, InvalidEdge),
+ applyFixupArm(*G, BArm, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
"encountered unfixable aarch32 edge kind INVALID RELOCATION")));
EXPECT_THAT_ERROR(
- applyFixupThumb(*G, B, InvalidEdge, ArmCfg),
+ applyFixupThumb(*G, BArm, InvalidEdge, ArmCfg),
FailedWithMessage(testing::HasSubstr(
"encountered unfixable aarch32 edge kind INVALID RELOCATION")));
for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_ERROR(applyFixupArm(*G, B, E),
- FailedWithMessage(testing::StartsWith("Invalid opcode")));
+ EXPECT_THAT_ERROR(applyFixupArm(*G, BArm, E),
+ FailedWithMessage(testing::AllOf(
+ testing::StartsWith("Invalid opcode"),
+ testing::EndsWith(G->getEdgeKindName(K)))));
}
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_ERROR(applyFixupThumb(*G, B, E, ArmCfg),
- FailedWithMessage(testing::StartsWith("Invalid opcode")));
+ EXPECT_THAT_ERROR(applyFixupThumb(*G, BThumb, E, ArmCfg),
+ FailedWithMessage(testing::AllOf(
+ testing::StartsWith("Invalid opcode"),
+ testing::EndsWith(G->getEdgeKindName(K)))));
}
}
>From 38c2c6645c63f95e66b38107b9b1d98feff2844c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Wed, 8 Nov 2023 21:10:18 +0300
Subject: [PATCH 09/10] Fix jump24/call mask and split tests
---
.../llvm/ExecutionEngine/JITLink/aarch32.h | 6 +-
.../JITLink/AArch32ErrorTests.cpp | 142 ++++++++++++------
2 files changed, 95 insertions(+), 53 deletions(-)
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
index 0f766ee63eeeaea..207350e5baab2d5 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
@@ -193,13 +193,13 @@ template <> struct FixupInfo<Arm_MovwAbsNC> : public FixupInfo<Arm_MovtAbs> {
template <> struct FixupInfo<Thumb_Jump24> {
static constexpr HalfWords Opcode{0xf000, 0x9000};
- static constexpr HalfWords OpcodeMask{0xf800, 0xd000};
+ static constexpr HalfWords OpcodeMask{0xf800, 0x9000};
static constexpr HalfWords ImmMask{0x07ff, 0x2fff};
};
template <> struct FixupInfo<Thumb_Call> {
- static constexpr HalfWords Opcode{0xf000, 0xd000};
- static constexpr HalfWords OpcodeMask{0xf800, 0xd000};
+ static constexpr HalfWords Opcode{0xf000, 0xc000};
+ static constexpr HalfWords OpcodeMask{0xf800, 0xc000};
static constexpr HalfWords ImmMask{0x07ff, 0x2fff};
static constexpr uint16_t LoBitH = 0x0001;
static constexpr uint16_t LoBitNoBlx = 0x1000;
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
index d155a3799036aeb..fbf9c4ea15a51b7 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
@@ -26,18 +26,56 @@ auto &Sec =
auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
-TEST(AArch32_ELF, readAddendErrors) {
+constexpr uint64_t ArmAlignment = 4;
+constexpr uint64_t ThumbAlignment = 2;
+constexpr uint64_t AlignmentOffset = 0;
+
+constexpr orc::ExecutorAddrDiff SymbolOffset = 0;
+constexpr orc::ExecutorAddrDiff SymbolSize = 4;
+
+TEST(AArch32_ELF, readAddendArmErrors) {
constexpr orc::ExecutorAddr B1DummyAddr(0x1000);
- constexpr orc::ExecutorAddr B2DummyAddr(0x2000);
- // Permanently undefined instruction
- // 11110:op:imm4:1:op1:imm12
- // op = 1111111 Permanent undefined
- // op1 = 010
+ // Permanently undefined instruction in ARM
+ // udf #0
uint8_t ArmWord[] = {0xf0, 0x00, 0xf0, 0xe7};
ArrayRef<char> ArmContent(reinterpret_cast<const char *>(&ArmWord),
sizeof(ArmWord));
+ auto &BArm = G->createContentBlock(Sec, ArmContent, B1DummyAddr, ArmAlignment,
+ AlignmentOffset);
+ Symbol &TargetSymbol =
+ G->addAnonymousSymbol(BArm, SymbolOffset, SymbolSize, false, false);
+ Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
+ 0 /*Addend*/);
+
+ EXPECT_THAT_EXPECTED(readAddendData(*G, BArm, InvalidEdge),
+ FailedWithMessage(testing::HasSubstr(
+ "can not read implicit addend for aarch32 edge kind "
+ "INVALID RELOCATION")));
+
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, BArm, InvalidEdge),
+ FailedWithMessage(testing::HasSubstr(
+ "can not read implicit addend for aarch32 edge kind "
+ "INVALID RELOCATION")));
+
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, BArm, InvalidEdge, ArmCfg),
+ FailedWithMessage(testing::HasSubstr(
+ "can not read implicit addend for aarch32 edge kind "
+ "INVALID RELOCATION")));
+
+ for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_EXPECTED(
+ readAddendArm(*G, BArm, E),
+ FailedWithMessage(testing::StartsWith("Invalid opcode")));
+ }
+}
+
+TEST(AArch32_ELF, readAddendThumbErrors) {
+
+ constexpr orc::ExecutorAddr B2DummyAddr(0x2000);
+
// Permanently undefined instruction in Thumb
// udf #0
//
@@ -48,42 +86,28 @@ TEST(AArch32_ELF, readAddendErrors) {
constexpr HalfWords ThumbHalfWords{0xf7f0, 0xa000};
ArrayRef<char> ThumbContent(reinterpret_cast<const char *>(&ThumbHalfWords),
sizeof(ThumbHalfWords));
- constexpr uint64_t ArmAlignment = 4;
- constexpr uint64_t ThumbAlignment = 2;
- constexpr uint64_t AlignmentOffset = 0;
- auto &BArm = G->createContentBlock(Sec, ArmContent, B1DummyAddr, ArmAlignment,
- AlignmentOffset);
auto &BThumb = G->createContentBlock(Sec, ThumbContent, B2DummyAddr,
ThumbAlignment, AlignmentOffset);
- constexpr orc::ExecutorAddrDiff Offset = 0;
- constexpr orc::ExecutorAddrDiff Size = 4;
Symbol &TargetSymbol =
- G->addAnonymousSymbol(BArm, Offset, Size, false, false);
+ G->addAnonymousSymbol(BThumb, SymbolOffset, SymbolSize, false, false);
Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
0 /*Addend*/);
- // Since invalid edge kind case is tested content of block is not significant
- EXPECT_THAT_EXPECTED(readAddendData(*G, BArm, InvalidEdge),
+ EXPECT_THAT_EXPECTED(readAddendData(*G, BThumb, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
"can not read implicit addend for aarch32 edge kind "
"INVALID RELOCATION")));
- EXPECT_THAT_EXPECTED(readAddendArm(*G, BArm, InvalidEdge),
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, BThumb, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
"can not read implicit addend for aarch32 edge kind "
"INVALID RELOCATION")));
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, BArm, InvalidEdge, ArmCfg),
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, BThumb, InvalidEdge, ArmCfg),
FailedWithMessage(testing::HasSubstr(
"can not read implicit addend for aarch32 edge kind "
"INVALID RELOCATION")));
- for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
- Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(
- readAddendArm(*G, BArm, E),
- FailedWithMessage(testing::StartsWith("Invalid opcode")));
- }
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_EXPECTED(
@@ -92,7 +116,45 @@ TEST(AArch32_ELF, readAddendErrors) {
}
}
-TEST(AArch32_ELF, applyFixupErrors) {
+TEST(AArch32_ELF, applyFixupArmErrors) {
+
+ constexpr orc::ExecutorAddr B3DummyAddr(0x5000);
+
+ uint8_t ArmWord[] = {0xf0, 0x00, 0xf0, 0xe7};
+ MutableArrayRef<char> MutableArmContent(reinterpret_cast<char *>(ArmWord),
+ sizeof(ArmWord));
+
+ auto &BArm = G->createMutableContentBlock(Sec, MutableArmContent, B3DummyAddr,
+ ArmAlignment, AlignmentOffset);
+
+ Symbol &TargetSymbol =
+ G->addAnonymousSymbol(BArm, SymbolOffset, SymbolSize, false, false);
+ Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
+ 0 /*Addend*/);
+
+ EXPECT_THAT_ERROR(
+ applyFixupData(*G, BArm, InvalidEdge),
+ FailedWithMessage(testing::HasSubstr(
+ "encountered unfixable aarch32 edge kind INVALID RELOCATION")));
+ EXPECT_THAT_ERROR(
+ applyFixupArm(*G, BArm, InvalidEdge),
+ FailedWithMessage(testing::HasSubstr(
+ "encountered unfixable aarch32 edge kind INVALID RELOCATION")));
+ EXPECT_THAT_ERROR(
+ applyFixupThumb(*G, BArm, InvalidEdge, ArmCfg),
+ FailedWithMessage(testing::HasSubstr(
+ "encountered unfixable aarch32 edge kind INVALID RELOCATION")));
+
+ for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
+ Edge E(K, 0, TargetSymbol, 0);
+ EXPECT_THAT_ERROR(applyFixupArm(*G, BArm, E),
+ FailedWithMessage(testing::AllOf(
+ testing::StartsWith("Invalid opcode"),
+ testing::EndsWith(G->getEdgeKindName(K)))));
+ }
+}
+
+TEST(AArch32_ELF, applyFixupThumbErrors) {
struct MutableHalfWords {
constexpr MutableHalfWords(HalfWords Preset)
@@ -102,14 +164,8 @@ TEST(AArch32_ELF, applyFixupErrors) {
uint16_t Lo; // Second halfword
};
- constexpr orc::ExecutorAddr B3DummyAddr(0x5000);
constexpr orc::ExecutorAddr B4DummyAddr(0x6000);
- // Permanently undefined instruction in ARM
- // udf #0
- uint8_t ArmWord[] = {0xf0, 0x00, 0xf0, 0xe7};
- MutableArrayRef<char> MutableArmContent(reinterpret_cast<char *>(ArmWord),
- sizeof(ArmWord));
// Permanently undefined instruction in Thumb
// udf #0
//
@@ -122,42 +178,28 @@ TEST(AArch32_ELF, applyFixupErrors) {
MutableArrayRef<char> MutableThumbContent(
reinterpret_cast<char *>(&MutableThumbHalfWords),
sizeof(MutableThumbHalfWords));
- constexpr uint64_t ArmAlignment = 4;
- constexpr uint64_t ThumbAlignment = 2;
- constexpr uint64_t AlignmentOffset = 0;
- auto &BArm = G->createMutableContentBlock(Sec, MutableArmContent, B3DummyAddr,
- ArmAlignment, AlignmentOffset);
+
auto &BThumb = G->createMutableContentBlock(
Sec, MutableThumbContent, B4DummyAddr, ThumbAlignment, AlignmentOffset);
- constexpr orc::ExecutorAddrDiff Offset = 0;
- constexpr orc::ExecutorAddrDiff Size = 4;
Symbol &TargetSymbol =
- G->addAnonymousSymbol(BArm, Offset, Size, false, false);
+ G->addAnonymousSymbol(BThumb, SymbolOffset, SymbolSize, false, false);
Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
0 /*Addend*/);
- // Since invalid edge kind case is tested content of block is not significant
EXPECT_THAT_ERROR(
- applyFixupData(*G, BArm, InvalidEdge),
+ applyFixupData(*G, BThumb, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
"encountered unfixable aarch32 edge kind INVALID RELOCATION")));
EXPECT_THAT_ERROR(
- applyFixupArm(*G, BArm, InvalidEdge),
+ applyFixupArm(*G, BThumb, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
"encountered unfixable aarch32 edge kind INVALID RELOCATION")));
EXPECT_THAT_ERROR(
- applyFixupThumb(*G, BArm, InvalidEdge, ArmCfg),
+ applyFixupThumb(*G, BThumb, InvalidEdge, ArmCfg),
FailedWithMessage(testing::HasSubstr(
"encountered unfixable aarch32 edge kind INVALID RELOCATION")));
- for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
- Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_ERROR(applyFixupArm(*G, BArm, E),
- FailedWithMessage(testing::AllOf(
- testing::StartsWith("Invalid opcode"),
- testing::EndsWith(G->getEdgeKindName(K)))));
- }
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_ERROR(applyFixupThumb(*G, BThumb, E, ArmCfg),
>From 563d5e0c16b04402b4c2a84347d27f76d9756ab0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eymen=20=C3=9Cnay?= <eymenunay at outlook.com>
Date: Wed, 8 Nov 2023 21:47:49 +0300
Subject: [PATCH 10/10] Remove redundant test for thumb
---
.../JITLink/AArch32ErrorTests.cpp | 33 +++----------------
1 file changed, 4 insertions(+), 29 deletions(-)
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
index fbf9c4ea15a51b7..9a9468b46d5e5cb 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32ErrorTests.cpp
@@ -49,6 +49,8 @@ TEST(AArch32_ELF, readAddendArmErrors) {
Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
0 /*Addend*/);
+ // Edge kind is tested, block itself is not significant here. So it is tested
+ // once in Arm
EXPECT_THAT_EXPECTED(readAddendData(*G, BArm, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
"can not read implicit addend for aarch32 edge kind "
@@ -93,21 +95,6 @@ TEST(AArch32_ELF, readAddendThumbErrors) {
Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
0 /*Addend*/);
- EXPECT_THAT_EXPECTED(readAddendData(*G, BThumb, InvalidEdge),
- FailedWithMessage(testing::HasSubstr(
- "can not read implicit addend for aarch32 edge kind "
- "INVALID RELOCATION")));
-
- EXPECT_THAT_EXPECTED(readAddendArm(*G, BThumb, InvalidEdge),
- FailedWithMessage(testing::HasSubstr(
- "can not read implicit addend for aarch32 edge kind "
- "INVALID RELOCATION")));
-
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, BThumb, InvalidEdge, ArmCfg),
- FailedWithMessage(testing::HasSubstr(
- "can not read implicit addend for aarch32 edge kind "
- "INVALID RELOCATION")));
-
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_EXPECTED(
@@ -132,6 +119,8 @@ TEST(AArch32_ELF, applyFixupArmErrors) {
Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
0 /*Addend*/);
+ // Edge kind is tested, block itself is not significant here. So it is tested
+ // once in Arm
EXPECT_THAT_ERROR(
applyFixupData(*G, BArm, InvalidEdge),
FailedWithMessage(testing::HasSubstr(
@@ -181,25 +170,11 @@ TEST(AArch32_ELF, applyFixupThumbErrors) {
auto &BThumb = G->createMutableContentBlock(
Sec, MutableThumbContent, B4DummyAddr, ThumbAlignment, AlignmentOffset);
-
Symbol &TargetSymbol =
G->addAnonymousSymbol(BThumb, SymbolOffset, SymbolSize, false, false);
Edge InvalidEdge(Edge::GenericEdgeKind::Invalid, 0 /*Offset*/, TargetSymbol,
0 /*Addend*/);
- EXPECT_THAT_ERROR(
- applyFixupData(*G, BThumb, InvalidEdge),
- FailedWithMessage(testing::HasSubstr(
- "encountered unfixable aarch32 edge kind INVALID RELOCATION")));
- EXPECT_THAT_ERROR(
- applyFixupArm(*G, BThumb, InvalidEdge),
- FailedWithMessage(testing::HasSubstr(
- "encountered unfixable aarch32 edge kind INVALID RELOCATION")));
- EXPECT_THAT_ERROR(
- applyFixupThumb(*G, BThumb, InvalidEdge, ArmCfg),
- FailedWithMessage(testing::HasSubstr(
- "encountered unfixable aarch32 edge kind INVALID RELOCATION")));
-
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_ERROR(applyFixupThumb(*G, BThumb, E, ArmCfg),
More information about the llvm-commits
mailing list