[obj2yaml][yaml2obj] - Add support of parsing/dumping of the .gnu.version_r section.

The section is described here:
https://refspecs.linuxfoundation.org/LSB_1.3.0/gLSB/gLSB/symverrqmts.html

Patch just teaches obj2yaml/yaml2obj to dump and parse such sections.

We did the finalization of string tables very late,
and I had to move the logic to make it a bit earlier.
That was needed in this patch since .gnu.version_r adds strings to .dynstr.
This might also be useful for implementing other special sections.

Everything else changed in this patch seems to be straightforward.

Differential revision: https://reviews.llvm.org/D58119

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354328 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
George Rimar
2019-02-19 14:03:14 +00:00
parent 6121ddcb93
commit ca483bfba2
6 changed files with 373 additions and 9 deletions
+32
View File
@@ -872,6 +872,12 @@ static void sectionMapping(IO &IO, ELFYAML::NoBitsSection &Section) {
IO.mapOptional("Size", Section.Size, Hex64(0));
}
static void sectionMapping(IO &IO, ELFYAML::VerneedSection &Section) {
commonSectionMapping(IO, Section);
IO.mapRequired("Info", Section.Info);
IO.mapRequired("Dependencies", Section.VerneedV);
}
static void sectionMapping(IO &IO, ELFYAML::RelocationSection &Section) {
commonSectionMapping(IO, Section);
IO.mapOptional("Info", Section.RelocatableSec, StringRef());
@@ -949,6 +955,11 @@ void MappingTraits<std::unique_ptr<ELFYAML::Section>>::mapping(
Section.reset(new ELFYAML::MipsABIFlags());
sectionMapping(IO, *cast<ELFYAML::MipsABIFlags>(Section.get()));
break;
case ELF::SHT_GNU_verneed:
if (!IO.outputting())
Section.reset(new ELFYAML::VerneedSection());
sectionMapping(IO, *cast<ELFYAML::VerneedSection>(Section.get()));
break;
default:
if (!IO.outputting())
Section.reset(new ELFYAML::RawContentSection());
@@ -997,6 +1008,27 @@ void MappingTraits<ELFYAML::DynamicEntry>::mapping(IO &IO,
IO.mapRequired("Value", Rel.Val);
}
void MappingTraits<ELFYAML::VerneedEntry>::mapping(IO &IO,
ELFYAML::VerneedEntry &E) {
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
assert(Object && "The IO context is not initialized");
IO.mapRequired("Version", E.Version);
IO.mapRequired("File", E.File);
IO.mapRequired("Entries", E.AuxV);
}
void MappingTraits<ELFYAML::VernauxEntry>::mapping(IO &IO,
ELFYAML::VernauxEntry &E) {
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
assert(Object && "The IO context is not initialized");
IO.mapRequired("Name", E.Name);
IO.mapRequired("Hash", E.Hash);
IO.mapRequired("Flags", E.Flags);
IO.mapRequired("Other", E.Other);
}
void MappingTraits<ELFYAML::Relocation>::mapping(IO &IO,
ELFYAML::Relocation &Rel) {
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());