mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-24 13:18:17 +00:00
Remove bogus std::error_code returns form SectionRef.
There are two methods in SectionRef that can fail: * getName: The index into the string table can be invalid. * getContents: The section might point to invalid contents. Every other method will always succeed and returning and std::error_code just complicates the code. For example, a section can have an invalid alignment, but if we are able to get to the section structure at all and create a SectionRef, we will always be able to read that invalid alignment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219314 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -134,10 +134,7 @@ static std::error_code getOffset(const SymbolRef &Sym, uint64_t &Result) {
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
uint64_t SectionAddress;
|
||||
if (std::error_code EC = SecI->getAddress(SectionAddress))
|
||||
return EC;
|
||||
|
||||
uint64_t SectionAddress = SecI->getAddress();
|
||||
Result = Address - SectionAddress;
|
||||
return object_error::success;
|
||||
}
|
||||
@@ -199,14 +196,13 @@ RuntimeDyldImpl::loadObject(std::unique_ptr<ObjectImage> Obj) {
|
||||
SymType == object::SymbolRef::ST_Unknown) {
|
||||
uint64_t SectOffset;
|
||||
StringRef SectionData;
|
||||
bool IsCode;
|
||||
section_iterator SI = Obj->end_sections();
|
||||
Check(getOffset(*I, SectOffset));
|
||||
Check(I->getSection(SI));
|
||||
if (SI == Obj->end_sections())
|
||||
continue;
|
||||
Check(SI->getContents(SectionData));
|
||||
Check(SI->isText(IsCode));
|
||||
bool IsCode = SI->isText();
|
||||
unsigned SectionID =
|
||||
findOrEmitSection(*Obj, *SI, IsCode, LocalSections);
|
||||
LocalSymbols[Name.data()] = SymbolLoc(SectionID, SectOffset);
|
||||
@@ -236,8 +232,7 @@ RuntimeDyldImpl::loadObject(std::unique_ptr<ObjectImage> Obj) {
|
||||
if (I == E && !ProcessAllSections)
|
||||
continue;
|
||||
|
||||
bool IsCode = false;
|
||||
Check(RelocatedSection->isText(IsCode));
|
||||
bool IsCode = RelocatedSection->isText();
|
||||
SectionID =
|
||||
findOrEmitSection(*Obj, *RelocatedSection, IsCode, LocalSections);
|
||||
DEBUG(dbgs() << "\tSectionID: " << SectionID << "\n");
|
||||
@@ -291,20 +286,15 @@ void RuntimeDyldImpl::computeTotalAllocSize(ObjectImage &Obj,
|
||||
SI != SE; ++SI) {
|
||||
const SectionRef &Section = *SI;
|
||||
|
||||
bool IsRequired;
|
||||
Check(Section.isRequiredForExecution(IsRequired));
|
||||
bool IsRequired = Section.isRequiredForExecution();
|
||||
|
||||
// Consider only the sections that are required to be loaded for execution
|
||||
if (IsRequired) {
|
||||
uint64_t DataSize = 0;
|
||||
uint64_t Alignment64 = 0;
|
||||
bool IsCode = false;
|
||||
bool IsReadOnly = false;
|
||||
StringRef Name;
|
||||
Check(Section.getSize(DataSize));
|
||||
Check(Section.getAlignment(Alignment64));
|
||||
Check(Section.isText(IsCode));
|
||||
Check(Section.isReadOnlyData(IsReadOnly));
|
||||
uint64_t DataSize = Section.getSize();
|
||||
uint64_t Alignment64 = Section.getAlignment();
|
||||
bool IsCode = Section.isText();
|
||||
bool IsReadOnly = Section.isReadOnlyData();
|
||||
Check(Section.getName(Name));
|
||||
unsigned Alignment = (unsigned)Alignment64 & 0xffffffffL;
|
||||
|
||||
@@ -386,10 +376,8 @@ unsigned RuntimeDyldImpl::computeSectionStubBufSize(ObjectImage &Obj,
|
||||
}
|
||||
|
||||
// Get section data size and alignment
|
||||
uint64_t Alignment64;
|
||||
uint64_t DataSize;
|
||||
Check(Section.getSize(DataSize));
|
||||
Check(Section.getAlignment(Alignment64));
|
||||
uint64_t DataSize = Section.getSize();
|
||||
uint64_t Alignment64 = Section.getAlignment();
|
||||
|
||||
// Add stubbuf size alignment
|
||||
unsigned Alignment = (unsigned)Alignment64 & 0xffffffffL;
|
||||
@@ -473,24 +461,18 @@ unsigned RuntimeDyldImpl::emitSection(ObjectImage &Obj,
|
||||
const SectionRef &Section, bool IsCode) {
|
||||
|
||||
StringRef data;
|
||||
uint64_t Alignment64;
|
||||
Check(Section.getContents(data));
|
||||
Check(Section.getAlignment(Alignment64));
|
||||
uint64_t Alignment64 = Section.getAlignment();
|
||||
|
||||
unsigned Alignment = (unsigned)Alignment64 & 0xffffffffL;
|
||||
bool IsRequired;
|
||||
bool IsVirtual;
|
||||
bool IsZeroInit;
|
||||
bool IsReadOnly;
|
||||
uint64_t DataSize;
|
||||
unsigned PaddingSize = 0;
|
||||
unsigned StubBufSize = 0;
|
||||
StringRef Name;
|
||||
Check(Section.isRequiredForExecution(IsRequired));
|
||||
Check(Section.isVirtual(IsVirtual));
|
||||
Check(Section.isZeroInit(IsZeroInit));
|
||||
Check(Section.isReadOnlyData(IsReadOnly));
|
||||
Check(Section.getSize(DataSize));
|
||||
bool IsRequired = Section.isRequiredForExecution();
|
||||
bool IsVirtual = Section.isVirtual();
|
||||
bool IsZeroInit = Section.isZeroInit();
|
||||
bool IsReadOnly = Section.isReadOnlyData();
|
||||
uint64_t DataSize = Section.getSize();
|
||||
Check(Section.getName(Name));
|
||||
|
||||
StubBufSize = computeSectionStubBufSize(Obj, Section);
|
||||
|
||||
@@ -702,8 +702,7 @@ void RuntimeDyldELF::findOPDEntrySection(ObjectImage &Obj,
|
||||
|
||||
section_iterator tsi(Obj.end_sections());
|
||||
check(TargetSymbol->getSection(tsi));
|
||||
bool IsCode = false;
|
||||
tsi->isText(IsCode);
|
||||
bool IsCode = tsi->isText();
|
||||
Rel.SectionID = findOrEmitSection(Obj, (*tsi), IsCode, LocalSections);
|
||||
Rel.Addend = (intptr_t)Addend;
|
||||
return;
|
||||
@@ -983,9 +982,7 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
|
||||
if (si == Obj.end_sections())
|
||||
llvm_unreachable("Symbol section not found, bad object file format!");
|
||||
DEBUG(dbgs() << "\t\tThis is section symbol\n");
|
||||
// Default to 'true' in case isText fails (though it never does).
|
||||
bool isCode = true;
|
||||
si->isText(isCode);
|
||||
bool isCode = si->isText();
|
||||
Value.SectionID = findOrEmitSection(Obj, (*si), isCode, ObjSectionToID);
|
||||
Value.Addend = Addend;
|
||||
break;
|
||||
|
||||
@@ -66,11 +66,9 @@ RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
|
||||
}
|
||||
} else {
|
||||
SectionRef Sec = Obj.getRelocationSection(RelInfo);
|
||||
bool IsCode = false;
|
||||
Sec.isText(IsCode);
|
||||
bool IsCode = Sec.isText();
|
||||
Value.SectionID = findOrEmitSection(ObjImg, Sec, IsCode, ObjSectionToID);
|
||||
uint64_t Addr;
|
||||
Sec.getAddress(Addr);
|
||||
uint64_t Addr = Sec.getAddress();
|
||||
Value.Offset = RE.Addend - Addr;
|
||||
}
|
||||
|
||||
@@ -115,9 +113,8 @@ RuntimeDyldMachO::getSectionByAddress(const MachOObjectFile &Obj,
|
||||
section_iterator SE = Obj.section_end();
|
||||
|
||||
for (; SI != SE; ++SI) {
|
||||
uint64_t SAddr, SSize;
|
||||
SI->getAddress(SAddr);
|
||||
SI->getSize(SSize);
|
||||
uint64_t SAddr = SI->getAddress();
|
||||
uint64_t SSize = SI->getSize();
|
||||
if ((Addr >= SAddr) && (Addr < SAddr + SSize))
|
||||
return SI;
|
||||
}
|
||||
|
||||
@@ -232,20 +232,17 @@ private:
|
||||
uint32_t AddrA = MachO->getScatteredRelocationValue(RE);
|
||||
section_iterator SAI = getSectionByAddress(*MachO, AddrA);
|
||||
assert(SAI != MachO->section_end() && "Can't find section for address A");
|
||||
uint64_t SectionABase;
|
||||
SAI->getAddress(SectionABase);
|
||||
uint64_t SectionABase = SAI->getAddress();
|
||||
uint64_t SectionAOffset = AddrA - SectionABase;
|
||||
SectionRef SectionA = *SAI;
|
||||
bool IsCode;
|
||||
SectionA.isText(IsCode);
|
||||
bool IsCode = SectionA.isText();
|
||||
uint32_t SectionAID =
|
||||
findOrEmitSection(Obj, SectionA, IsCode, ObjSectionToID);
|
||||
|
||||
uint32_t AddrB = MachO->getScatteredRelocationValue(RE2);
|
||||
section_iterator SBI = getSectionByAddress(*MachO, AddrB);
|
||||
assert(SBI != MachO->section_end() && "Can't find section for address B");
|
||||
uint64_t SectionBBase;
|
||||
SBI->getAddress(SectionBBase);
|
||||
uint64_t SectionBBase = SBI->getAddress();
|
||||
uint64_t SectionBOffset = AddrB - SectionBBase;
|
||||
SectionRef SectionB = *SBI;
|
||||
uint32_t SectionBID =
|
||||
|
||||
@@ -152,20 +152,17 @@ private:
|
||||
uint32_t AddrA = MachO->getScatteredRelocationValue(RE);
|
||||
section_iterator SAI = getSectionByAddress(*MachO, AddrA);
|
||||
assert(SAI != MachO->section_end() && "Can't find section for address A");
|
||||
uint64_t SectionABase;
|
||||
SAI->getAddress(SectionABase);
|
||||
uint64_t SectionABase = SAI->getAddress();
|
||||
uint64_t SectionAOffset = AddrA - SectionABase;
|
||||
SectionRef SectionA = *SAI;
|
||||
bool IsCode;
|
||||
SectionA.isText(IsCode);
|
||||
bool IsCode = SectionA.isText();
|
||||
uint32_t SectionAID =
|
||||
findOrEmitSection(Obj, SectionA, IsCode, ObjSectionToID);
|
||||
|
||||
uint32_t AddrB = MachO->getScatteredRelocationValue(RE2);
|
||||
section_iterator SBI = getSectionByAddress(*MachO, AddrB);
|
||||
assert(SBI != MachO->section_end() && "Can't find section for address B");
|
||||
uint64_t SectionBBase;
|
||||
SBI->getAddress(SectionBBase);
|
||||
uint64_t SectionBBase = SBI->getAddress();
|
||||
uint64_t SectionBOffset = AddrB - SectionBBase;
|
||||
SectionRef SectionB = *SBI;
|
||||
uint32_t SectionBID =
|
||||
@@ -211,11 +208,9 @@ private:
|
||||
unsigned SymbolBaseAddr = MachO->getScatteredRelocationValue(RE);
|
||||
section_iterator TargetSI = getSectionByAddress(*MachO, SymbolBaseAddr);
|
||||
assert(TargetSI != MachO->section_end() && "Can't find section for symbol");
|
||||
uint64_t SectionBaseAddr;
|
||||
TargetSI->getAddress(SectionBaseAddr);
|
||||
uint64_t SectionBaseAddr = TargetSI->getAddress();
|
||||
SectionRef TargetSection = *TargetSI;
|
||||
bool IsCode;
|
||||
TargetSection.isText(IsCode);
|
||||
bool IsCode = TargetSection.isText();
|
||||
uint32_t TargetSectionID =
|
||||
findOrEmitSection(Obj, TargetSection, IsCode, ObjSectionToID);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user