return DotShStrtab.getOffset(Name);
}
+static uint64_t writeContent(ContiguousBlobAccumulator &CBA,
+ const Optional<yaml::BinaryRef> &Content,
+ const Optional<llvm::yaml::Hex64> &Size) {
+ size_t ContentSize = 0;
+ if (Content) {
+ CBA.writeAsBinary(*Content);
+ ContentSize = Content->binary_size();
+ }
+
+ if (!Size)
+ return ContentSize;
+
+ CBA.writeZeros(*Size - ContentSize);
+ return *Size;
+}
+
template <class ELFT>
void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
ContiguousBlobAccumulator &CBA) {
}
if (Sec->EntSize)
SHeader.sh_entsize = *Sec->EntSize;
- } else if (auto S = dyn_cast<ELFYAML::RawContentSection>(Sec)) {
+
+ LocationCounter += SHeader.sh_size;
+ overrideFields<ELFT>(Sec, SHeader);
+ continue;
+ }
+
+ if (!isa<ELFYAML::NoBitsSection>(Sec) && (Sec->Content || Sec->Size))
+ SHeader.sh_size = writeContent(CBA, Sec->Content, Sec->Size);
+
+ if (auto S = dyn_cast<ELFYAML::RawContentSection>(Sec)) {
writeSectionContent(SHeader, *S, CBA);
} else if (auto S = dyn_cast<ELFYAML::SymtabShndxSection>(Sec)) {
writeSectionContent(SHeader, *S, CBA);
return Symbols.size();
}
-static uint64_t writeContent(ContiguousBlobAccumulator &CBA,
- const Optional<yaml::BinaryRef> &Content,
- const Optional<llvm::yaml::Hex64> &Size) {
- size_t ContentSize = 0;
- if (Content) {
- CBA.writeAsBinary(*Content);
- ContentSize = Content->binary_size();
- }
-
- if (!Size)
- return ContentSize;
-
- CBA.writeZeros(*Size - ContentSize);
- return *Size;
-}
-
template <class ELFT>
std::vector<typename ELFT::Sym>
ELFState<ELFT>::toELFSymbols(ArrayRef<ELFYAML::Symbol> Symbols,
void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::NoBitsSection &S,
ContiguousBlobAccumulator &CBA) {
- // SHT_NOBITS sections do not have any content to write.
- SHeader.sh_entsize = 0;
-
if (!S.Size)
return;
void ELFState<ELFT>::writeSectionContent(
Elf_Shdr &SHeader, const ELFYAML::RawContentSection &Section,
ContiguousBlobAccumulator &CBA) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
-
if (Section.EntSize)
SHeader.sh_entsize = *Section.EntSize;
if (!Section.RelocatableSec.empty())
SHeader.sh_info = toSectionIndex(Section.RelocatableSec, Section.Name);
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Relocations)
return;
SHeader.sh_entsize =
Section.EntSize ? uint64_t(*Section.EntSize) : sizeof(Elf_Relr);
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Entries)
return;
SHeader.sh_info =
toSymbolIndex(*Section.Signature, Section.Name, /*IsDynamic=*/false);
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Members)
return;
ContiguousBlobAccumulator &CBA) {
SHeader.sh_entsize = Section.EntSize ? (uint64_t)*Section.EntSize : 2;
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Entries)
return;
void ELFState<ELFT>::writeSectionContent(
Elf_Shdr &SHeader, const ELFYAML::StackSizesSection &Section,
ContiguousBlobAccumulator &CBA) {
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
+ if (!Section.Entries)
return;
- }
if (!Section.Entries)
return;
void ELFState<ELFT>::writeSectionContent(
Elf_Shdr &SHeader, const ELFYAML::LinkerOptionsSection &Section,
ContiguousBlobAccumulator &CBA) {
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Options)
return;
void ELFState<ELFT>::writeSectionContent(
Elf_Shdr &SHeader, const ELFYAML::DependentLibrariesSection &Section,
ContiguousBlobAccumulator &CBA) {
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Libs)
return;
SN2I.lookup(".symtab", Link))
SHeader.sh_link = Link;
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Entries)
return;
else
SHeader.sh_entsize = sizeof(typename ELFT::Word);
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
+ if (!Section.Bucket)
return;
- }
if (!Section.Bucket)
return;
SHeader.sh_info = Section.Info;
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Entries)
return;
SHeader.sh_info = Section.Info;
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.VerneedV)
return;
void ELFState<ELFT>::writeSectionContent(
Elf_Shdr &SHeader, const ELFYAML::ARMIndexTableSection &Section,
ContiguousBlobAccumulator &CBA) {
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Entries)
return;
else
SHeader.sh_entsize = 2 * sizeof(uintX_t);
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Entries)
return;
SN2I.lookup(".symtab", Link))
SHeader.sh_link = Link;
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
+ if (!Section.Symbols)
return;
- }
if (!Section.Symbols)
return;
void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::NoteSection &Section,
ContiguousBlobAccumulator &CBA) {
- uint64_t Offset = CBA.tell();
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
- return;
- }
-
if (!Section.Notes)
return;
+ uint64_t Offset = CBA.tell();
for (const ELFYAML::NoteEntry &NE : *Section.Notes) {
// Write name size.
if (NE.Name.empty())
SN2I.lookup(".dynsym", Link))
SHeader.sh_link = Link;
- if (Section.Content || Section.Size) {
- SHeader.sh_size = writeContent(CBA, Section.Content, Section.Size);
+ if (!Section.HashBuckets)
return;
- }
if (!Section.Header)
return;