summaryrefslogtreecommitdiffstats
path: root/llvm/tools/obj2yaml
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/obj2yaml')
-rw-r--r--llvm/tools/obj2yaml/elf2yaml.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp
index 15c38c630b9..3dc48b8b880 100644
--- a/llvm/tools/obj2yaml/elf2yaml.cpp
+++ b/llvm/tools/obj2yaml/elf2yaml.cpp
@@ -62,6 +62,8 @@ class ELFDumper {
Expected<ELFYAML::AddrsigSection *> dumpAddrsigSection(const Elf_Shdr *Shdr);
Expected<ELFYAML::LinkerOptionsSection *>
dumpLinkerOptionsSection(const Elf_Shdr *Shdr);
+ Expected<ELFYAML::DependentLibrariesSection *>
+ dumpDependentLibrariesSection(const Elf_Shdr *Shdr);
Expected<ELFYAML::DynamicSection *> dumpDynamicSection(const Elf_Shdr *Shdr);
Expected<ELFYAML::RelocationSection *> dumpRelocSection(const Elf_Shdr *Shdr);
Expected<ELFYAML::RawContentSection *>
@@ -325,6 +327,14 @@ template <class ELFT> Expected<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
Y->Chunks.emplace_back(*SecOrErr);
break;
}
+ case ELF::SHT_LLVM_DEPENDENT_LIBRARIES: {
+ Expected<ELFYAML::DependentLibrariesSection *> SecOrErr =
+ dumpDependentLibrariesSection(&Sec);
+ if (!SecOrErr)
+ return SecOrErr.takeError();
+ Y->Chunks.emplace_back(*SecOrErr);
+ break;
+ }
case ELF::SHT_NULL: {
// We only dump the SHT_NULL section at index 0 when it
// has at least one non-null field, because yaml2obj
@@ -630,6 +640,33 @@ ELFDumper<ELFT>::dumpLinkerOptionsSection(const Elf_Shdr *Shdr) {
}
template <class ELFT>
+Expected<ELFYAML::DependentLibrariesSection *>
+ELFDumper<ELFT>::dumpDependentLibrariesSection(const Elf_Shdr *Shdr) {
+ auto DL = std::make_unique<ELFYAML::DependentLibrariesSection>();
+ if (Error E = dumpCommonSection(Shdr, *DL))
+ return std::move(E);
+
+ Expected<ArrayRef<uint8_t>> ContentOrErr = Obj.getSectionContents(Shdr);
+ if (!ContentOrErr)
+ return ContentOrErr.takeError();
+
+ ArrayRef<uint8_t> Content = *ContentOrErr;
+ if (!Content.empty() && Content.back() != 0) {
+ DL->Content = Content;
+ return DL.release();
+ }
+
+ DL->Libs.emplace();
+ for (const uint8_t *I = Content.begin(), *E = Content.end(); I < E;) {
+ StringRef Lib((const char *)I);
+ DL->Libs->emplace_back(Lib);
+ I += Lib.size() + 1;
+ }
+
+ return DL.release();
+}
+
+template <class ELFT>
Expected<ELFYAML::DynamicSection *>
ELFDumper<ELFT>::dumpDynamicSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::DynamicSection>();
OpenPOWER on IntegriCloud