summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2015-04-22 21:38:37 +0000
committerLang Hames <lhames@gmail.com>2015-04-22 21:38:37 +0000
commit34cfa49b66906c8a090d9b5d121aa729b97c1aef (patch)
tree30c57ae3e6eefcb41ee3416e7a54c1dbdeba8162 /llvm/lib/ExecutionEngine
parentdc012fa26690bef5cd7b56e28bbbe9d1aa17349a (diff)
downloadbcm5719-llvm-34cfa49b66906c8a090d9b5d121aa729b97c1aef.tar.gz
bcm5719-llvm-34cfa49b66906c8a090d9b5d121aa729b97c1aef.zip
[RuntimeDyld][COFF] Add external symbol resolution support to RuntimeDyldCOFF.
Patch by Andy Ayers. Thanks Andy! llvm-svn: 235554
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h30
1 files changed, 16 insertions, 14 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
index cd534a12549..478665ea3d0 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
@@ -114,23 +114,15 @@ public:
const ObjectFile &Obj,
ObjSectionToIDMap &ObjSectionToID,
StubMap &Stubs) override {
- // Find the symbol referred to in the relocation, and
- // get its section and offset.
- //
- // Insist for now that all symbols be resolvable within
- // the scope of this object file.
+ // If possible, find the symbol referred to in the relocation,
+ // and the section that contains it.
symbol_iterator Symbol = RelI->getSymbol();
if (Symbol == Obj.symbol_end())
report_fatal_error("Unknown symbol in relocation");
- unsigned TargetSectionID = 0;
- uint64_t TargetOffset = UnknownAddressOrSize;
section_iterator SecI(Obj.section_end());
Symbol->getSection(SecI);
- if (SecI == Obj.section_end())
- report_fatal_error("Unknown section in relocation");
- bool IsCode = SecI->isText();
- TargetSectionID = findOrEmitSection(Obj, *SecI, IsCode, ObjSectionToID);
- TargetOffset = getSymbolOffset(*Symbol);
+ // If there is no section, this must be an external reference.
+ const bool IsExtern = SecI == Obj.section_end();
// Determine the Addend used to adjust the relocation value.
uint64_t RelType;
@@ -167,12 +159,22 @@ public:
StringRef TargetName;
Symbol->getName(TargetName);
+
DEBUG(dbgs() << "\t\tIn Section " << SectionID << " Offset " << Offset
<< " RelType: " << RelType << " TargetName: " << TargetName
<< " Addend " << Addend << "\n");
- RelocationEntry RE(SectionID, Offset, RelType, TargetOffset + Addend);
- addRelocationForSection(RE, TargetSectionID);
+ if (IsExtern) {
+ RelocationEntry RE(SectionID, Offset, RelType, Addend);
+ addRelocationForSymbol(RE, TargetName);
+ } else {
+ bool IsCode = SecI->isText();
+ unsigned TargetSectionID =
+ findOrEmitSection(Obj, *SecI, IsCode, ObjSectionToID);
+ uint64_t TargetOffset = getSymbolOffset(*Symbol);
+ RelocationEntry RE(SectionID, Offset, RelType, TargetOffset + Addend);
+ addRelocationForSection(RE, TargetSectionID);
+ }
return ++RelI;
}
OpenPOWER on IntegriCloud