39 StringMap<unsigned> Map;
43 bool addName(StringRef Name,
unsigned Ndx) {
44 return Map.insert({
Name, Ndx}).second;
47 bool lookup(StringRef Name,
unsigned &Idx)
const {
48 auto I = Map.find(Name);
55 unsigned get(StringRef Name)
const {
59 assert(
false &&
"Expected section not found in index");
62 unsigned size()
const {
return Map.size(); }
77template <
class ELFT>
class ELFState {
97 StringRef SectionHeaderStringTableName =
".shstrtab";
98 StringTableBuilder *ShStrtabStrings = &DotShStrtab;
102 NameToIdxMap DynSymN2I;
103 ELFYAML::Object &Doc;
105 std::vector<std::pair<Elf_Shdr *, ELFYAML::Section>>
106 SectionHeadersOverrideHelper;
108 StringSet<> ExcludedSectionHeaders;
110 uint64_t LocationCounter = 0;
111 bool HasError =
false;
117 const StringTableBuilder &Strtab);
118 unsigned toSectionIndex(StringRef S, StringRef LocSec, StringRef LocSym =
"");
119 unsigned toSymbolIndex(StringRef S, StringRef LocSec,
bool IsDynamic);
121 void buildSectionIndex();
122 void buildSymbolIndexes();
123 void initProgramHeaders(std::vector<Elf_Phdr> &PHeaders);
124 bool initImplicitHeader(ContiguousBlobAccumulator &CBA, Elf_Shdr &Header,
125 StringRef SecName, ELFYAML::Section *YAMLSec);
126 void initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
127 ContiguousBlobAccumulator &CBA);
128 void overrideSectionHeaders(std::vector<Elf_Shdr> &SHeaders);
129 void initSymtabSectionHeader(Elf_Shdr &SHeader, SymtabType STType,
130 ContiguousBlobAccumulator &CBA,
131 ELFYAML::Section *YAMLSec);
132 void initStrtabSectionHeader(Elf_Shdr &SHeader, StringRef Name,
133 StringTableBuilder &STB,
134 ContiguousBlobAccumulator &CBA,
135 ELFYAML::Section *YAMLSec);
136 void initDWARFSectionHeader(Elf_Shdr &SHeader, StringRef Name,
137 ContiguousBlobAccumulator &CBA,
138 ELFYAML::Section *YAMLSec);
139 void setProgramHeaderLayout(std::vector<Elf_Phdr> &PHeaders,
140 std::vector<Elf_Shdr> &SHeaders);
142 std::vector<Fragment>
143 getPhdrFragments(
const ELFYAML::ProgramHeader &Phdr,
146 void finalizeStrings();
147 void writeELFHeader(raw_ostream &OS);
148 void writeSectionContent(Elf_Shdr &SHeader,
149 const ELFYAML::NoBitsSection &Section,
150 ContiguousBlobAccumulator &CBA);
151 void writeSectionContent(Elf_Shdr &SHeader,
152 const ELFYAML::RawContentSection &Section,
153 ContiguousBlobAccumulator &CBA);
154 void writeSectionContent(Elf_Shdr &SHeader,
155 const ELFYAML::RelocationSection &Section,
156 ContiguousBlobAccumulator &CBA);
157 void writeSectionContent(Elf_Shdr &SHeader,
158 const ELFYAML::RelrSection &Section,
159 ContiguousBlobAccumulator &CBA);
160 void writeSectionContent(Elf_Shdr &SHeader,
161 const ELFYAML::GroupSection &Group,
162 ContiguousBlobAccumulator &CBA);
163 void writeSectionContent(Elf_Shdr &SHeader,
164 const ELFYAML::SymtabShndxSection &Shndx,
165 ContiguousBlobAccumulator &CBA);
166 void writeSectionContent(Elf_Shdr &SHeader,
167 const ELFYAML::SymverSection &Section,
168 ContiguousBlobAccumulator &CBA);
169 void writeSectionContent(Elf_Shdr &SHeader,
170 const ELFYAML::VerneedSection &Section,
171 ContiguousBlobAccumulator &CBA);
172 void writeSectionContent(Elf_Shdr &SHeader,
173 const ELFYAML::VerdefSection &Section,
174 ContiguousBlobAccumulator &CBA);
175 void writeSectionContent(Elf_Shdr &SHeader,
176 const ELFYAML::ARMIndexTableSection &Section,
177 ContiguousBlobAccumulator &CBA);
178 void writeSectionContent(Elf_Shdr &SHeader,
179 const ELFYAML::MipsABIFlags &Section,
180 ContiguousBlobAccumulator &CBA);
181 void writeSectionContent(Elf_Shdr &SHeader,
182 const ELFYAML::DynamicSection &Section,
183 ContiguousBlobAccumulator &CBA);
184 void writeSectionContent(Elf_Shdr &SHeader,
185 const ELFYAML::StackSizesSection &Section,
186 ContiguousBlobAccumulator &CBA);
187 void writeSectionContent(Elf_Shdr &SHeader,
188 const ELFYAML::BBAddrMapSection &Section,
189 ContiguousBlobAccumulator &CBA);
190 void writeSectionContent(Elf_Shdr &SHeader,
191 const ELFYAML::HashSection &Section,
192 ContiguousBlobAccumulator &CBA);
193 void writeSectionContent(Elf_Shdr &SHeader,
194 const ELFYAML::AddrsigSection &Section,
195 ContiguousBlobAccumulator &CBA);
196 void writeSectionContent(Elf_Shdr &SHeader,
197 const ELFYAML::NoteSection &Section,
198 ContiguousBlobAccumulator &CBA);
199 void writeSectionContent(Elf_Shdr &SHeader,
200 const ELFYAML::GnuHashSection &Section,
201 ContiguousBlobAccumulator &CBA);
202 void writeSectionContent(Elf_Shdr &SHeader,
203 const ELFYAML::LinkerOptionsSection &Section,
204 ContiguousBlobAccumulator &CBA);
205 void writeSectionContent(Elf_Shdr &SHeader,
206 const ELFYAML::DependentLibrariesSection &Section,
207 ContiguousBlobAccumulator &CBA);
208 void writeSectionContent(Elf_Shdr &SHeader,
209 const ELFYAML::CallGraphProfileSection &Section,
210 ContiguousBlobAccumulator &CBA);
212 void writeFill(ELFYAML::Fill &Fill, ContiguousBlobAccumulator &CBA);
216 void assignSectionAddress(Elf_Shdr &SHeader, ELFYAML::Section *YAMLSec);
218 DenseMap<StringRef, size_t> buildSectionHeaderReorderMap();
221 uint64_t alignToOffset(ContiguousBlobAccumulator &CBA, uint64_t Align,
222 std::optional<llvm::yaml::Hex64>
Offset);
224 uint64_t getSectionNameOffset(StringRef Name);
227 static bool writeELF(raw_ostream &OS, ELFYAML::Object &Doc,
233 return A.size() *
sizeof(
T);
240template <
class T>
static void zero(
T &Obj) { memset(&Obj, 0,
sizeof(Obj)); }
244 : Doc(
D), ErrHandler(EH) {
248 if (Doc.Header.SectionHeaderStringTable) {
249 SectionHeaderStringTableName = *Doc.Header.SectionHeaderStringTable;
250 if (*Doc.Header.SectionHeaderStringTable ==
".strtab")
251 ShStrtabStrings = &DotStrtab;
252 else if (*Doc.Header.SectionHeaderStringTable ==
".dynstr")
253 ShStrtabStrings = &DotDynstr;
257 std::vector<ELFYAML::Section *> Sections = Doc.getSections();
262 std::make_unique<ELFYAML::Section>(
267 for (
size_t I = 0;
I < Doc.Chunks.size(); ++
I) {
268 const std::unique_ptr<ELFYAML::Chunk> &
C = Doc.Chunks[
I];
273 reportError(
"multiple section header tables are not allowed");
281 if (
C->Name.empty()) {
288 if (!DocSections.insert(
C->Name).second)
290 "' at YAML section/fill number " +
Twine(
I));
294 if (Doc.DynamicSymbols) {
295 if (SectionHeaderStringTableName ==
".dynsym")
296 reportError(
"cannot use '.dynsym' as the section header name table when "
297 "there are dynamic symbols");
298 ImplicitSections.insert(
".dynsym");
299 ImplicitSections.insert(
".dynstr");
302 if (SectionHeaderStringTableName ==
".symtab")
303 reportError(
"cannot use '.symtab' as the section header name table when "
304 "there are symbols");
305 ImplicitSections.insert(
".symtab");
308 for (
StringRef DebugSecName : Doc.DWARF->getNonEmptySectionNames()) {
309 std::string SecName = (
"." + DebugSecName).str();
312 if (SectionHeaderStringTableName == SecName)
313 reportError(
"cannot use '" + SecName +
314 "' as the section header name table when it is needed for "
316 ImplicitSections.insert(StringRef(SecName).copy(StringAlloc));
319 ImplicitSections.
insert(
".strtab");
320 if (!SecHdrTable || !SecHdrTable->NoHeaders.value_or(
false))
321 ImplicitSections.
insert(SectionHeaderStringTableName);
326 if (DocSections.count(SecName))
329 std::unique_ptr<ELFYAML::Section> Sec = std::make_unique<ELFYAML::Section>(
333 if (SecName == SectionHeaderStringTableName)
335 else if (SecName ==
".dynsym")
337 else if (SecName ==
".symtab")
347 if (Doc.Chunks.back().get() == SecHdrTable)
348 Doc.Chunks.insert(Doc.Chunks.end() - 1, std::move(Sec));
350 Doc.Chunks.push_back(std::move(Sec));
356 Doc.Chunks.push_back(
357 std::make_unique<ELFYAML::SectionHeaderTable>(
true));
361void ELFState<ELFT>::writeELFHeader(
raw_ostream &OS) {
366 Header.e_ident[
EI_MAG0] = 0x7f;
371 Header.e_ident[
EI_DATA] = Doc.Header.Data;
373 Header.e_ident[
EI_OSABI] = Doc.Header.OSABI;
375 Header.e_type = Doc.Header.Type;
377 if (Doc.Header.Machine)
378 Header.e_machine = *Doc.Header.Machine;
383 Header.e_entry = Doc.Header.Entry;
384 if (Doc.Header.Flags)
385 Header.e_flags = *Doc.Header.Flags;
389 Header.e_ehsize =
sizeof(Elf_Ehdr);
391 if (Doc.Header.EPhOff)
392 Header.e_phoff = *Doc.Header.EPhOff;
393 else if (!Doc.ProgramHeaders.empty())
394 Header.e_phoff =
sizeof(Header);
398 if (Doc.Header.EPhEntSize)
399 Header.e_phentsize = *Doc.Header.EPhEntSize;
400 else if (!Doc.ProgramHeaders.empty())
401 Header.e_phentsize =
sizeof(Elf_Phdr);
403 Header.e_phentsize = 0;
405 if (Doc.Header.EPhNum)
406 Header.e_phnum = *Doc.Header.EPhNum;
407 else if (!Doc.ProgramHeaders.empty())
408 Header.e_phnum = Doc.ProgramHeaders.size();
412 Header.e_shentsize = Doc.Header.EShEntSize ? (
uint16_t)*Doc.Header.EShEntSize
416 Doc.getSectionHeaderTable();
418 if (Doc.Header.EShOff)
419 Header.e_shoff = *Doc.Header.EShOff;
421 Header.e_shoff = *SectionHeaders.
Offset;
425 if (Doc.Header.EShNum)
426 Header.e_shnum = *Doc.Header.EShNum;
428 Header.e_shnum = SectionHeaders.
getNumHeaders(Doc.getSections().size());
430 if (Doc.Header.EShStrNdx)
431 Header.e_shstrndx = *Doc.Header.EShStrNdx;
433 !ExcludedSectionHeaders.count(SectionHeaderStringTableName))
434 Header.e_shstrndx = SN2I.get(SectionHeaderStringTableName);
436 Header.e_shstrndx = 0;
438 OS.
write((
const char *)&Header,
sizeof(Header));
442void ELFState<ELFT>::initProgramHeaders(std::vector<Elf_Phdr> &PHeaders) {
444 for (
size_t I = 0,
E = Doc.Chunks.size();
I !=
E; ++
I) {
445 NameToIndex[Doc.Chunks[
I]->Name] =
I + 1;
448 for (
size_t I = 0,
E = Doc.ProgramHeaders.size();
I !=
E; ++
I) {
452 Phdr.p_type = YamlPhdr.
Type;
453 Phdr.p_flags = YamlPhdr.
Flags;
454 Phdr.p_vaddr = YamlPhdr.
VAddr;
455 Phdr.p_paddr = YamlPhdr.
PAddr;
456 PHeaders.push_back(Phdr);
465 "' by the 'FirstSec' key of the program header with index " +
470 "' by the 'LastSec' key of the program header with index " +
477 ": the section index of " + *YamlPhdr.
FirstSec +
478 " is greater than the index of " + *YamlPhdr.
LastSec);
481 YamlPhdr.
Chunks.push_back(Doc.Chunks[
I - 1].get());
491 if (!SN2I.lookup(S, Index) && !
to_integer(S, Index)) {
493 reportError(
"unknown section referenced: '" + S +
"' by YAML symbol '" +
496 reportError(
"unknown section referenced: '" + S +
"' by YAML section '" +
502 Doc.getSectionHeaderTable();
509 size_t FirstExcluded =
511 if (Index > FirstExcluded) {
513 reportError(
"unable to link '" + LocSec +
"' to excluded section '" + S +
516 reportError(
"excluded section referenced: '" + S +
"' by symbol '" +
525 const NameToIdxMap &
SymMap = IsDynamic ? DynSymN2I : SymN2I;
530 reportError(
"unknown symbol referenced: '" + S +
"' by YAML section '" +
546 To.sh_name = *From->
ShName;
550 To.sh_size = *From->
ShSize;
552 To.sh_type = *From->
ShType;
560 if (Header.sh_offset)
563 if (SecName ==
".strtab")
564 initStrtabSectionHeader(Header, SecName, DotStrtab, CBA, YAMLSec);
565 else if (SecName ==
".dynstr")
566 initStrtabSectionHeader(Header, SecName, DotDynstr, CBA, YAMLSec);
567 else if (SecName == SectionHeaderStringTableName)
568 initStrtabSectionHeader(Header, SecName, *ShStrtabStrings, CBA, YAMLSec);
569 else if (SecName ==
".symtab")
570 initSymtabSectionHeader(Header, SymtabType::Static, CBA, YAMLSec);
571 else if (SecName ==
".dynsym")
572 initSymtabSectionHeader(Header, SymtabType::Dynamic, CBA, YAMLSec);
578 initDWARFSectionHeader(Header, SecName, CBA, YAMLSec);
582 LocationCounter += Header.sh_size;
595 std::string Ret = Name.empty() ?
"" : Name.str() +
' ';
610 return S.
substr(0, SuffixPos - 1);
617 if (ExcludedSectionHeaders.count(Name))
619 return ShStrtabStrings->getOffset(Name);
623 const std::optional<yaml::BinaryRef> &Content,
624 const std::optional<llvm::yaml::Hex64> &
Size) {
625 size_t ContentSize = 0;
628 ContentSize = Content->binary_size();
662void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
666 SHeaders.resize(Doc.getSections().size());
668 for (
const std::unique_ptr<ELFYAML::Chunk> &
D : Doc.Chunks) {
670 S->Offset = alignToOffset(CBA, 1, S->Offset);
672 LocationCounter += S->Size;
678 if (S->NoHeaders.value_or(
false))
682 S->Offset = alignToOffset(CBA,
sizeof(
typename ELFT::uint),
685 S->Offset = alignToOffset(CBA, 1, S->Offset);
687 uint64_t Size = S->getNumHeaders(SHeaders.size()) *
sizeof(Elf_Shdr);
691 LocationCounter +=
Size;
696 bool IsFirstUndefSection = Sec == Doc.getSections().front();
700 Elf_Shdr &SHeader = SHeaders[SN2I.get(Sec->
Name)];
702 SHeader.sh_link = toSectionIndex(*Sec->
Link, Sec->
Name);
706 if (!LinkSec.
empty() && !ExcludedSectionHeaders.count(LinkSec) &&
707 SN2I.lookup(LinkSec, Link))
708 SHeader.sh_link = Link;
712 SHeader.sh_entsize = *Sec->
EntSize;
721 if (initImplicitHeader(CBA, SHeader, Sec->
Name,
725 assert(Sec &&
"It can't be null unless it is an implicit section. But all "
726 "implicit sections should already have been handled above.");
730 SHeader.sh_type = Sec->
Type;
732 SHeader.sh_flags = *Sec->
Flags;
737 if (!IsFirstUndefSection || Sec->
Offset)
738 SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign, Sec->
Offset);
740 assignSectionAddress(SHeader, Sec);
742 if (IsFirstUndefSection) {
746 SHeader.sh_size = *RawSec->Size;
748 SHeader.sh_info = *RawSec->Info;
751 LocationCounter += SHeader.sh_size;
752 SectionHeadersOverrideHelper.push_back({&SHeader, *Sec});
760 writeSectionContent(SHeader, *S, CBA);
762 writeSectionContent(SHeader, *S, CBA);
764 writeSectionContent(SHeader, *S, CBA);
766 writeSectionContent(SHeader, *S, CBA);
768 writeSectionContent(SHeader, *S, CBA);
770 writeSectionContent(SHeader, *S, CBA);
772 writeSectionContent(SHeader, *S, CBA);
774 writeSectionContent(SHeader, *S, CBA);
776 writeSectionContent(SHeader, *S, CBA);
778 writeSectionContent(SHeader, *S, CBA);
780 writeSectionContent(SHeader, *S, CBA);
782 writeSectionContent(SHeader, *S, CBA);
784 writeSectionContent(SHeader, *S, CBA);
786 writeSectionContent(SHeader, *S, CBA);
788 writeSectionContent(SHeader, *S, CBA);
790 writeSectionContent(SHeader, *S, CBA);
792 writeSectionContent(SHeader, *S, CBA);
794 writeSectionContent(SHeader, *S, CBA);
796 writeSectionContent(SHeader, *S, CBA);
798 writeSectionContent(SHeader, *S, CBA);
800 writeSectionContent(SHeader, *S, CBA);
805 LocationCounter += SHeader.sh_size;
806 SectionHeadersOverrideHelper.push_back({&SHeader, *Sec});
811void ELFState<ELFT>::overrideSectionHeaders(std::vector<Elf_Shdr> &SHeaders) {
812 for (std::pair<Elf_Shdr *, ELFYAML::Section> &HeaderAndSec :
813 SectionHeadersOverrideHelper)
818void ELFState<ELFT>::assignSectionAddress(Elf_Shdr &SHeader,
820 if (YAMLSec && YAMLSec->
Address) {
821 SHeader.sh_addr = *YAMLSec->
Address;
822 LocationCounter = *YAMLSec->
Address;
834 alignTo(LocationCounter, SHeader.sh_addralign ? SHeader.sh_addralign : 1);
835 SHeader.sh_addr = LocationCounter;
839 for (
size_t I = 0;
I < Symbols.size(); ++
I)
842 return Symbols.size();
846std::vector<typename ELFT::Sym>
849 std::vector<Elf_Sym> Ret;
850 Ret.resize(
Symbols.size() + 1);
854 Elf_Sym &Symbol = Ret[++
I];
860 Symbol.st_name = *Sym.StName;
861 else if (!Sym.Name.empty())
864 Symbol.setBindingAndType(Sym.Binding, Sym.Type);
866 Symbol.st_shndx = toSectionIndex(*Sym.Section,
"", Sym.Name);
868 Symbol.st_shndx = *Sym.Index;
870 Symbol.st_value = Sym.Value.value_or(yaml::Hex64(0));
871 Symbol.st_other = Sym.Other.value_or(0);
872 Symbol.st_size = Sym.Size.value_or(yaml::Hex64(0));
879void ELFState<ELFT>::initSymtabSectionHeader(Elf_Shdr &SHeader,
884 bool IsStatic = STType == SymtabType::Static;
886 if (IsStatic && Doc.Symbols)
888 else if (!IsStatic && Doc.DynamicSymbols)
894 bool HasSymbolsDescription =
895 (IsStatic && Doc.Symbols) || (!IsStatic && Doc.DynamicSymbols);
896 if (HasSymbolsDescription) {
899 reportError(
"cannot specify both `Content` and " + Property +
900 " for symbol table section '" + RawSec->
Name +
"'");
902 reportError(
"cannot specify both `Size` and " + Property +
903 " for symbol table section '" + RawSec->
Name +
"'");
908 SHeader.sh_name = getSectionNameOffset(IsStatic ?
".symtab" :
".dynsym");
911 SHeader.sh_type = YAMLSec->
Type;
915 if (YAMLSec && YAMLSec->
Flags)
916 SHeader.sh_flags = *YAMLSec->
Flags;
922 SHeader.sh_info = (RawSec && RawSec->
Info) ? (
unsigned)(*RawSec->
Info)
926 assignSectionAddress(SHeader, YAMLSec);
928 SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign,
929 RawSec ? RawSec->
Offset : std::nullopt);
937 std::vector<Elf_Sym> Syms =
938 toELFSymbols(Symbols, IsStatic ? DotStrtab : DotDynstr);
939 SHeader.sh_size = Syms.size() *
sizeof(Elf_Sym);
940 CBA.
write((
const char *)Syms.data(), SHeader.sh_size);
944void ELFState<ELFT>::initStrtabSectionHeader(Elf_Shdr &SHeader,
StringRef Name,
955 SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign,
956 YAMLSec ? YAMLSec->
Offset : std::nullopt);
963 SHeader.sh_size = STB.
getSize();
966 if (RawSec && RawSec->
Info)
967 SHeader.sh_info = *RawSec->
Info;
969 if (YAMLSec && YAMLSec->
Flags)
970 SHeader.sh_flags = *YAMLSec->
Flags;
971 else if (Name ==
".dynstr")
974 assignSectionAddress(SHeader, YAMLSec);
979 return Name.consume_front(
".") && DebugSecNames.
count(Name);
996 if (
Error Err = EmitFunc(*OS, DWARF))
997 return std::move(Err);
999 return CBA.
tell() - BeginOffset;
1002template <
class ELFT>
1003void ELFState<ELFT>::initDWARFSectionHeader(Elf_Shdr &SHeader,
StringRef Name,
1009 SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign,
1010 YAMLSec ? YAMLSec->
Offset : std::nullopt);
1017 "' contents in the 'DWARF' entry and the 'Content' "
1018 "or 'Size' in the 'Sections' entry at the same time");
1022 SHeader.sh_size = *ShSizeOrErr;
1030 "entry or a RawContentSection");
1032 if (RawSec && RawSec->
Info)
1033 SHeader.sh_info = *RawSec->
Info;
1035 if (YAMLSec && YAMLSec->
Flags)
1036 SHeader.sh_flags = *YAMLSec->
Flags;
1037 else if (Name ==
".debug_str")
1040 assignSectionAddress(SHeader, YAMLSec);
1043template <
class ELFT>
void ELFState<ELFT>::reportError(
const Twine &
Msg) {
1048template <
class ELFT>
void ELFState<ELFT>::reportError(
Error Err) {
1054template <
class ELFT>
1055std::vector<Fragment>
1058 std::vector<Fragment> Ret;
1067 const Elf_Shdr &
H = SHeaders[SN2I.get(S->
Name)];
1068 Ret.push_back({
H.sh_offset,
H.sh_size,
H.sh_type,
H.sh_addralign});
1073template <
class ELFT>
1074void ELFState<ELFT>::setProgramHeaderLayout(std::vector<Elf_Phdr> &PHeaders,
1075 std::vector<Elf_Shdr> &SHeaders) {
1077 for (
auto &YamlPhdr : Doc.ProgramHeaders) {
1078 Elf_Phdr &PHeader = PHeaders[PhdrIdx++];
1079 std::vector<Fragment> Fragments = getPhdrFragments(YamlPhdr, SHeaders);
1081 return A.Offset <
B.Offset;
1083 reportError(
"sections in the program header with index " +
1084 Twine(PhdrIdx) +
" are not sorted by their file offset");
1087 if (!Fragments.empty() && *YamlPhdr.
Offset > Fragments.front().Offset)
1089 " must be less than or equal to the minimum file offset of "
1090 "all included sections (0x" +
1092 PHeader.p_offset = *YamlPhdr.
Offset;
1093 }
else if (!Fragments.empty()) {
1094 PHeader.p_offset = Fragments.front().Offset;
1099 PHeader.p_filesz = *YamlPhdr.
FileSize;
1100 }
else if (!Fragments.empty()) {
1101 uint64_t FileSize = Fragments.back().Offset - PHeader.p_offset;
1106 FileSize += Fragments.back().Size;
1107 PHeader.p_filesz = FileSize;
1111 uint64_t MemOffset = PHeader.p_offset;
1112 for (
const Fragment &
F : Fragments)
1113 MemOffset = std::max(MemOffset,
F.Offset +
F.Size);
1116 : MemOffset - PHeader.p_offset;
1118 if (YamlPhdr.
Align) {
1119 PHeader.p_align = *YamlPhdr.
Align;
1124 PHeader.p_align = 1;
1125 for (
const Fragment &
F : Fragments)
1126 PHeader.p_align = std::max((
uint64_t)PHeader.p_align,
F.AddrAlign);
1137 return (isa<ELFYAML::Fill>(C) ||
1138 cast<ELFYAML::Section>(C)->Type != ELF::SHT_NOBITS);
1145template <
class ELFT>
1146void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1152 SHeader.sh_size = *S.
Size;
1157 if (shouldAllocateFileSpace(Doc.ProgramHeaders, S))
1161template <
class ELFT>
1162void ELFState<ELFT>::writeSectionContent(
1166 SHeader.sh_info = *Section.Info;
1175template <
class ELFT>
1176void ELFState<ELFT>::writeSectionContent(
1182 "Section type is not SHT_REL nor SHT_RELA");
1184 if (!
Section.RelocatableSec.empty())
1185 SHeader.sh_info = toSectionIndex(
Section.RelocatableSec,
Section.Name);
1192 typename ELFT::uint OffsetMask = 8,
Offset = 0, Addend = 0;
1197 OffsetMask |= Rel.
Offset;
1203 const bool IsDynamic =
Section.Link && (*
Section.Link ==
".dynsym");
1211 (
static_cast<typename ELFT::uint
>(Rel.
Offset) -
Offset) >> Shift;
1214 DeltaOffset * 8 + (SymIdx != CurSymIdx) + (
Type != Rel.
Type ? 2 : 0) +
1215 (Addend !=
static_cast<typename ELFT::uint
>(Rel.
Addend) ? 4 : 0);
1216 if (DeltaOffset < 0x10) {
1225 std::make_signed_t<typename ELFT::uint>(CurSymIdx - SymIdx));
1234 std::make_signed_t<typename ELFT::uint>(Rel.
Addend - Addend));
1237 }
else if (IsRela) {
1240 REntry.r_offset = Rel.
Offset;
1241 REntry.r_addend = Rel.
Addend;
1243 CBA.
write((
const char *)&REntry,
sizeof(REntry));
1247 REntry.r_offset = Rel.
Offset;
1249 CBA.
write((
const char *)&REntry,
sizeof(REntry));
1253 SHeader.sh_size = CBA.
getOffset() - CurrentOffset;
1256template <
class ELFT>
1257void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1263 for (llvm::yaml::Hex64
E : *
Section.Entries) {
1264 if (!ELFT::Is64Bits &&
E > UINT32_MAX)
1267 CBA.
write<uintX_t>(
E, ELFT::Endianness);
1270 SHeader.sh_size =
sizeof(uintX_t) *
Section.Entries->size();
1273template <
class ELFT>
1274void ELFState<ELFT>::writeSectionContent(
1287 SHeader.sh_size = Shndx.
Entries->size() * SHeader.sh_entsize;
1290template <
class ELFT>
1291void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1295 "Section type is not SHT_GROUP");
1305 unsigned int SectionIndex = 0;
1306 if (
Member.sectionNameOrType ==
"GRP_COMDAT")
1309 SectionIndex = toSectionIndex(
Member.sectionNameOrType,
Section.Name);
1312 SHeader.sh_size = SHeader.sh_entsize *
Section.Members->size();
1315template <
class ELFT>
1316void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1324 SHeader.sh_size =
Section.Entries->size() * SHeader.sh_entsize;
1327template <
class ELFT>
1328void ELFState<ELFT>::writeSectionContent(
1335 CBA.
write<uintX_t>(
E.Address, ELFT::Endianness);
1336 SHeader.sh_size +=
sizeof(uintX_t) + CBA.
writeULEB128(
E.Size);
1340template <
class ELFT>
1341void ELFState<ELFT>::writeSectionContent(
1347 <<
"PGOAnalyses should not exist in SHT_LLVM_BB_ADDR_MAP when "
1348 "Entries does not exist";
1352 const std::vector<BBAddrMapYAML::PGOAnalysisMapEntry> *PGOAnalyses =
nullptr;
1356 "in SHT_LLVM_BB_ADDR_MAP";
1358 PGOAnalyses = &
Section.PGOAnalyses.value();
1363 ELFT::Endianness,
sizeof(uintX_t));
1364 SHeader.sh_size += CBA.
getOffset() - CurrentOffset;
1367template <
class ELFT>
1368void ELFState<ELFT>::writeSectionContent(
1375 CBA.
write(
LO.Key.data(),
LO.Key.size());
1377 CBA.
write(
LO.Value.data(),
LO.Value.size());
1379 SHeader.sh_size += (
LO.Key.size() +
LO.Value.size() + 2);
1383template <
class ELFT>
1384void ELFState<ELFT>::writeSectionContent(
1393 SHeader.sh_size +=
Lib.size() + 1;
1397template <
class ELFT>
1400 std::optional<llvm::yaml::Hex64>
Offset) {
1408 return CurrentOffset;
1417 CBA.
writeZeros(AlignedOffset - CurrentOffset);
1418 return AlignedOffset;
1421template <
class ELFT>
1422void ELFState<ELFT>::writeSectionContent(
1434template <
class ELFT>
1435void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1442 Section.NBucket.value_or(llvm::yaml::Hex64(
Section.Bucket->size())),
1445 Section.NChain.value_or(llvm::yaml::Hex64(
Section.Chain->size())),
1453 SHeader.sh_size = (2 +
Section.Bucket->size() +
Section.Chain->size()) * 4;
1456template <
class ELFT>
1457void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1462 SHeader.sh_info = *
Section.Info;
1464 SHeader.sh_info =
Section.Entries->size();
1470 for (
size_t I = 0;
I <
Section.Entries->size(); ++
I) {
1474 VerDef.vd_version =
E.Version.value_or(1);
1475 VerDef.vd_flags =
E.Flags.value_or(0);
1476 VerDef.vd_ndx =
E.VersionNdx.value_or(0);
1477 VerDef.vd_hash =
E.Hash.value_or(0);
1478 VerDef.vd_aux =
E.VDAux.value_or(
sizeof(Elf_Verdef));
1479 VerDef.vd_cnt =
E.VerNames.size();
1480 if (
I ==
Section.Entries->size() - 1)
1484 sizeof(Elf_Verdef) +
E.VerNames.size() *
sizeof(Elf_Verdaux);
1485 CBA.
write((
const char *)&VerDef,
sizeof(Elf_Verdef));
1487 for (
size_t J = 0; J <
E.VerNames.size(); ++J, ++AuxCnt) {
1488 Elf_Verdaux VerdAux;
1489 VerdAux.vda_name = DotDynstr.getOffset(
E.VerNames[J]);
1490 if (J ==
E.VerNames.size() - 1)
1491 VerdAux.vda_next = 0;
1493 VerdAux.vda_next =
sizeof(Elf_Verdaux);
1494 CBA.
write((
const char *)&VerdAux,
sizeof(Elf_Verdaux));
1498 SHeader.sh_size =
Section.Entries->size() *
sizeof(Elf_Verdef) +
1499 AuxCnt *
sizeof(Elf_Verdaux);
1502template <
class ELFT>
1503void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1507 SHeader.sh_info = *
Section.Info;
1509 SHeader.sh_info =
Section.VerneedV->size();
1515 for (
size_t I = 0;
I <
Section.VerneedV->size(); ++
I) {
1518 Elf_Verneed VerNeed;
1519 VerNeed.vn_version =
VE.Version;
1520 VerNeed.vn_file = DotDynstr.getOffset(
VE.File);
1521 if (
I ==
Section.VerneedV->size() - 1)
1522 VerNeed.vn_next = 0;
1525 sizeof(Elf_Verneed) +
VE.AuxV.size() *
sizeof(Elf_Vernaux);
1526 VerNeed.vn_cnt =
VE.AuxV.size();
1527 VerNeed.vn_aux =
sizeof(Elf_Verneed);
1528 CBA.
write((
const char *)&VerNeed,
sizeof(Elf_Verneed));
1530 for (
size_t J = 0; J <
VE.AuxV.size(); ++J, ++AuxCnt) {
1533 Elf_Vernaux VernAux;
1534 VernAux.vna_hash = VAuxE.
Hash;
1535 VernAux.vna_flags = VAuxE.
Flags;
1536 VernAux.vna_other = VAuxE.
Other;
1537 VernAux.vna_name = DotDynstr.getOffset(VAuxE.
Name);
1538 if (J ==
VE.AuxV.size() - 1)
1539 VernAux.vna_next = 0;
1541 VernAux.vna_next =
sizeof(Elf_Vernaux);
1542 CBA.
write((
const char *)&VernAux,
sizeof(Elf_Vernaux));
1546 SHeader.sh_size =
Section.VerneedV->size() *
sizeof(Elf_Verneed) +
1547 AuxCnt *
sizeof(Elf_Vernaux);
1550template <
class ELFT>
1551void ELFState<ELFT>::writeSectionContent(
1561 SHeader.sh_size =
Section.Entries->size() * 8;
1564template <
class ELFT>
1565void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1569 "Section type is not SHT_MIPS_ABIFLAGS");
1573 SHeader.sh_size = SHeader.sh_entsize;
1575 Flags.version =
Section.Version;
1576 Flags.isa_level =
Section.ISALevel;
1577 Flags.isa_rev =
Section.ISARevision;
1578 Flags.gpr_size =
Section.GPRSize;
1579 Flags.cpr1_size =
Section.CPR1Size;
1580 Flags.cpr2_size =
Section.CPR2Size;
1582 Flags.isa_ext =
Section.ISAExtension;
1584 Flags.flags1 =
Section.Flags1;
1585 Flags.flags2 =
Section.Flags2;
1586 CBA.
write((
const char *)&Flags,
sizeof(Flags));
1589template <
class ELFT>
1590void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1594 "Section type is not SHT_DYNAMIC");
1600 CBA.
write<uintX_t>(DE.
Tag, ELFT::Endianness);
1601 CBA.
write<uintX_t>(DE.
Val, ELFT::Endianness);
1603 SHeader.sh_size = 2 *
sizeof(uintX_t) *
Section.Entries->size();
1606template <
class ELFT>
1607void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1618template <
class ELFT>
1619void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1626 switch (
Section.AddressAlign) {
1650 if (
NE.Name.empty())
1656 if (
NE.Desc.binary_size() == 0)
1665 if (!
NE.Name.empty()) {
1666 CBA.
write(
NE.Name.data(),
NE.Name.size());
1671 if (
NE.Desc.binary_size() != 0) {
1682template <
class ELFT>
1683void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
1707 if (
Section.Header->MaskWords)
1716 for (llvm::yaml::Hex64 Val : *
Section.BloomFilter)
1717 CBA.
write<uintX_t>(Val, ELFT::Endianness);
1720 for (llvm::yaml::Hex32 Val : *
Section.HashBuckets)
1724 for (llvm::yaml::Hex32 Val : *
Section.HashValues)
1727 SHeader.sh_size = 16 +
1728 Section.BloomFilter->size() *
sizeof(
typename ELFT::uint) +
1729 Section.HashBuckets->size() * 4 +
1730 Section.HashValues->size() * 4;
1733template <
class ELFT>
1736 size_t PatternSize = Fill.
Pattern ? Fill.
Pattern->binary_size() : 0;
1744 for (; Written + PatternSize <= Fill.
Size; Written += PatternSize)
1749template <
class ELFT>
1752 Doc.getSectionHeaderTable();
1763 reportError(
"repeated section name: '" + Hdr.Name +
1764 "' in the section header description");
1778 if (S == Doc.getSections().front())
1782 "' should be present in the 'Sections' or 'Excluded' lists");
1786 for (
const auto &It : Seen)
1787 reportError(
"section header contains undefined section '" + It.getKey() +
1792template <
class ELFT>
void ELFState<ELFT>::buildSectionIndex() {
1801 std::vector<ELFYAML::Section *> Sections = Doc.getSections();
1803 Doc.getSectionHeaderTable();
1806 if (!ExcludedSectionHeaders.insert(Hdr.
Name).second)
1809 if (SectionHeaders.
NoHeaders.value_or(
false))
1811 if (!ExcludedSectionHeaders.insert(S->
Name).second)
1818 size_t Index = ReorderMap.
empty() ? SecNdx : ReorderMap.
lookup(S->
Name);
1819 if (!SN2I.addName(S->
Name, Index))
1822 if (!ExcludedSectionHeaders.count(S->
Name))
1827template <
class ELFT>
void ELFState<ELFT>::buildSymbolIndexes() {
1829 for (
size_t I = 0, S = V.size();
I < S; ++
I) {
1837 Build(*Doc.Symbols, SymN2I);
1838 if (Doc.DynamicSymbols)
1839 Build(*Doc.DynamicSymbols, DynSymN2I);
1842template <
class ELFT>
void ELFState<ELFT>::finalizeStrings() {
1847 DotStrtab.finalize();
1850 if (Doc.DynamicSymbols)
1858 if (VerNeed->VerneedV) {
1860 DotDynstr.add(
VE.File);
1862 DotDynstr.add(Aux.
Name);
1866 if (VerDef->Entries)
1869 DotDynstr.add(Name);
1873 DotDynstr.finalize();
1877 if (ShStrtabStrings != &DotStrtab && ShStrtabStrings != &DotDynstr)
1878 ShStrtabStrings->finalize();
1881template <
class ELFT>
1884 ELFState<ELFT> State(Doc, EH);
1890 State.buildSectionIndex();
1891 State.buildSymbolIndexes();
1896 State.finalizeStrings();
1901 std::vector<Elf_Phdr> PHeaders;
1902 State.initProgramHeaders(PHeaders);
1906 const size_t SectionContentBeginOffset =
1914 std::vector<Elf_Shdr> SHeaders;
1915 State.initSectionHeaders(SHeaders, CBA);
1918 State.setProgramHeaderLayout(PHeaders, SHeaders);
1923 State.overrideSectionHeaders(SHeaders);
1925 bool ReachedLimit = CBA.
getOffset() > MaxSize;
1929 ReachedLimit =
true;
1934 "the desired output size is greater than permitted. Use the "
1935 "--max-size option to change the limit");
1940 State.writeELFHeader(OS);
1961 return ELFState<object::ELF64LE>::writeELF(Out, Doc, EH, MaxSize);
1962 return ELFState<object::ELF64BE>::writeELF(Out, Doc, EH, MaxSize);
1965 return ELFState<object::ELF32LE>::writeELF(Out, Doc, EH, MaxSize);
1966 return ELFState<object::ELF32BE>::writeELF(Out, Doc, EH, MaxSize);
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static Error reportError(StringRef Message)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines ContiguousBlobAccumulator, the size-limited output buffer shared by the yaml2obj em...
Common declarations for yaml2obj.
This file declares classes for handling the YAML representation of DWARF Debug Info.
DXIL Resource Implicit Binding
This file defines the DenseMap class.
static StringRef getDefaultLinkSec(unsigned SecType)
static void overrideFields(ELFYAML::Section *From, typename ELFT::Shdr &To)
static void writeArrayData(raw_ostream &OS, ArrayRef< T > A)
static bool isMips64EL(const ELFYAML::Object &Obj)
static size_t arrayDataSize(ArrayRef< T > A)
constexpr char SuffixStart
static bool shouldEmitDWARF(DWARFYAML::Data &DWARF, StringRef Name)
static uint64_t writeContent(ContiguousBlobAccumulator &CBA, const std::optional< yaml::BinaryRef > &Content, const std::optional< llvm::yaml::Hex64 > &Size)
Expected< uint64_t > emitDWARF(typename ELFT::Shdr &SHeader, StringRef Name, const DWARFYAML::Data &DWARF, ContiguousBlobAccumulator &CBA)
static size_t findFirstNonGlobal(ArrayRef< ELFYAML::Symbol > Symbols)
#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
This file declares classes for handling the YAML representation of ELF.
static bool lookup(const GsymReader &GR, GsymDataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
This file implements a set that has insertion order iteration characteristics.
StringSet - A set-like wrapper for the StringMap.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Base class for error info classes.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
A vector that has set insertion semantics.
size_type count(const_arg_type key) const
Count the number of elements of a given key in the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
A SetVector that performs no allocations if smaller than a certain size.
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Represent a constant reference to a string, i.e.
static constexpr size_t npos
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
char back() const
Get the last character in the string.
size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
StringRef copy(Allocator &A) const
StringSet - A wrapper for StringMap that provides set-like functionality.
std::pair< typename Base::iterator, bool > insert(StringRef key)
Utility for building string tables with deduplicated suffixes.
LLVM_ABI size_t getOffset(CachedHashStringRef S) const
Get the offest of a string in the string table.
LLVM_ABI void write(raw_ostream &OS) const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Twine utohexstr(uint64_t Val)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write(unsigned char C)
LLVM_ABI uint64_t padToAlignment(unsigned Align)
LLVM_ABI unsigned writeSLEB128(int64_t Val)
LLVM_ABI void writeAsBinary(const BinaryRef &Bin, uint64_t N=UINT64_MAX)
void writeBlobToStream(raw_ostream &Out) const
void write(const char *Ptr, size_t Size)
uint64_t getOffset() const
void writeZeros(uint64_t Num)
LLVM_ABI unsigned writeULEB128(uint64_t Val)
raw_ostream * getRawOS(uint64_t Size)
LLVM_ABI void updateDataAt(uint64_t Pos, const void *Data, size_t Size)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI void encodePayload(ArrayRef< BBAddrMapEntry > Entries, const std::vector< PGOAnalysisMapEntry > *PGOAnalyses, yaml::ContiguousBlobAccumulator &CBA, llvm::endianness Endian, unsigned AddressSize)
Encodes the BBAddrMap payload into CBA.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI std::function< Error(raw_ostream &, const Data &)> getDWARFEmitterByName(StringRef SecName)
LLVM_ABI std::string appendUniqueSuffix(StringRef Name, const Twine &Msg)
unsigned getDefaultShEntSize(unsigned EMachine, ELF_SHT SecType, StringRef SecName)
LLVM_ABI StringRef dropUniqueSuffix(StringRef S)
LLVM_ABI bool shouldAllocateFileSpace(ArrayRef< ProgramHeader > Phdrs, const NoBitsSection &S)
@ SHT_LLVM_CALL_GRAPH_PROFILE
constexpr unsigned CREL_HDR_ADDEND
LLVM_ABI bool yaml2elf(ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH, uint64_t MaxSize)
llvm::function_ref< void(const Twine &Msg)> ErrorHandler
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
auto dyn_cast_or_null(const Y &Val)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
@ Dynamic
Denotes mode unknown at compile time.
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool to_integer(StringRef S, N &Num, unsigned Base=0)
Convert the string S to an integer of the specified type using the radix Base. If Base is 0,...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
void consumeError(Error Err)
Consume a Error without doing anything.
This struct is a compact representation of a valid (non-zero power of two) alignment.
LLVM_ABI SetVector< StringRef > getNonEmptySectionNames() const
std::optional< llvm::yaml::Hex64 > Offset
std::optional< yaml::BinaryRef > Pattern
const SectionHeaderTable & getSectionHeaderTable() const
std::vector< ProgramHeader > ProgramHeaders
std::optional< llvm::yaml::Hex64 > Info
std::optional< StringRef > Symbol
std::optional< llvm::yaml::Hex64 > Address
std::optional< StringRef > Link
std::optional< llvm::yaml::Hex64 > Size
std::optional< llvm::yaml::Hex64 > ShAddrAlign
llvm::yaml::Hex64 AddressAlign
std::optional< ELF_SHF > Flags
std::optional< ELF_SHT > ShType
std::optional< llvm::yaml::Hex64 > ShOffset
std::optional< llvm::yaml::Hex64 > ShFlags
std::optional< llvm::yaml::Hex64 > ShName
std::optional< yaml::BinaryRef > Content
std::optional< llvm::yaml::Hex64 > EntSize
std::optional< llvm::yaml::Hex64 > ShSize
std::optional< std::vector< uint32_t > > Entries
Common declarations for yaml2obj.