summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorXing GUO <higuoxing@gmail.com>2018-12-07 10:31:34 +0000
committerXing GUO <higuoxing@gmail.com>2018-12-07 10:31:34 +0000
commit63e123464b4fa9f45b4a027347a4167cc6620692 (patch)
treeff4add86d0358822cca286ef5b3e730b35bfbd17 /llvm/tools
parentc56cc3a889f794db4b4c1deae67b64d436f7a656 (diff)
downloadbcm5719-llvm-63e123464b4fa9f45b4a027347a4167cc6620692.tar.gz
bcm5719-llvm-63e123464b4fa9f45b4a027347a4167cc6620692.zip
[yaml2obj] format some codes NFC.
Summary: This line is longer than 80 characters. Subscribers: llvm-commits, jakehehrlich Differential Revision: https://reviews.llvm.org/D55419 llvm-svn: 348578
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/yaml2obj/yaml2elf.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp
index bd4c1c3e998..5c3eb13cca4 100644
--- a/llvm/tools/yaml2obj/yaml2elf.cpp
+++ b/llvm/tools/yaml2obj/yaml2elf.cpp
@@ -158,6 +158,9 @@ class ELFState {
bool writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::Group &Group,
ContiguousBlobAccumulator &CBA);
bool writeSectionContent(Elf_Shdr &SHeader,
+ const ELFYAML::VersionNeedSection &Section,
+ ContiguousBlobAccumulator &CBA);
+ bool writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::MipsABIFlags &Section,
ContiguousBlobAccumulator &CBA);
bool hasDynamicSymbols() const;
@@ -292,6 +295,13 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
// SHT_NOBITS section does not have content
// so just to setup the section offset.
CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);
+ } else if (auto S = dyn_cast<ELFYAML::VersionNeedSection>(Sec.get())) {
+ if (S->Link.empty())
+ // For VersionNeed section set link to .dynstr by default.
+ SHeader.sh_link = getDotDynStrSecNo();
+
+ if (!writeSectionContent(SHeader, *S, CBA))
+ return false;
} else
llvm_unreachable("Unknown section type");
@@ -548,6 +558,55 @@ bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
}
template <class ELFT>
+bool ELFState<ELFT>::writeSectionContent(
+ Elf_Shdr &SHeader, const ELFYAML::VersionNeedSection &Section,
+ ContiguousBlobAccumulator &CBA) {
+ assert(Section.Type == llvm::ELF::SHT_GNU_verneed &&
+ "Section type is not SHT_GNU_verneed");
+
+ typedef typename ELFT::Verneed Elf_Verneed;
+ typedef typename ELFT::Vernaux Elf_Vernaux;
+
+ uint64_t BlobSize = 0;
+ SHeader.sh_info = Section.VersionNeeds.size();
+ auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);
+
+ for (auto VNeedIt = Section.VersionNeeds.begin();
+ VNeedIt != Section.VersionNeeds.end(); ++VNeedIt) {
+ Elf_Verneed VNeed;
+
+ VNeed.vn_version = VNeedIt->Version;
+ VNeed.vn_cnt = VNeedIt->Auxiliaries.size();
+ // VNeed.vn_file = DotDynstr.add(VNeedIt->File);
+ // errs() << "Need Name: " << VNeedIt->File << " Index: " << DotDynstr.add(VNeedIt->File) << '\n';
+ VNeed.vn_aux = sizeof(Elf_Verneed);
+ VNeed.vn_next =
+ (VNeedIt != Section.VersionNeeds.end() - 1)
+ ? sizeof(Elf_Verneed) + VNeed.vn_cnt * sizeof(Elf_Vernaux)
+ : 0;
+ BlobSize += sizeof(Elf_Verneed);
+ OS.write((const char *)&VNeed, sizeof(VNeed));
+
+ for (auto VNeedAuxIt = VNeedIt->Auxiliaries.begin();
+ VNeedAuxIt != VNeedIt->Auxiliaries.end(); ++VNeedAuxIt) {
+ Elf_Vernaux VNeedAux;
+ zero(VNeedAux);
+ VNeedAux.vna_hash = VNeedAuxIt->Hash;
+ VNeedAux.vna_flags = VNeedAuxIt->Flags;
+ VNeedAux.vna_other = VNeedAuxIt->Other;
+ // VNeedAux.vna_name = DotDynstr.add(VNeedAuxIt->Name);
+ VNeedAux.vna_next = (VNeedAuxIt != VNeedIt->Auxiliaries.end() - 1)
+ ? sizeof(Elf_Vernaux)
+ : 0;
+ BlobSize += sizeof(Elf_Vernaux);
+ OS.write((const char *)&VNeedAux, sizeof(Elf_Vernaux));
+ }
+ }
+ SHeader.sh_size = BlobSize;
+ return true;
+}
+
+template <class ELFT>
bool ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::MipsABIFlags &Section,
ContiguousBlobAccumulator &CBA) {
OpenPOWER on IntegriCloud