Skip to content

Commit 0fd299e

Browse files
committed
Added support for ARM_REL32 and GOT_PREL
These changes add support for the R_ARM_REL32 type and R_ARM_GOT_PREL. They are required to provide JIT support to Swift which in turn supports interpret mode.
1 parent f54fa77 commit 0fd299e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ void RuntimeDyldELF::resolveARMRelocation(const SectionEntry &Section,
480480
*TargetPtr |= Value & 0xFFF;
481481
*TargetPtr |= ((Value >> 12) & 0xF) << 16;
482482
break;
483+
case ELF::R_ARM_REL32:
484+
*TargetPtr += Value - FinalAddress;
485+
break;
483486
// Write 24 bit relative value to the branch instruction.
484487
case ELF::R_ARM_PC24: // Fall through.
485488
case ELF::R_ARM_CALL: // Fall through.
@@ -1324,6 +1327,19 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
13241327
RelType, 0);
13251328
Section.advanceStubOffset(getMaxStubSize());
13261329
}
1330+
} else if (RelType == ELF::R_ARM_GOT_PREL) {
1331+
uint32_t GOTOffset = allocateGOTEntries(SectionID, 1);
1332+
1333+
RelocationEntry GOTRE(SectionID, Offset, ELF::R_ARM_REL32, GOTOffset);
1334+
addRelocationForSection(GOTRE, GOTSectionID);
1335+
1336+
// Fill in the value of the symbol we're targeting into the GOT
1337+
RelocationEntry RE = computeGOTOffsetRE(SectionID, GOTOffset,
1338+
Value.Offset, ELF::R_ARM_ABS32);
1339+
if (Value.SymbolName)
1340+
addRelocationForSymbol(RE, Value.SymbolName);
1341+
else
1342+
addRelocationForSection(RE, Value.SectionID);
13271343
} else {
13281344
uint32_t *Placeholder =
13291345
reinterpret_cast<uint32_t*>(computePlaceholderAddress(SectionID, Offset));

0 commit comments

Comments
 (0)