[obj2yaml] - Fix BB after r373315.
authorGeorge Rimar <grimar@accesssoftek.com>
Tue, 1 Oct 2019 10:02:47 +0000 (10:02 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Tue, 1 Oct 2019 10:02:47 +0000 (10:02 +0000)
The success return value for data extractor's cursor
should also be checked.

llvm-svn: 373319

llvm/tools/obj2yaml/elf2yaml.cpp

index b70a5dd..c4b6eb7 100644 (file)
@@ -647,7 +647,9 @@ ELFDumper<ELFT>::dumpHashSection(const Elf_Shdr *Shdr) {
   uint32_t NChain = Data.getU32(Cur);
   if (Content.size() != (2 + NBucket + NChain) * 4) {
     S->Content = yaml::BinaryRef(Content);
-    return S.release();
+    if (Cur)
+      return S.release();
+    llvm_unreachable("entries were not read correctly");
   }
 
   S->Bucket.emplace(NBucket);
@@ -658,9 +660,9 @@ ELFDumper<ELFT>::dumpHashSection(const Elf_Shdr *Shdr) {
   for (uint32_t &V : *S->Chain)
     V = Data.getU32(Cur);
 
-  if (!Cur)
-    llvm_unreachable("entries were not read correctly");
-  return S.release();
+  if (Cur)
+    return S.release();
+  llvm_unreachable("entries were not read correctly");
 }
 
 template <class ELFT>