summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ObjectYAML
diff options
context:
space:
mode:
authorGeorgii Rymar <grimar@accesssoftek.com>2019-11-28 16:27:01 +0300
committerGeorgii Rymar <grimar@accesssoftek.com>2019-11-29 10:50:00 +0300
commit13cbcf1c1a4cbfecba30e21ccd86d688e1437d06 (patch)
treedaa7ac69cebd40223c51007fed9de253e7a57f22 /llvm/lib/ObjectYAML
parent6c742fdbf48ee3ae9afb2ab1568397a3b89276e5 (diff)
downloadbcm5719-llvm-13cbcf1c1a4cbfecba30e21ccd86d688e1437d06.tar.gz
bcm5719-llvm-13cbcf1c1a4cbfecba30e21ccd86d688e1437d06.zip
[yaml2obj] - Add a way to describe content of the SHT_GNU_verneed section with "Content".
There is no way to set raw content for SHT_GNU_verneed section. This patch implements it. Differential revision: https://reviews.llvm.org/D70816
Diffstat (limited to 'llvm/lib/ObjectYAML')
-rw-r--r--llvm/lib/ObjectYAML/ELFEmitter.cpp28
-rw-r--r--llvm/lib/ObjectYAML/ELFYAML.cpp10
2 files changed, 28 insertions, 10 deletions
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index 069e3c19523..37eeb01fb09 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -1036,15 +1036,24 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
typedef typename ELFT::Vernaux Elf_Vernaux;
auto &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.VerneedV)
+ return;
uint64_t AuxCnt = 0;
- for (size_t I = 0; I < Section.VerneedV.size(); ++I) {
- const ELFYAML::VerneedEntry &VE = Section.VerneedV[I];
+ for (size_t I = 0; I < Section.VerneedV->size(); ++I) {
+ const ELFYAML::VerneedEntry &VE = (*Section.VerneedV)[I];
Elf_Verneed VerNeed;
VerNeed.vn_version = VE.Version;
VerNeed.vn_file = DotDynstr.getOffset(VE.File);
- if (I == Section.VerneedV.size() - 1)
+ if (I == Section.VerneedV->size() - 1)
VerNeed.vn_next = 0;
else
VerNeed.vn_next =
@@ -1069,9 +1078,8 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
}
}
- SHeader.sh_size = Section.VerneedV.size() * sizeof(Elf_Verneed) +
+ SHeader.sh_size = Section.VerneedV->size() * sizeof(Elf_Verneed) +
AuxCnt * sizeof(Elf_Vernaux);
- SHeader.sh_info = Section.Info;
}
template <class ELFT>
@@ -1344,10 +1352,12 @@ template <class ELFT> void ELFState<ELFT>::finalizeStrings() {
// add strings to .dynstr section.
for (const ELFYAML::Chunk *Sec : Doc.getSections()) {
if (auto VerNeed = dyn_cast<ELFYAML::VerneedSection>(Sec)) {
- for (const ELFYAML::VerneedEntry &VE : VerNeed->VerneedV) {
- DotDynstr.add(VE.File);
- for (const ELFYAML::VernauxEntry &Aux : VE.AuxV)
- DotDynstr.add(Aux.Name);
+ if (VerNeed->VerneedV) {
+ for (const ELFYAML::VerneedEntry &VE : *VerNeed->VerneedV) {
+ DotDynstr.add(VE.File);
+ for (const ELFYAML::VernauxEntry &Aux : VE.AuxV)
+ DotDynstr.add(Aux.Name);
+ }
}
} else if (auto VerDef = dyn_cast<ELFYAML::VerdefSection>(Sec)) {
if (VerDef->Entries)
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index ebda4cca97c..2a9d51486f6 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -1086,7 +1086,8 @@ static void sectionMapping(IO &IO, ELFYAML::SymverSection &Section) {
static void sectionMapping(IO &IO, ELFYAML::VerneedSection &Section) {
commonSectionMapping(IO, Section);
IO.mapRequired("Info", Section.Info);
- IO.mapRequired("Dependencies", Section.VerneedV);
+ IO.mapOptional("Dependencies", Section.VerneedV);
+ IO.mapOptional("Content", Section.Content);
}
static void sectionMapping(IO &IO, ELFYAML::RelocationSection &Section) {
@@ -1427,6 +1428,13 @@ StringRef MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::validate(
return {};
}
+ if (const auto *VD = dyn_cast<ELFYAML::VerneedSection>(C.get())) {
+ if (VD->VerneedV && VD->Content)
+ return "SHT_GNU_verneed: \"Dependencies\" and \"Content\" can't be used "
+ "together";
+ return {};
+ }
+
return {};
}
OpenPOWER on IntegriCloud