diff options
Diffstat (limited to 'lib/Object/ELFYAML.cpp')
-rw-r--r-- | lib/Object/ELFYAML.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Object/ELFYAML.cpp b/lib/Object/ELFYAML.cpp index c396f66ee6..547720ddc3 100644 --- a/lib/Object/ELFYAML.cpp +++ b/lib/Object/ELFYAML.cpp @@ -658,6 +658,7 @@ static void commonSectionMapping(IO &IO, ELFYAML::Section &Section) { static void sectionMapping(IO &IO, ELFYAML::RawContentSection &Section) { commonSectionMapping(IO, Section); IO.mapOptional("Content", Section.Content); + IO.mapOptional("Size", Section.Size, Hex64(Section.Content.binary_size())); } static void sectionMapping(IO &IO, ELFYAML::RelocationSection &Section) { @@ -687,6 +688,14 @@ void MappingTraits<std::unique_ptr<ELFYAML::Section>>::mapping( } } +StringRef MappingTraits<std::unique_ptr<ELFYAML::Section>>::validate( + IO &io, std::unique_ptr<ELFYAML::Section> &Section) { + const auto *RawSection = dyn_cast<ELFYAML::RawContentSection>(Section.get()); + if (!RawSection || RawSection->Size >= RawSection->Content.binary_size()) + return StringRef(); + return "Section size must be greater or equal to the content size"; +} + void MappingTraits<ELFYAML::Relocation>::mapping(IO &IO, ELFYAML::Relocation &Rel) { IO.mapRequired("Offset", Rel.Offset); |