diff options
author | Lang Hames <lhames@gmail.com> | 2018-05-09 01:38:13 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-05-09 01:38:13 +0000 |
commit | 3ae85708c96df313e79116a9207b03214df66386 (patch) | |
tree | 0211ed95462862dfa0cecf65550000dbe60ce2aa /llvm/lib/ExecutionEngine | |
parent | 6fe69b9212d7a59a943447b09563d46a0a03eb4b (diff) | |
download | bcm5719-llvm-3ae85708c96df313e79116a9207b03214df66386.tar.gz bcm5719-llvm-3ae85708c96df313e79116a9207b03214df66386.zip |
[RuntimeDyld][MachO] Properly handle thumb to thumb calls within a section.
Previously thumb bits were only checked for external relocations (thumb to arm
code and vice-versa). This patch adds detection for thumb callees in the same
section asthe (also thumb) caller.
The MachO/Thumb test case is updated to cover this, and redundant checks
(handled by the MachO/ARM test) are removed.
llvm-svn: 331838
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h index 990629de2f1..16a0f6ef2a7 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h @@ -47,6 +47,18 @@ public: return Addr; } + bool isAddrTargetThumb(unsigned SectionID, uint64_t Offset) { + auto TargetObjAddr = Sections[SectionID].getObjAddress() + Offset; + for (auto &KV : GlobalSymbolTable) { + auto &Entry = KV.second; + auto SymbolObjAddr = + Sections[Entry.getSectionID()].getObjAddress() + Entry.getOffset(); + if (TargetObjAddr == SymbolObjAddr) + return (Entry.getFlags().getTargetFlags() & ARMJITSymbolFlags::Thumb); + } + return false; + } + Expected<int64_t> decodeAddend(const RelocationEntry &RE) const { const SectionEntry &Section = Sections[RE.SectionID]; uint8_t *LocalAddress = Section.getAddressWithOffset(RE.Offset); @@ -161,12 +173,18 @@ public: // the value as being a thumb stub: we don't want to mix it up with an ARM // stub targeting the same function. if (RE.RelType == MachO::ARM_THUMB_RELOC_BR22) - Value.IsStubThumb = TargetIsLocalThumbFunc; + Value.IsStubThumb = true; if (RE.IsPCRel) makeValueAddendPCRel(Value, RelI, (RE.RelType == MachO::ARM_THUMB_RELOC_BR22) ? 4 : 8); + // If this is a non-external branch target check whether Value points to a + // thumb func. + if (!Value.SymbolName && (RelType == MachO::ARM_RELOC_BR24 || + RelType == MachO::ARM_THUMB_RELOC_BR22)) + RE.IsTargetThumbFunc = isAddrTargetThumb(Value.SectionID, Value.Offset); + if (RE.RelType == MachO::ARM_RELOC_BR24 || RE.RelType == MachO::ARM_THUMB_RELOC_BR22) processBranchRelocation(RE, Value, Stubs); |