[yaml2obj] - Allow overriding sh_offset field from the YAML.

Some of our test cases are using objects which
has sections with a broken sh_offset field.

There was no way to set it from YAML until this patch.

Differential revision: https://reviews.llvm.org/D63879

llvm-svn: 364898
diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp
index e093ed8..735057f 100644
--- a/llvm/tools/yaml2obj/yaml2elf.cpp
+++ b/llvm/tools/yaml2obj/yaml2elf.cpp
@@ -269,6 +269,11 @@
                                   YAMLSec);
   else
     return false;
+
+  // Override the sh_offset field if requested.
+  if (YAMLSec && YAMLSec->ShOffset)
+    Header.sh_offset = *YAMLSec->ShOffset;
+
   return true;
 }
 
@@ -358,6 +363,10 @@
         return false;
     } else
       llvm_unreachable("Unknown section type");
+
+    // Override the sh_offset field if requested.
+    if (Sec && Sec->ShOffset)
+      SHeader.sh_offset = *Sec->ShOffset;
   }
 
   return true;