summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ObjectYAML/ELFEmitter.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-10-03 13:57:08 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-10-03 13:57:08 +0000
commit32cbabfecb8d48d676be683bb0c8ce082294638e (patch)
tree0100737e6468b766e9042f3a3fbfc3a661215ae8 /llvm/lib/ObjectYAML/ELFEmitter.cpp
parentc78064573643f694e65a6222b0ee47276864545c (diff)
downloadbcm5719-llvm-32cbabfecb8d48d676be683bb0c8ce082294638e.tar.gz
bcm5719-llvm-32cbabfecb8d48d676be683bb0c8ce082294638e.zip
[yaml2obj/obj2yaml] - Add support for SHT_LLVM_ADDRSIG sections.
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: 373598
Diffstat (limited to 'llvm/lib/ObjectYAML/ELFEmitter.cpp')
-rw-r--r--llvm/lib/ObjectYAML/ELFEmitter.cpp30
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;
OpenPOWER on IntegriCloud