diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-10-03 14:52:33 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-10-03 14:52:33 +0000 |
commit | fc9104d42a777540984c7f43f5f12f635ebc5098 (patch) | |
tree | bae019618dcd2cb1b90398f54e8138edf65e071e /llvm/lib/ObjectYAML/ELFEmitter.cpp | |
parent | 2c9c7d680974d4d6f39a7df52268b8e308a5b50c (diff) | |
download | bcm5719-llvm-fc9104d42a777540984c7f43f5f12f635ebc5098.tar.gz bcm5719-llvm-fc9104d42a777540984c7f43f5f12f635ebc5098.zip |
Recommit r373598 "[yaml2obj/obj2yaml] - Add support for SHT_LLVM_ADDRSIG sections."
Fix: call `consumeError()` for a case missed.
Original commit message:
SHT_LLVM_ADDRSIG is described here:
https://llvm.org/docs/Extensions.html#sht-llvm-addrsig-section-address-significance-table
This patch teaches tools to dump them and to parse the YAML declarations of such sections.
Differential revision: https://reviews.llvm.org/D68333
llvm-svn: 373606
Diffstat (limited to 'llvm/lib/ObjectYAML/ELFEmitter.cpp')
-rw-r--r-- | llvm/lib/ObjectYAML/ELFEmitter.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp index c85cf4c924f..3f3b27c5bfa 100644 --- a/llvm/lib/ObjectYAML/ELFEmitter.cpp +++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp @@ -174,6 +174,10 @@ template <class ELFT> class ELFState { void writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::HashSection &Section, ContiguousBlobAccumulator &CBA); + void writeSectionContent(Elf_Shdr &SHeader, + const ELFYAML::AddrsigSection &Section, + ContiguousBlobAccumulator &CBA); + ELFState(ELFYAML::Object &D, yaml::ErrorHandler EH); public: @@ -423,6 +427,8 @@ void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders, writeSectionContent(SHeader, *S, CBA); } else if (auto S = dyn_cast<ELFYAML::HashSection>(Sec)) { writeSectionContent(SHeader, *S, CBA); + } else if (auto S = dyn_cast<ELFYAML::AddrsigSection>(Sec)) { + writeSectionContent(SHeader, *S, CBA); } else { llvm_unreachable("Unknown section type"); } @@ -990,6 +996,30 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, Section.Content->writeAsBinary(OS); } +template <class ELFT> +void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader, + const ELFYAML::AddrsigSection &Section, + ContiguousBlobAccumulator &CBA) { + raw_ostream &OS = + CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign); + + unsigned Link = 0; + if (Section.Link.empty() && SN2I.lookup(".symtab", Link)) + SHeader.sh_link = Link; + + if (Section.Content) { + SHeader.sh_size = writeContent(OS, Section.Content, None); + return; + } + + for (const ELFYAML::AddrsigSymbol &Sym : *Section.Symbols) { + uint64_t Val = + Sym.Name ? toSymbolIndex(*Sym.Name, Section.Name, /*IsDynamic=*/false) + : (uint32_t)*Sym.Index; + SHeader.sh_size += encodeULEB128(Val, OS); + } +} + template <class ELFT> void ELFState<ELFT>::buildSectionIndex() { for (unsigned I = 0, E = Doc.Sections.size(); I != E; ++I) { StringRef Name = Doc.Sections[I]->Name; |