aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 3fddfd2..de26b61 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1126,9 +1126,8 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
SmallString<40> Comments;
raw_svector_ostream CommentStream(Comments);
- StringRef BytesStr;
- error(Section.getContents(BytesStr));
- ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(BytesStr);
+ ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(
+ unwrapOrError(Section.getContents(), Obj->getFileName()));
uint64_t VMAAdjustment = 0;
if (shouldAdjustVA(Section))
@@ -1561,7 +1560,6 @@ 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();
@@ -1576,7 +1574,7 @@ void printSectionContents(const ObjectFile *Obj) {
continue;
}
- error(Section.getContents(Contents));
+ StringRef Contents = unwrapOrError(Section.getContents(), Obj->getFileName());
// Dump out the content as hex and printable ascii characters.
for (std::size_t Addr = 0, End = Contents.size(); Addr < End; Addr += 16) {
@@ -1764,8 +1762,8 @@ void printRawClangAST(const ObjectFile *Obj) {
if (!ClangASTSection)
return;
- StringRef ClangASTContents;
- error(ClangASTSection.getValue().getContents(ClangASTContents));
+ StringRef ClangASTContents = unwrapOrError(
+ ClangASTSection.getValue().getContents(), Obj->getFileName());
outs().write(ClangASTContents.data(), ClangASTContents.size());
}
@@ -1801,9 +1799,8 @@ static void printFaultMaps(const ObjectFile *Obj) {
return;
}
- StringRef FaultMapContents;
- error(FaultMapSection.getValue().getContents(FaultMapContents));
-
+ StringRef FaultMapContents =
+ unwrapOrError(FaultMapSection.getValue().getContents(), Obj->getFileName());
FaultMapParser FMP(FaultMapContents.bytes_begin(),
FaultMapContents.bytes_end());