diff options
author | Georgii Rymar <grimar@accesssoftek.com> | 2019-11-26 13:59:37 +0300 |
---|---|---|
committer | Georgii Rymar <grimar@accesssoftek.com> | 2019-11-26 15:35:05 +0300 |
commit | f69ac55d60d916e295ae0e507c5f4c2655360089 (patch) | |
tree | ac3616c84080ac435c7869b5aed0580bdf7984ac /llvm/lib/ObjectYAML/ELFEmitter.cpp | |
parent | 5f8b8d282048a9c535a90ab64bbadf576e348963 (diff) | |
download | bcm5719-llvm-f69ac55d60d916e295ae0e507c5f4c2655360089.tar.gz bcm5719-llvm-f69ac55d60d916e295ae0e507c5f4c2655360089.zip |
[yaml2obj] - Teach tool to describe SHT_GNU_verdef section with a "Content" property.
There is no way to set raw content for SHT_GNU_verdef section.
This patch implements it.
Differential revision: https://reviews.llvm.org/D70710
Diffstat (limited to 'llvm/lib/ObjectYAML/ELFEmitter.cpp')
-rw-r--r-- | llvm/lib/ObjectYAML/ELFEmitter.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index e8b54a7e602..069e3c19523 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -985,9 +985,19 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, raw_ostream &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign); + SHeader.sh_info = Section.Info; + + if (Section.Content) { + SHeader.sh_size = writeContent(OS, Section.Content, None); + return; + } + + if (!Section.Entries) + return; + uint64_t AuxCnt = 0; - for (size_t I = 0; I < Section.Entries.size(); ++I) { - const ELFYAML::VerdefEntry &E = Section.Entries[I]; + for (size_t I = 0; I < Section.Entries->size(); ++I) { + const ELFYAML::VerdefEntry &E = (*Section.Entries)[I]; Elf_Verdef VerDef; VerDef.vd_version = E.Version; @@ -996,7 +1006,7 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, VerDef.vd_hash = E.Hash; VerDef.vd_aux = sizeof(Elf_Verdef); VerDef.vd_cnt = E.VerNames.size(); - if (I == Section.Entries.size() - 1) + if (I == Section.Entries->size() - 1) VerDef.vd_next = 0; else VerDef.vd_next = @@ -1014,9 +1024,8 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, } } - SHeader.sh_size = Section.Entries.size() * sizeof(Elf_Verdef) + + SHeader.sh_size = Section.Entries->size() * sizeof(Elf_Verdef) + AuxCnt * sizeof(Elf_Verdaux); - SHeader.sh_info = Section.Info; } template <class ELFT> @@ -1341,9 +1350,10 @@ template <class ELFT> void ELFState<ELFT>::finalizeStrings() { DotDynstr.add(Aux.Name); } } else if (auto VerDef = dyn_cast<ELFYAML::VerdefSection>(Sec)) { - for (const ELFYAML::VerdefEntry &E : VerDef->Entries) - for (StringRef Name : E.VerNames) - DotDynstr.add(Name); + if (VerDef->Entries) + for (const ELFYAML::VerdefEntry &E : *VerDef->Entries) + for (StringRef Name : E.VerNames) + DotDynstr.add(Name); } } |