summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-10-21 11:06:38 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-10-21 11:06:38 +0000
commit2bf01dcbaa6723c9c41f8d6005a1f69818ddbd23 (patch)
treef9862a0f5568ba2e6e46f55e85ba2b720c50853e /llvm/tools/llvm-readobj
parentbac5f6bd21de81a9041a94c12b49eb108dbc77c4 (diff)
downloadbcm5719-llvm-2bf01dcbaa6723c9c41f8d6005a1f69818ddbd23.tar.gz
bcm5719-llvm-2bf01dcbaa6723c9c41f8d6005a1f69818ddbd23.zip
[llvm/Object] - Make ELFObjectFile::getRelocatedSection return Expected<section_iterator>
It returns just a section_iterator currently and have a report_fatal_error call inside. This change adds a way to return errors and handle them on caller sides. The patch also changes/improves current users and adds test cases. Differential revision: https://reviews.llvm.org/D69167 llvm-svn: 375408
Diffstat (limited to 'llvm/tools/llvm-readobj')
-rw-r--r--llvm/tools/llvm-readobj/ELFDumper.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 7e140933393..57144882c4b 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -4894,8 +4894,16 @@ void DumpStyle<ELFT>::printRelocatableStackSizes(
if (SectionType != ELF::SHT_RELA && SectionType != ELF::SHT_REL)
continue;
- SectionRef Contents = *Sec.getRelocatedSection();
- const Elf_Shdr *ContentsSec = Obj->getSection(Contents.getRawDataRefImpl());
+ Expected<section_iterator> RelSecOrErr = Sec.getRelocatedSection();
+ if (!RelSecOrErr)
+ reportError(createStringError(object_error::parse_failed,
+ "%s: failed to get a relocated section: %s",
+ SectionName.data(),
+ toString(RelSecOrErr.takeError()).c_str()),
+ Obj->getFileName());
+
+ const Elf_Shdr *ContentsSec =
+ Obj->getSection((*RelSecOrErr)->getRawDataRefImpl());
Expected<StringRef> ContentsSectionNameOrErr =
EF->getSectionName(ContentsSec);
if (!ContentsSectionNameOrErr) {
OpenPOWER on IntegriCloud