diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-06-10 12:43:18 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-06-10 12:43:18 +0000 |
commit | 1e41007aeba071d1a30f1f0eb7ebfe41f75917fb (patch) | |
tree | 7be126a2c5b55277db11eeda19ee307a68d82d1c /llvm/lib/ObjectYAML | |
parent | 1f73bbbd3a5bbe4baec841f20ac237011716fbdd (diff) | |
download | bcm5719-llvm-1e41007aeba071d1a30f1f0eb7ebfe41f75917fb.tar.gz bcm5719-llvm-1e41007aeba071d1a30f1f0eb7ebfe41f75917fb.zip |
[yaml2obj/obj2yaml] - Make RawContentSection::Content and RawContentSection::Size optional
This is a follow-up for D62809.
Content and Size fields should be optional as was discussed in comments
of the D62809's thread. With that, we can describe a specific string table and
symbol table sections in a more correct way and also show appropriate errors.
The patch adds lots of test cases where the behavior is described in details.
Differential revision: https://reviews.llvm.org/D62957
llvm-svn: 362931
Diffstat (limited to 'llvm/lib/ObjectYAML')
-rw-r--r-- | llvm/lib/ObjectYAML/ELFYAML.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index 33d011cbd9f..8be86ab4707 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -914,7 +914,7 @@ static void sectionMapping(IO &IO, ELFYAML::DynamicSection &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())); + IO.mapOptional("Size", Section.Size); IO.mapOptional("Info", Section.Info, Hex64(0)); } @@ -1042,9 +1042,12 @@ 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"; + if (!RawSection) + return {}; + if (RawSection->Size && RawSection->Content && + (uint64_t)(*RawSection->Size) < RawSection->Content->binary_size()) + return "Section size must be greater than or equal to the content size"; + return {}; } namespace { |