summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/obj2yaml/elf2yaml.cpp1
-rw-r--r--tools/yaml2obj/yaml2elf.cpp9
2 files changed, 8 insertions, 2 deletions
diff --git a/tools/obj2yaml/elf2yaml.cpp b/tools/obj2yaml/elf2yaml.cpp
index 38afa138d9..7642921b48 100644
--- a/tools/obj2yaml/elf2yaml.cpp
+++ b/tools/obj2yaml/elf2yaml.cpp
@@ -254,6 +254,7 @@ ELFDumper<ELFT>::dumpContentSection(const Elf_Shdr *Shdr) {
if (error_code EC = ContentOrErr.getError())
return EC;
S->Content = object::yaml::BinaryRef(ContentOrErr.get());
+ S->Size = S->Content.binary_size();
return S.release();
}
diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp
index 3190b27d32..bb52cda7c1 100644
--- a/tools/yaml2obj/yaml2elf.cpp
+++ b/tools/yaml2obj/yaml2elf.cpp
@@ -314,9 +314,14 @@ void
ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::RawContentSection &Section,
ContiguousBlobAccumulator &CBA) {
- Section.Content.writeAsBinary(CBA.getOSAndAlignedOffset(SHeader.sh_offset));
+ assert(Section.Size >= Section.Content.binary_size() &&
+ "Section size and section content are inconsistent");
+ raw_ostream &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset);
+ Section.Content.writeAsBinary(OS);
+ for (auto i = Section.Content.binary_size(); i < Section.Size; ++i)
+ OS.write(0);
SHeader.sh_entsize = 0;
- SHeader.sh_size = Section.Content.binary_size();
+ SHeader.sh_size = Section.Size;
}
template <class ELFT>