summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ObjectYAML
diff options
context:
space:
mode:
authorGeorgii Rymar <grimar@accesssoftek.com>2019-11-26 13:59:37 +0300
committerGeorgii Rymar <grimar@accesssoftek.com>2019-11-26 15:35:05 +0300
commitf69ac55d60d916e295ae0e507c5f4c2655360089 (patch)
treeac3616c84080ac435c7869b5aed0580bdf7984ac /llvm/lib/ObjectYAML
parent5f8b8d282048a9c535a90ab64bbadf576e348963 (diff)
downloadbcm5719-llvm-f69ac55d60d916e295ae0e507c5f4c2655360089.tar.gz
bcm5719-llvm-f69ac55d60d916e295ae0e507c5f4c2655360089.zip
[yaml2obj] - Teach tool to describe SHT_GNU_verdef section with a "Content" property.
There is no way to set raw content for SHT_GNU_verdef section. This patch implements it. Differential revision: https://reviews.llvm.org/D70710
Diffstat (limited to 'llvm/lib/ObjectYAML')
-rw-r--r--llvm/lib/ObjectYAML/ELFEmitter.cpp26
-rw-r--r--llvm/lib/ObjectYAML/ELFYAML.cpp10
2 files changed, 27 insertions, 9 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index e8b54a7e602..069e3c19523 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -985,9 +985,19 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
raw_ostream &OS =
CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);
+ SHeader.sh_info = Section.Info;
+
+ if (Section.Content) {
+ SHeader.sh_size = writeContent(OS, Section.Content, None);
+ return;
+ }
+
+ if (!Section.Entries)
+ return;
+
uint64_t AuxCnt = 0;
- for (size_t I = 0; I < Section.Entries.size(); ++I) {
- const ELFYAML::VerdefEntry &E = Section.Entries[I];
+ for (size_t I = 0; I < Section.Entries->size(); ++I) {
+ const ELFYAML::VerdefEntry &E = (*Section.Entries)[I];
Elf_Verdef VerDef;
VerDef.vd_version = E.Version;
@@ -996,7 +1006,7 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
VerDef.vd_hash = E.Hash;
VerDef.vd_aux = sizeof(Elf_Verdef);
VerDef.vd_cnt = E.VerNames.size();
- if (I == Section.Entries.size() - 1)
+ if (I == Section.Entries->size() - 1)
VerDef.vd_next = 0;
else
VerDef.vd_next =
@@ -1014,9 +1024,8 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
}
}
- SHeader.sh_size = Section.Entries.size() * sizeof(Elf_Verdef) +
+ SHeader.sh_size = Section.Entries->size() * sizeof(Elf_Verdef) +
AuxCnt * sizeof(Elf_Verdaux);
- SHeader.sh_info = Section.Info;
}
template <class ELFT>
@@ -1341,9 +1350,10 @@ template <class ELFT> void ELFState<ELFT>::finalizeStrings() {
DotDynstr.add(Aux.Name);
}
} else if (auto VerDef = dyn_cast<ELFYAML::VerdefSection>(Sec)) {
- for (const ELFYAML::VerdefEntry &E : VerDef->Entries)
- for (StringRef Name : E.VerNames)
- DotDynstr.add(Name);
+ if (VerDef->Entries)
+ for (const ELFYAML::VerdefEntry &E : *VerDef->Entries)
+ for (StringRef Name : E.VerNames)
+ DotDynstr.add(Name);
}
}
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index a5e5894af04..ebda4cca97c 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1074,7 +1074,8 @@ static void sectionMapping(IO &IO, ELFYAML::NoBitsSection &Section) {
static void sectionMapping(IO &IO, ELFYAML::VerdefSection &Section) {
commonSectionMapping(IO, Section);
IO.mapRequired("Info", Section.Info);
- IO.mapRequired("Entries", Section.Entries);
+ IO.mapOptional("Entries", Section.Entries);
+ IO.mapOptional("Content", Section.Content);
}
static void sectionMapping(IO &IO, ELFYAML::SymverSection &Section) {
@@ -1419,6 +1420,13 @@ StringRef MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::validate(
return {};
}
+ if (const auto *VD = dyn_cast<ELFYAML::VerdefSection>(C.get())) {
+ if (VD->Entries && VD->Content)
+ return "SHT_GNU_verdef: \"Entries\" and \"Content\" can't be used "
+ "together";
+ return {};
+ }
+
return {};
}
OpenPOWER on IntegriCloud