[llvm] 565470e - [JITLink][AArch32] Implement ELF relocation R_ARM_NONE
Stefan Gränitz via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 22 07:48:41 PST 2024
Author: Stefan Gränitz
Date: 2024-01-22T16:47:17+01:00
New Revision: 565470ed27131b2550e71cf334bf3f33f9d82c62
URL: https://github.com/llvm/llvm-project/commit/565470ed27131b2550e71cf334bf3f33f9d82c62
DIFF: https://github.com/llvm/llvm-project/commit/565470ed27131b2550e71cf334bf3f33f9d82c62.diff
LOG: [JITLink][AArch32] Implement ELF relocation R_ARM_NONE
Added:
Modified:
llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
llvm/test/ExecutionEngine/JITLink/AArch32/ELF_relocations_data.s
llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
index 938d25dc15bf2b6..081f77a85e182a7 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
@@ -101,7 +101,11 @@ enum EdgeKind_aarch32 : Edge::Kind {
Thumb_MovtPrel,
LastThumbRelocation = Thumb_MovtPrel,
- LastRelocation = LastThumbRelocation,
+
+ /// No-op relocation
+ None,
+
+ LastRelocation = None,
};
/// Flags enum for AArch32-specific symbol properties
@@ -293,7 +297,8 @@ inline Expected<int64_t> readAddend(LinkGraph &G, Block &B,
if (Kind <= LastThumbRelocation)
return readAddendThumb(G, B, Offset, Kind, ArmCfg);
- llvm_unreachable("Relocation must be of class Data, Arm or Thumb");
+ assert(Kind == None && "Not associated with a relocation class");
+ return 0;
}
/// Helper function to apply the fixup for Data-class relocations.
@@ -320,7 +325,8 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
if (Kind <= LastThumbRelocation)
return applyFixupThumb(G, B, E, ArmCfg);
- llvm_unreachable("Relocation must be of class Data, Arm or Thumb");
+ assert(Kind == None && "Not associated with a relocation class");
+ return Error::success();
}
/// Populate a Global Offset Table from edges that request it.
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
index ed7d58da2dc111e..15c209e1ebe5bf6 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
@@ -48,6 +48,8 @@ getJITLinkEdgeKind(uint32_t ELFType, const aarch32::ArmConfig &ArmCfg) {
return aarch32::Arm_MovwAbsNC;
case ELF::R_ARM_MOVT_ABS:
return aarch32::Arm_MovtAbs;
+ case ELF::R_ARM_NONE:
+ return aarch32::None;
case ELF::R_ARM_TARGET1:
return (ArmCfg.Target1Rel) ? aarch32::Data_Delta32
: aarch32::Data_Pointer32;
@@ -99,6 +101,8 @@ Expected<uint32_t> getELFRelocationType(Edge::Kind Kind) {
return ELF::R_ARM_THM_MOVW_PREL_NC;
case aarch32::Thumb_MovtPrel:
return ELF::R_ARM_THM_MOVT_PREL;
+ case aarch32::None:
+ return ELF::R_ARM_NONE;
}
return make_error<JITLinkError>(formatv("Invalid aarch32 edge {0:d}: ",
diff --git a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
index 111527a39e06ecd..1797a0068cd7cdc 100644
--- a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
@@ -766,6 +766,7 @@ const char *getEdgeKindName(Edge::Kind K) {
KIND_NAME_CASE(Thumb_MovtAbs)
KIND_NAME_CASE(Thumb_MovwPrelNC)
KIND_NAME_CASE(Thumb_MovtPrel)
+ KIND_NAME_CASE(None)
default:
return getGenericEdgeKindName(K);
}
diff --git a/llvm/test/ExecutionEngine/JITLink/AArch32/ELF_relocations_data.s b/llvm/test/ExecutionEngine/JITLink/AArch32/ELF_relocations_data.s
index de25a82aff16bcf..7bd59f8a52de6d8 100644
--- a/llvm/test/ExecutionEngine/JITLink/AArch32/ELF_relocations_data.s
+++ b/llvm/test/ExecutionEngine/JITLink/AArch32/ELF_relocations_data.s
@@ -64,6 +64,30 @@ got_prel_offset:
.size got_prel_offset, .-got_prel_offset
.size got_prel, .-got_prel
+# EH personality routine
+# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_NONE __aeabi_unwind_cpp_pr0
+ .globl __aeabi_unwind_cpp_pr0
+ .type __aeabi_unwind_cpp_pr0,%function
+ .align 2
+__aeabi_unwind_cpp_pr0:
+ bx lr
+
+# Generate reference to EH personality (right now we ignore the resulting
+# R_ARM_PREL31 relocation since it's in .ARM.exidx)
+ .globl prel31
+ .type prel31,%function
+ .align 2
+prel31:
+ .fnstart
+ .save {r11, lr}
+ push {r11, lr}
+ .setfp r11, sp
+ mov r11, sp
+ pop {r11, lr}
+ mov pc, lr
+ .size prel31,.-prel31
+ .fnend
+
# This test is executable with any 4-byte external target:
# > echo "unsigned target = 42;" | clang -target armv7-linux-gnueabihf -o target.o -c -xc -
# > llvm-jitlink target.o armv7/out.o
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
index a08884e1c7f7f4f..b1890d884d1735e 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
@@ -49,7 +49,7 @@ Expected<uint32_t> getELFRelocationType(Edge::Kind Kind);
TEST(AArch32_ELF, EdgeKinds) {
// Fails: Invalid ELF type -> JITLink kind
aarch32::ArmConfig Cfg;
- Expected<uint32_t> ErrKind = getJITLinkEdgeKind(ELF::R_ARM_NONE, Cfg);
+ Expected<uint32_t> ErrKind = getJITLinkEdgeKind(ELF::R_ARM_ME_TOO, Cfg);
EXPECT_TRUE(errorToBool(ErrKind.takeError()));
// Fails: Invalid JITLink kind -> ELF type
More information about the llvm-commits
mailing list