summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2019-05-16 12:08:34 +0000
committerHans Wennborg <hans@hanshq.net>2019-05-16 12:08:34 +0000
commit4da9ff9fcfe8987472dc894489597bd338aac85e (patch)
tree21bc0332451ec4093db5da5255ee98577ac5926e /llvm/tools/llvm-objdump
parenta8f88c388f75cb03bd21beb0b64f87d8a8727254 (diff)
downloadbcm5719-llvm-4da9ff9fcfe8987472dc894489597bd338aac85e.tar.gz
bcm5719-llvm-4da9ff9fcfe8987472dc894489597bd338aac85e.zip
Revert r360876 "[Object] Change object::SectionRef::getContents() to return Expected<StringRef>"
It broke the Clang build, see llvm-commits thread. > Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. > > Follow-up of D61781. llvm-svn: 360878
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r--llvm/tools/llvm-objdump/MachODump.cpp35
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp17
2 files changed, 29 insertions, 23 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 6bb30c551da..9d8161937b4 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -1482,8 +1482,8 @@ static void DumpLiteralPointerSection(MachOObjectFile *O,
section_type = Sec.flags & MachO::SECTION_TYPE;
}
- StringRef BytesStr = unwrapOrError(Sect->getContents(), O->getFileName());
-
+ StringRef BytesStr;
+ Sect->getContents(BytesStr);
const char *Contents = reinterpret_cast<const char *>(BytesStr.data());
switch (section_type) {
@@ -1697,8 +1697,8 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
}
uint32_t section_type = section_flags & MachO::SECTION_TYPE;
- StringRef BytesStr =
- unwrapOrError(Section.getContents(), O->getFileName());
+ StringRef BytesStr;
+ Section.getContents(BytesStr);
const char *sect = reinterpret_cast<const char *>(BytesStr.data());
uint32_t sect_size = BytesStr.size();
uint64_t sect_addr = Section.getAddress();
@@ -1782,8 +1782,8 @@ static void DumpInfoPlistSectionContents(StringRef Filename,
if (SegName == "__TEXT" && SectName == "__info_plist") {
if (!NoLeadingHeaders)
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
- StringRef BytesStr =
- unwrapOrError(Section.getContents(), O->getFileName());
+ StringRef BytesStr;
+ Section.getContents(BytesStr);
const char *sect = reinterpret_cast<const char *>(BytesStr.data());
outs() << format("%.*s", BytesStr.size(), sect) << "\n";
return;
@@ -3194,8 +3194,8 @@ static const char *get_pointer_64(uint64_t Address, uint32_t &offset,
S = (*(info->Sections))[SectIdx];
offset = Address - SectAddress;
left = SectSize - offset;
- StringRef SectContents = unwrapOrError(
- ((*(info->Sections))[SectIdx]).getContents(), info->O->getFileName());
+ StringRef SectContents;
+ ((*(info->Sections))[SectIdx]).getContents(SectContents);
return SectContents.data() + offset;
}
}
@@ -3998,7 +3998,8 @@ walk_pointer_list_64(const char *listname, const SectionRef S,
StringRef SegName = O->getSectionFinalSegmentName(Ref);
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
- StringRef BytesStr = unwrapOrError(S.getContents(), O->getFileName());
+ StringRef BytesStr;
+ S.getContents(BytesStr);
const char *Contents = reinterpret_cast<const char *>(BytesStr.data());
for (uint32_t i = 0; i < S.getSize(); i += sizeof(uint64_t)) {
@@ -4048,7 +4049,8 @@ walk_pointer_list_32(const char *listname, const SectionRef S,
StringRef SegName = O->getSectionFinalSegmentName(Ref);
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
- StringRef BytesStr = unwrapOrError(S.getContents(), O->getFileName());
+ StringRef BytesStr;
+ S.getContents(BytesStr);
const char *Contents = reinterpret_cast<const char *>(BytesStr.data());
for (uint32_t i = 0; i < S.getSize(); i += sizeof(uint32_t)) {
@@ -7240,8 +7242,8 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
if (SegmentName != DisSegName)
continue;
- StringRef BytesStr =
- unwrapOrError(Sections[SectIdx].getContents(), Filename);
+ StringRef BytesStr;
+ Sections[SectIdx].getContents(BytesStr);
ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(BytesStr);
uint64_t SectAddress = Sections[SectIdx].getAddress();
@@ -7694,8 +7696,9 @@ printMachOCompactUnwindSection(const MachOObjectFile *Obj,
uint32_t PointerSize = Is64 ? sizeof(uint64_t) : sizeof(uint32_t);
uint32_t EntrySize = 3 * PointerSize + 2 * sizeof(uint32_t);
- StringRef Contents =
- unwrapOrError(CompactUnwind.getContents(), Obj->getFileName());
+ StringRef Contents;
+ CompactUnwind.getContents(Contents);
+
SmallVector<CompactUnwindEntry, 4> CompactUnwinds;
// First populate the initial raw offsets, encodings and so on from the entry.
@@ -7836,8 +7839,8 @@ static void printMachOUnwindInfoSection(const MachOObjectFile *Obj,
outs() << "Contents of __unwind_info section:\n";
- StringRef Contents =
- unwrapOrError(UnwindInfo.getContents(), Obj->getFileName());
+ StringRef Contents;
+ UnwindInfo.getContents(Contents);
ptrdiff_t Pos = 0;
//===----------------------------------
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index de26b61697c..3fddfd2d349 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1126,8 +1126,9 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
SmallString<40> Comments;
raw_svector_ostream CommentStream(Comments);
- ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(
- unwrapOrError(Section.getContents(), Obj->getFileName()));
+ StringRef BytesStr;
+ error(Section.getContents(BytesStr));
+ ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(BytesStr);
uint64_t VMAAdjustment = 0;
if (shouldAdjustVA(Section))
@@ -1560,6 +1561,7 @@ void printSectionHeaders(const ObjectFile *Obj) {
void printSectionContents(const ObjectFile *Obj) {
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
StringRef Name;
+ StringRef Contents;
error(Section.getName(Name));
uint64_t BaseAddr = Section.getAddress();
uint64_t Size = Section.getSize();
@@ -1574,7 +1576,7 @@ void printSectionContents(const ObjectFile *Obj) {
continue;
}
- StringRef Contents = unwrapOrError(Section.getContents(), Obj->getFileName());
+ error(Section.getContents(Contents));
// Dump out the content as hex and printable ascii characters.
for (std::size_t Addr = 0, End = Contents.size(); Addr < End; Addr += 16) {
@@ -1762,8 +1764,8 @@ void printRawClangAST(const ObjectFile *Obj) {
if (!ClangASTSection)
return;
- StringRef ClangASTContents = unwrapOrError(
- ClangASTSection.getValue().getContents(), Obj->getFileName());
+ StringRef ClangASTContents;
+ error(ClangASTSection.getValue().getContents(ClangASTContents));
outs().write(ClangASTContents.data(), ClangASTContents.size());
}
@@ -1799,8 +1801,9 @@ static void printFaultMaps(const ObjectFile *Obj) {
return;
}
- StringRef FaultMapContents =
- unwrapOrError(FaultMapSection.getValue().getContents(), Obj->getFileName());
+ StringRef FaultMapContents;
+ error(FaultMapSection.getValue().getContents(FaultMapContents));
+
FaultMapParser FMP(FaultMapContents.bytes_begin(),
FaultMapContents.bytes_end());
OpenPOWER on IntegriCloud