summaryrefslogtreecommitdiff
path: root/tools/yaml2obj
diff options
context:
space:
mode:
Diffstat (limited to 'tools/yaml2obj')
-rw-r--r--tools/yaml2obj/yaml2elf.cpp9
1 files changed, 7 insertions, 2 deletions
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>