[yaml2obj] Add sh_addr via `Address` key.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183954 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/Object/ELFYAML.h b/include/llvm/Object/ELFYAML.h
index dd9625e..401e4db 100644
--- a/include/llvm/Object/ELFYAML.h
+++ b/include/llvm/Object/ELFYAML.h
@@ -53,6 +53,7 @@
   StringRef Name;
   ELF_SHT Type;
   ELF_SHF Flags;
+  llvm::yaml::Hex64 Address;
 };
 struct Object {
   FileHeader Header;
diff --git a/lib/Object/ELFYAML.cpp b/lib/Object/ELFYAML.cpp
index e275a4a..9ce2b9b 100644
--- a/lib/Object/ELFYAML.cpp
+++ b/lib/Object/ELFYAML.cpp
@@ -265,6 +265,7 @@
   IO.mapOptional("Name", Section.Name, StringRef());
   IO.mapRequired("Type", Section.Type);
   IO.mapOptional("Flags", Section.Flags, ELFYAML::ELF_SHF(0));
+  IO.mapOptional("Address", Section.Address, Hex64(0));
 }
 
 void MappingTraits<ELFYAML::Object>::mapping(IO &IO, ELFYAML::Object &Object) {
diff --git a/test/Object/yaml2obj-elf-section-basic.yaml b/test/Object/yaml2obj-elf-section-basic.yaml
index 6d40952..e59b450 100644
--- a/test/Object/yaml2obj-elf-section-basic.yaml
+++ b/test/Object/yaml2obj-elf-section-basic.yaml
@@ -9,6 +9,7 @@
   - Name: .text
     Type: SHT_PROGBITS
     Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address: 0xDEADBEEF
 
 # CHECK:        Section {
 # CHECK:          Index: 0
@@ -21,3 +22,4 @@
 # CHECK-NEXT:       SHF_ALLOC (0x2)
 # CHECK-NEXT:       SHF_EXECINSTR (0x4)
 # CHECK-NEXT:     ]
+# CHECK-NEXT:     Address: 0xDEADBEEF
diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp
index 235327b..1809bb5 100644
--- a/tools/yaml2obj/yaml2elf.cpp
+++ b/tools/yaml2obj/yaml2elf.cpp
@@ -132,7 +132,7 @@
     SHeader.sh_name = StrTab.addString(Sec.Name);
     SHeader.sh_type = Sec.Type;
     SHeader.sh_flags = Sec.Flags;
-    SHeader.sh_addr = 0;
+    SHeader.sh_addr = Sec.Address;
     SHeader.sh_offset = 0;
     SHeader.sh_size = 0;
     SHeader.sh_link = 0;