diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-07-07 16:45:55 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-07-07 16:45:55 +0000 |
commit | ef888a4db60a8c1081169f8cf395d614623ec195 (patch) | |
tree | 9834528bcca29e023c75961e68893ecf3d35a2b8 /llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | |
parent | feb13e9e09b48f1f92c8310d806b4228d8e3ea22 (diff) | |
download | bcm5719-llvm-ef888a4db60a8c1081169f8cf395d614623ec195.tar.gz bcm5719-llvm-ef888a4db60a8c1081169f8cf395d614623ec195.zip |
Simplify by passing in the section of the symbol. NFC.
llvm-svn: 241603
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index 6851625b9e9..93287a3a4e7 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -113,29 +113,12 @@ void RuntimeDyldImpl::mapSectionAddress(const void *LocalAddress, llvm_unreachable("Attempting to remap address of unknown section!"); } -static std::error_code getOffset(const SymbolRef &Sym, uint64_t &Result) { +static std::error_code getOffset(const SymbolRef &Sym, SectionRef Sec, + uint64_t &Result) { ErrorOr<uint64_t> AddressOrErr = Sym.getAddress(); if (std::error_code EC = AddressOrErr.getError()) return EC; - uint64_t Address = *AddressOrErr; - - if (Address == UnknownAddress) { - Result = UnknownAddress; - return std::error_code(); - } - - const ObjectFile *Obj = Sym.getObject(); - section_iterator SecI(Obj->section_begin()); - if (std::error_code EC = Sym.getSection(SecI)) - return EC; - - if (SecI == Obj->section_end()) { - Result = UnknownAddress; - return std::error_code(); - } - - uint64_t SectionAddress = SecI->getAddress(); - Result = Address - SectionAddress; + Result = *AddressOrErr - Sec.getAddress(); return std::error_code(); } @@ -185,12 +168,12 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) { ErrorOr<StringRef> NameOrErr = I->getName(); Check(NameOrErr.getError()); StringRef Name = *NameOrErr; - uint64_t SectOffset; - Check(getOffset(*I, SectOffset)); section_iterator SI = Obj.section_end(); Check(I->getSection(SI)); if (SI == Obj.section_end()) continue; + uint64_t SectOffset; + Check(getOffset(*I, *SI, SectOffset)); StringRef SectionData; Check(SI->getContents(SectionData)); bool IsCode = SI->isText(); |