diff options
Diffstat (limited to 'llvm/tools/yaml2obj/yaml2elf.cpp')
-rw-r--r-- | llvm/tools/yaml2obj/yaml2elf.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp index beb2ea26752..84865341a29 100644 --- a/llvm/tools/yaml2obj/yaml2elf.cpp +++ b/llvm/tools/yaml2obj/yaml2elf.cpp @@ -157,6 +157,9 @@ class ELFState { bool writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::Group &Group, ContiguousBlobAccumulator &CBA); bool writeSectionContent(Elf_Shdr &SHeader, + const ELFYAML::SymverSection &Section, + ContiguousBlobAccumulator &CBA); + bool writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::VerneedSection &Section, ContiguousBlobAccumulator &CBA); bool writeSectionContent(Elf_Shdr &SHeader, @@ -303,6 +306,8 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders, CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign); } else if (auto S = dyn_cast<ELFYAML::DynamicSection>(Sec.get())) { writeSectionContent(SHeader, *S, CBA); + } else if (auto S = dyn_cast<ELFYAML::SymverSection>(Sec.get())) { + writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast<ELFYAML::VerneedSection>(Sec.get())) { writeSectionContent(SHeader, *S, CBA); } else @@ -569,6 +574,24 @@ bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, template <class ELFT> bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, + const ELFYAML::SymverSection &Section, + ContiguousBlobAccumulator &CBA) { + typedef typename ELFT::Half Elf_Half; + + raw_ostream &OS = + CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign); + for (uint16_t V : Section.Entries) { + Elf_Half Version = (Elf_Half)V; + OS.write((const char *)&Version, sizeof(Elf_Half)); + } + + SHeader.sh_size = Section.Entries.size() * sizeof(Elf_Half); + SHeader.sh_entsize = sizeof(Elf_Half); + return true; +} + +template <class ELFT> +bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::VerneedSection &Section, ContiguousBlobAccumulator &CBA) { typedef typename ELFT::Verneed Elf_Verneed; |