// to find a section beginning instead.
for (const SectionRef &Section : O->sections()) {
std::error_code ec;
- uint64_t Addr;
- StringRef Name;
- if ((ec = Section.getAddress(Addr)))
- report_fatal_error(ec.message());
+ StringRef Name;
+ uint64_t Addr = Section.getAddress();
if (Addr != Val)
continue;
if ((ec = Section.getName(Name)))
EndOffset = Value;
}
if (!EndOffset) {
- uint64_t Size;
DataRefImpl Sec;
Sec.d.a = SectionIndex-1;
- getSectionSize(Sec, Size);
- getSectionAddress(Sec, EndOffset);
+ uint64_t Size = getSectionSize(Sec);
+ EndOffset = getSectionAddress(Sec);
EndOffset += Size;
}
Result = EndOffset - BeginOffset;
return object_error::success;
}
-std::error_code MachOObjectFile::getSectionAddress(DataRefImpl Sec,
- uint64_t &Res) const {
- if (is64Bit()) {
- MachO::section_64 Sect = getSection64(Sec);
- Res = Sect.addr;
- } else {
- MachO::section Sect = getSection(Sec);
- Res = Sect.addr;
- }
- return object_error::success;
+uint64_t MachOObjectFile::getSectionAddress(DataRefImpl Sec) const {
+ if (is64Bit())
+ return getSection64(Sec).addr;
+ return getSection(Sec).addr;
}
-std::error_code MachOObjectFile::getSectionSize(DataRefImpl Sec,
- uint64_t &Res) const {
- if (is64Bit()) {
- MachO::section_64 Sect = getSection64(Sec);
- Res = Sect.size;
- } else {
- MachO::section Sect = getSection(Sec);
- Res = Sect.size;
- }
-
- return object_error::success;
+uint64_t MachOObjectFile::getSectionSize(DataRefImpl Sec) const {
+ if (is64Bit())
+ return getSection64(Sec).size;
+ return getSection(Sec).size;
}
std::error_code MachOObjectFile::getSectionContents(DataRefImpl Sec,
return object_error::success;
}
-std::error_code MachOObjectFile::getSectionAlignment(DataRefImpl Sec,
- uint64_t &Res) const {
+uint64_t MachOObjectFile::getSectionAlignment(DataRefImpl Sec) const {
uint32_t Align;
if (is64Bit()) {
MachO::section_64 Sect = getSection64(Sec);
Align = Sect.align;
}
- Res = uint64_t(1) << Align;
- return object_error::success;
+ return uint64_t(1) << Align;
}
-std::error_code MachOObjectFile::isSectionText(DataRefImpl Sec,
- bool &Res) const {
+bool MachOObjectFile::isSectionText(DataRefImpl Sec) const {
uint32_t Flags = getSectionFlags(this, Sec);
- Res = Flags & MachO::S_ATTR_PURE_INSTRUCTIONS;
- return object_error::success;
+ return Flags & MachO::S_ATTR_PURE_INSTRUCTIONS;
}
-std::error_code MachOObjectFile::isSectionData(DataRefImpl Sec,
- bool &Result) const {
+bool MachOObjectFile::isSectionData(DataRefImpl Sec) const {
uint32_t Flags = getSectionFlags(this, Sec);
unsigned SectionType = Flags & MachO::SECTION_TYPE;
- Result = !(Flags & MachO::S_ATTR_PURE_INSTRUCTIONS) &&
- !(SectionType == MachO::S_ZEROFILL ||
- SectionType == MachO::S_GB_ZEROFILL);
- return object_error::success;
+ return !(Flags & MachO::S_ATTR_PURE_INSTRUCTIONS) &&
+ !(SectionType == MachO::S_ZEROFILL ||
+ SectionType == MachO::S_GB_ZEROFILL);
}
-std::error_code MachOObjectFile::isSectionBSS(DataRefImpl Sec,
- bool &Result) const {
+bool MachOObjectFile::isSectionBSS(DataRefImpl Sec) const {
uint32_t Flags = getSectionFlags(this, Sec);
unsigned SectionType = Flags & MachO::SECTION_TYPE;
- Result = !(Flags & MachO::S_ATTR_PURE_INSTRUCTIONS) &&
- (SectionType == MachO::S_ZEROFILL ||
- SectionType == MachO::S_GB_ZEROFILL);
- return object_error::success;
+ return !(Flags & MachO::S_ATTR_PURE_INSTRUCTIONS) &&
+ (SectionType == MachO::S_ZEROFILL ||
+ SectionType == MachO::S_GB_ZEROFILL);
}
-std::error_code
-MachOObjectFile::isSectionRequiredForExecution(DataRefImpl Sec,
- bool &Result) const {
+bool MachOObjectFile::isSectionRequiredForExecution(DataRefImpl Sect) const {
// FIXME: Unimplemented.
- Result = true;
- return object_error::success;
+ return true;
}
-std::error_code MachOObjectFile::isSectionVirtual(DataRefImpl Sec,
- bool &Result) const {
+bool MachOObjectFile::isSectionVirtual(DataRefImpl Sec) const {
// FIXME: Unimplemented.
- Result = false;
- return object_error::success;
+ return false;
}
-std::error_code MachOObjectFile::isSectionZeroInit(DataRefImpl Sec,
- bool &Res) const {
+bool MachOObjectFile::isSectionZeroInit(DataRefImpl Sec) const {
uint32_t Flags = getSectionFlags(this, Sec);
unsigned SectionType = Flags & MachO::SECTION_TYPE;
- Res = SectionType == MachO::S_ZEROFILL ||
- SectionType == MachO::S_GB_ZEROFILL;
- return object_error::success;
+ return SectionType == MachO::S_ZEROFILL ||
+ SectionType == MachO::S_GB_ZEROFILL;
}
-std::error_code MachOObjectFile::isSectionReadOnlyData(DataRefImpl Sec,
- bool &Result) const {
+bool MachOObjectFile::isSectionReadOnlyData(DataRefImpl Sec) const {
// Consider using the code from isSectionText to look for __const sections.
// Alternately, emit S_ATTR_PURE_INSTRUCTIONS and/or S_ATTR_SOME_INSTRUCTIONS
// to use section attributes to distinguish code from data.
// FIXME: Unimplemented.
- Result = false;
- return object_error::success;
+ return false;
}
-std::error_code MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec,
- DataRefImpl Symb,
- bool &Result) const {
+bool MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec,
+ DataRefImpl Symb) const {
SymbolRef::Type ST;
this->getSymbolType(Symb, ST);
- if (ST == SymbolRef::ST_Unknown) {
- Result = false;
- return object_error::success;
- }
+ if (ST == SymbolRef::ST_Unknown)
+ return false;
- uint64_t SectBegin, SectEnd;
- getSectionAddress(Sec, SectBegin);
- getSectionSize(Sec, SectEnd);
+ uint64_t SectBegin = getSectionAddress(Sec);
+ uint64_t SectEnd = getSectionSize(Sec);
SectEnd += SectBegin;
uint64_t SymAddr;
getSymbolAddress(Symb, SymAddr);
- Result = (SymAddr >= SectBegin) && (SymAddr < SectEnd);
-
- return object_error::success;
+ return (SymAddr >= SectBegin) && (SymAddr < SectEnd);
}
relocation_iterator MachOObjectFile::section_rel_begin(DataRefImpl Sec) const {
DataRefImpl Sec;
Sec.d.a = Rel.d.a;
- uint64_t SecAddress;
- getSectionAddress(Sec, SecAddress);
+ uint64_t SecAddress = getSectionAddress(Sec);
Res = SecAddress + Offset;
return object_error::success;
}
while (*Ptr) {
++Ptr;
}
- ++Ptr;
SymbolName = StringRef(reinterpret_cast<const char*>(SymStart),
Ptr-SymStart);
+ ++Ptr;
DEBUG_WITH_TYPE(
"mach-o-bind",
llvm::dbgs() << "BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: "