Skip to content

Commit a05a98a

Browse files
[JITLink][AArch32] Implement ELF::R_ARM_ABS32 after we stopped skipping debug info sections
We create LinkGraph sections with NoAlloc lifetime now since f05ac80 This means we do process debug info sections now with all their relocations. That's ok for the moment.
1 parent 7e28a2c commit a05a98a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@ namespace aarch32 {
2727
enum EdgeKind_aarch32 : Edge::Kind {
2828

2929
///
30-
/// Relocations of class Data
30+
/// Relocations of class Data respect target endianness (unless otherwise
31+
/// specified)
3132
///
3233
FirstDataRelocation = Edge::FirstRelocation,
3334

34-
/// Plain 32-bit value relocation in target endianness
35+
/// Relative 32-bit value relocation
3536
Data_Delta32 = FirstDataRelocation,
3637

37-
LastDataRelocation = Data_Delta32,
38+
/// Absolute 32-bit value relocation
39+
Data_Pointer32,
40+
41+
LastDataRelocation = Data_Pointer32,
3842

3943
///
4044
/// Relocations of class Arm (covers fixed-width 4-byte instruction subset)

llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ namespace jitlink {
3434
/// Translate from ELF relocation type to JITLink-internal edge kind.
3535
Expected<aarch32::EdgeKind_aarch32> getJITLinkEdgeKind(uint32_t ELFType) {
3636
switch (ELFType) {
37+
case ELF::R_ARM_ABS32:
38+
return aarch32::Data_Pointer32;
3739
case ELF::R_ARM_REL32:
3840
return aarch32::Data_Delta32;
3941
case ELF::R_ARM_CALL:
@@ -58,6 +60,8 @@ Expected<uint32_t> getELFRelocationType(Edge::Kind Kind) {
5860
switch (static_cast<aarch32::EdgeKind_aarch32>(Kind)) {
5961
case aarch32::Data_Delta32:
6062
return ELF::R_ARM_REL32;
63+
case aarch32::Data_Pointer32:
64+
return ELF::R_ARM_ABS32;
6165
case aarch32::Arm_Call:
6266
return ELF::R_ARM_CALL;
6367
case aarch32::Thumb_Call:

llvm/lib/ExecutionEngine/JITLink/aarch32.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ Expected<int64_t> readAddendData(LinkGraph &G, Block &B, const Edge &E) {
200200

201201
switch (Kind) {
202202
case Data_Delta32:
203+
case Data_Pointer32:
203204
return SignExtend64<32>(support::endian::read32(FixupPtr, Endian));
204205
default:
205206
return make_error<JITLinkError>(
@@ -303,6 +304,13 @@ Error applyFixupData(LinkGraph &G, Block &B, const Edge &E) {
303304
Write32(Value);
304305
return Error::success();
305306
}
307+
case Data_Pointer32: {
308+
int64_t Value = TargetAddress + Addend;
309+
if (!isInt<32>(Value))
310+
return makeTargetOutOfRangeError(G, B, E);
311+
Write32(Value);
312+
return Error::success();
313+
}
306314
default:
307315
return make_error<JITLinkError>(
308316
"In graph " + G.getName() + ", section " + B.getSection().getName() +

0 commit comments

Comments
 (0)