[yaml2obj] Support numeric indexes to create invalid files. Will be used by lld test.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Thu, 27 Aug 2015 23:11:20 +0000 (23:11 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Thu, 27 Aug 2015 23:11:20 +0000 (23:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246233 91177308-0d34-0410-b5e6-96231b3b80d8

tools/yaml2obj/yaml2elf.cpp

index a247f48c053dcdb94bdec6228b9bca6acc6d33a2..849f202b126a5e73521ecc5f0ecc2091270a50ff 100644 (file)
@@ -222,9 +222,11 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
 
       unsigned Index;
       if (SN2I.lookup(S->Info, Index)) {
-        errs() << "error: Unknown section referenced: '" << S->Info
-               << "' at YAML section '" << S->Name << "'.\n";
-        return false;
+        if (S->Info.getAsInteger(0, Index)) {
+          errs() << "error: Unknown section referenced: '" << S->Info
+                 << "' at YAML section '" << S->Name << "'.\n";
+          return false;
+        }
       }
       SHeader.sh_info = Index;