summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp2
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp5
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp8
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h3
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp24
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp22
-rw-r--r--llvm/lib/Object/Object.cpp4
-rw-r--r--llvm/lib/Object/ObjectFile.cpp6
8 files changed, 34 insertions, 40 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 408214339a8..4316934df04 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -685,7 +685,7 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
}
SymAddr = *SymAddrOrErr;
// Also remember what section this symbol is in for later
- Sym->getSection(RSec);
+ RSec = *Sym->getSection();
} else if (auto *MObj = dyn_cast<MachOObjectFile>(&Obj)) {
// MachO also has relocations that point to sections and
// scattered relocations.
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index 24495b21d45..2ce337dc83d 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -164,8 +164,9 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
ErrorOr<StringRef> NameOrErr = I->getName();
Check(NameOrErr.getError());
StringRef Name = *NameOrErr;
- section_iterator SI = Obj.section_end();
- Check(I->getSection(SI));
+ ErrorOr<section_iterator> SIOrErr = I->getSection();
+ Check(SIOrErr.getError());
+ section_iterator SI = *SIOrErr;
if (SI == Obj.section_end())
continue;
uint64_t SectOffset;
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index a93c3d3098c..16612c146dd 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -845,8 +845,9 @@ void RuntimeDyldELF::findOPDEntrySection(const ELFObjectFileBase &Obj,
if (Rel.Addend != (int64_t)TargetSymbolOffset)
continue;
- section_iterator tsi(Obj.section_end());
- check(TargetSymbol->getSection(tsi));
+ ErrorOr<section_iterator> TSIOrErr = TargetSymbol->getSection();
+ check(TSIOrErr.getError());
+ section_iterator tsi = *TSIOrErr;
bool IsCode = tsi->isText();
Rel.SectionID = findOrEmitSection(Obj, (*tsi), IsCode, LocalSections);
Rel.Addend = (intptr_t)Addend;
@@ -1162,8 +1163,7 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
// TODO: Now ELF SymbolRef::ST_Debug = STT_SECTION, it's not obviously
// and can be changed by another developers. Maybe best way is add
// a new symbol type ST_Section to SymbolRef and use it.
- section_iterator si(Obj.section_end());
- Symbol->getSection(si);
+ section_iterator si = *Symbol->getSection();
if (si == Obj.section_end())
llvm_unreachable("Symbol section not found, bad object file format!");
DEBUG(dbgs() << "\t\tThis is section symbol\n");
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
index 408227eb0f2..8b7d06930a1 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
@@ -119,8 +119,7 @@ public:
symbol_iterator Symbol = RelI->getSymbol();
if (Symbol == Obj.symbol_end())
report_fatal_error("Unknown symbol in relocation");
- section_iterator SecI(Obj.section_end());
- Symbol->getSection(SecI);
+ section_iterator SecI = *Symbol->getSection();
// If there is no section, this must be an external reference.
const bool IsExtern = SecI == Obj.section_end();
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index fa6aa4ced39..d3f604a8d35 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -238,21 +238,17 @@ uint64_t COFFObjectFile::getCommonSymbolSizeImpl(DataRefImpl Ref) const {
return Symb.getValue();
}
-std::error_code
-COFFObjectFile::getSymbolSection(DataRefImpl Ref,
- section_iterator &Result) const {
+ErrorOr<section_iterator>
+COFFObjectFile::getSymbolSection(DataRefImpl Ref) const {
COFFSymbolRef Symb = getCOFFSymbol(Ref);
- if (COFF::isReservedSectionNumber(Symb.getSectionNumber())) {
- Result = section_end();
- } else {
- const coff_section *Sec = nullptr;
- if (std::error_code EC = getSection(Symb.getSectionNumber(), Sec))
- return EC;
- DataRefImpl Ref;
- Ref.p = reinterpret_cast<uintptr_t>(Sec);
- Result = section_iterator(SectionRef(Ref, this));
- }
- return std::error_code();
+ if (COFF::isReservedSectionNumber(Symb.getSectionNumber()))
+ return section_end();
+ const coff_section *Sec = nullptr;
+ if (std::error_code EC = getSection(Symb.getSectionNumber(), Sec))
+ return EC;
+ DataRefImpl Ret;
+ Ret.p = reinterpret_cast<uintptr_t>(Sec);
+ return section_iterator(SectionRef(Ret, this));
}
unsigned COFFObjectFile::getSymbolSectionID(SymbolRef Sym) const {
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 05900630c75..d1faf7be3af 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -445,22 +445,18 @@ uint32_t MachOObjectFile::getSymbolFlags(DataRefImpl DRI) const {
return Result;
}
-std::error_code MachOObjectFile::getSymbolSection(DataRefImpl Symb,
- section_iterator &Res) const {
+ErrorOr<section_iterator>
+MachOObjectFile::getSymbolSection(DataRefImpl Symb) const {
MachO::nlist_base Entry = getSymbolTableEntryBase(this, Symb);
uint8_t index = Entry.n_sect;
- if (index == 0) {
- Res = section_end();
- } else {
- DataRefImpl DRI;
- DRI.d.a = index - 1;
- if (DRI.d.a >= Sections.size())
- report_fatal_error("getSymbolSection: Invalid section index.");
- Res = section_iterator(SectionRef(DRI, this));
- }
-
- return std::error_code();
+ if (index == 0)
+ return section_end();
+ DataRefImpl DRI;
+ DRI.d.a = index - 1;
+ if (DRI.d.a >= Sections.size())
+ report_fatal_error("getSymbolSection: Invalid section index.");
+ return section_iterator(SectionRef(DRI, this));
}
unsigned MachOObjectFile::getSymbolSectionID(SymbolRef Sym) const {
diff --git a/llvm/lib/Object/Object.cpp b/llvm/lib/Object/Object.cpp
index 5c4b7a67b2a..b44c1a16fd0 100644
--- a/llvm/lib/Object/Object.cpp
+++ b/llvm/lib/Object/Object.cpp
@@ -98,8 +98,10 @@ void LLVMMoveToNextSection(LLVMSectionIteratorRef SI) {
void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect,
LLVMSymbolIteratorRef Sym) {
- if (std::error_code ec = (*unwrap(Sym))->getSection(*unwrap(Sect)))
+ ErrorOr<section_iterator> SecOrErr = (*unwrap(Sym))->getSection();
+ if (std::error_code ec = SecOrErr.getError())
report_fatal_error(ec.message());
+ *unwrap(Sect) = *SecOrErr;
}
// ObjectFile Symbol iterators
diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp
index f82edae89bc..d12dc411361 100644
--- a/llvm/lib/Object/ObjectFile.cpp
+++ b/llvm/lib/Object/ObjectFile.cpp
@@ -29,10 +29,10 @@ ObjectFile::ObjectFile(unsigned int Type, MemoryBufferRef Source)
: SymbolicFile(Type, Source) {}
bool SectionRef::containsSymbol(SymbolRef S) const {
- section_iterator SymSec = getObject()->section_end();
- if (S.getSection(SymSec))
+ ErrorOr<section_iterator> SymSec = S.getSection();
+ if (!SymSec)
return false;
- return *this == *SymSec;
+ return *this == **SymSec;
}
uint64_t ObjectFile::getSymbolValue(DataRefImpl Ref) const {
OpenPOWER on IntegriCloud