summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ObjectYAML/ELFEmitter.cpp
diff options
context:
space:
mode:
authorGeorgii Rymar <grimar@accesssoftek.com>2019-11-22 17:18:34 +0300
committerGeorgii Rymar <grimar@accesssoftek.com>2019-11-25 12:57:53 +0300
commit9659464d7e7f30c6a1cee07c739dfe8f812924fd (patch)
tree1a066995b2f806e663c465c3608740f5c02ae296 /llvm/lib/ObjectYAML/ELFEmitter.cpp
parente841029aef74d99d1cb9443edd4a7b761d84ff45 (diff)
downloadbcm5719-llvm-9659464d7e7f30c6a1cee07c739dfe8f812924fd.tar.gz
bcm5719-llvm-9659464d7e7f30c6a1cee07c739dfe8f812924fd.zip
[yaml2obj/obj2yaml] - Add support for SHT_LLVM_DEPENDENT_LIBRARIES sections.
This section contains strings specifying libraries to be added to the link by the linker. The strings are encoded as standard null-terminated UTF-8 strings. This patch adds a way to describe and dump SHT_LLVM_DEPENDENT_LIBRARIES sections. I introduced a new YAMLFlowString type here. That used to teach obj2yaml to dump them like: ``` Libraries: [ foo, bar ] ``` instead of the following (if StringRef would be used): ``` Libraries: - foo - bar ``` Differential revision: https://reviews.llvm.org/D70598
Diffstat (limited to 'llvm/lib/ObjectYAML/ELFEmitter.cpp')
-rw-r--r--llvm/lib/ObjectYAML/ELFEmitter.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index 1a6f0a8337a..e8b54a7e602 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -203,6 +203,9 @@ template <class ELFT> class ELFState {
void writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::LinkerOptionsSection &Section,
ContiguousBlobAccumulator &CBA);
+ void writeSectionContent(Elf_Shdr &SHeader,
+ const ELFYAML::DependentLibrariesSection &Section,
+ ContiguousBlobAccumulator &CBA);
void writeFill(ELFYAML::Fill &Fill, ContiguousBlobAccumulator &CBA);
@@ -475,6 +478,8 @@ void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
writeSectionContent(SHeader, *S, CBA);
} else if (auto S = dyn_cast<ELFYAML::GnuHashSection>(Sec)) {
writeSectionContent(SHeader, *S, CBA);
+ } else if (auto S = dyn_cast<ELFYAML::DependentLibrariesSection>(Sec)) {
+ writeSectionContent(SHeader, *S, CBA);
} else {
llvm_unreachable("Unknown section type");
}
@@ -922,6 +927,28 @@ void ELFState<ELFT>::writeSectionContent(
}
template <class ELFT>
+void ELFState<ELFT>::writeSectionContent(
+ Elf_Shdr &SHeader, const ELFYAML::DependentLibrariesSection &Section,
+ ContiguousBlobAccumulator &CBA) {
+ raw_ostream &OS =
+ CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);
+
+ if (Section.Content) {
+ SHeader.sh_size = writeContent(OS, Section.Content, None);
+ return;
+ }
+
+ if (!Section.Libs)
+ return;
+
+ for (StringRef Lib : *Section.Libs) {
+ OS.write(Lib.data(), Lib.size());
+ OS.write('\0');
+ SHeader.sh_size += Lib.size() + 1;
+ }
+}
+
+template <class ELFT>
void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::HashSection &Section,
ContiguousBlobAccumulator &CBA) {
OpenPOWER on IntegriCloud