Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 84c33c6

Browse files
committed
[RuntimeDyld] Add support for ELF R_ARM_REL32 and R_ARM_GOT_PREL.
Patch by William Dillon. Thanks William! This patch adds support for the R_ARM_REL32 and R_ARM_GOT_PREL ELF ARM relocations to RuntimeDyld, which should allow JITing of code that produces these relocations. No test case: Unfortunately RuntimeDyldELF's GOT building mechanism (which uses a separate section for GOT entries) isn't compatible with RuntimeDyldChecker. The correct fix for this is to fix RuntimeDyldELF's GOT support (it's fundamentally broken at the moment: separate sections aren't guaranteed to be in range of a GOT entry load), but that's a non-trivial job. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279182 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 0c6c3b2 commit 84c33c6

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.
@@ -1365,6 +1368,19 @@ RuntimeDyldELF::processRelocationRef(
13651368
RelType, 0);
13661369
Section.advanceStubOffset(getMaxStubSize());
13671370
}
1371+
} else if (RelType == ELF::R_ARM_GOT_PREL) {
1372+
uint32_t GOTOffset = allocateGOTEntries(SectionID, 1);
1373+
1374+
RelocationEntry GOTRE(SectionID, Offset, ELF::R_ARM_REL32, GOTOffset);
1375+
addRelocationForSection(GOTRE, GOTSectionID);
1376+
1377+
// Fill in the value of the symbol we're targeting into the GOT
1378+
RelocationEntry RE = computeGOTOffsetRE(SectionID, GOTOffset,
1379+
Value.Offset, ELF::R_ARM_ABS32);
1380+
if (Value.SymbolName)
1381+
addRelocationForSymbol(RE, Value.SymbolName);
1382+
else
1383+
addRelocationForSection(RE, Value.SectionID);
13681384
} else {
13691385
uint32_t *Placeholder =
13701386
reinterpret_cast<uint32_t*>(computePlaceholderAddress(SectionID, Offset));

0 commit comments

Comments
 (0)