66#define DEBUG_TYPE "reloc-info"
77class SymbolTableWriter {
82 std::vector<uint32_t> ShndxIndexes;
87 void createSymtabShndx();
92 SymbolTableWriter(ELFWriter &EWriter,
bool Is64Bit);
101 ELFObjectWriter &OWriter;
112 bool Used,
bool Renamed);
115 struct ELFSymbolData {
131 unsigned LastLocalSymbolIndex = ~0u;
133 unsigned StringTableIndex = ~0u;
135 unsigned SymbolTableIndex = ~0u;
138 std::vector<MCSectionELF *> SectionTable;
152 bool IsLittleEndian, DwoMode Mode)
164 template <
typename T>
void write(
T Val) {
170 void writeSymbol(
const MCAssembler &Asm, SymbolTableWriter &Writer,
171 uint32_t StringIndex, ELFSymbolData &MSD);
180 void computeSymbolTable(
MCAssembler &Asm,
const RevGroupMapTy &RevGroupMap);
182 void writeAddrsigSection();
205 std::unique_ptr<MCELFObjectTargetWriter> TargetObjectWriter;
211 bool SeenGnuAbi =
false;
213 std::optional<uint8_t> OverrideABIVersion;
215 bool hasRelocationAddend()
const;
219 unsigned Type)
const;
222 ELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW)
223 : TargetObjectWriter(std::move(MOTW)) {}
225 void reset()
override {
227 OverrideABIVersion.reset();
236 bool IsPCRel)
const override;
251 void markGnuAbi()
override { SeenGnuAbi =
true; }
252 bool seenGnuAbi()
const {
return SeenGnuAbi; }
254 bool seenOverrideABIVersion()
const {
return OverrideABIVersion.has_value(); }
255 uint8_t getOverrideABIVersion()
const {
return OverrideABIVersion.value(); }
258 friend struct ELFWriter;
261class ELFSingleObjectWriter :
public ELFObjectWriter {
266 ELFSingleObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW,
268 : ELFObjectWriter(std::move(MOTW)),
OS(
OS),
269 IsLittleEndian(IsLittleEndian) {}
272 return ELFWriter(*
this,
OS, IsLittleEndian, ELFWriter::AllSections)
276 friend struct ELFWriter;
279class ELFDwoObjectWriter :
public ELFObjectWriter {
284 ELFDwoObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW,
287 : ELFObjectWriter(std::move(MOTW)),
OS(
OS), DwoOS(DwoOS),
288 IsLittleEndian(IsLittleEndian) {}
293 Ctx.
reportError(Loc,
"A dwo section may not contain relocations");
297 Ctx.
reportError(Loc,
"A relocation may not refer to a dwo section");
304 uint64_t Size = ELFWriter(*
this,
OS, IsLittleEndian, ELFWriter::NonDwoOnly)
306 Size += ELFWriter(*
this, DwoOS, IsLittleEndian, ELFWriter::DwoOnly)
317 W.OS.write_zeros(NewOffset -
Offset);
321unsigned ELFWriter::addToSectionTable(
MCSectionELF *Sec) {
322 SectionTable.push_back(Sec);
323 StrTabBuilder.add(Sec->
getName());
324 return SectionTable.size();
327void SymbolTableWriter::createSymtabShndx() {
328 if (!ShndxIndexes.empty())
331 ShndxIndexes.resize(NumWritten);
334template <
typename T>
void SymbolTableWriter::write(
T Value) {
335 EWriter.write(
Value);
338SymbolTableWriter::SymbolTableWriter(ELFWriter &EWriter,
bool Is64Bit)
339 : EWriter(EWriter), Is64Bit(Is64Bit), NumWritten(0) {}
349 if (!ShndxIndexes.empty()) {
351 ShndxIndexes.push_back(shndx);
353 ShndxIndexes.push_back(0);
377bool ELFWriter::is64Bit()
const {
378 return OWriter.TargetObjectWriter->is64Bit();
382void ELFWriter::writeHeader(
const MCAssembler &Asm) {
401 uint8_t OSABI = OWriter.TargetObjectWriter->getOSABI();
406 W.OS <<
char(OWriter.seenOverrideABIVersion()
407 ? OWriter.getOverrideABIVersion()
408 : OWriter.TargetObjectWriter->getABIVersion());
414 W.write<
uint16_t>(OWriter.TargetObjectWriter->getEMachine());
445 return Sym.getCommonAlignment()->value();
448 if (!
Asm.getSymbolOffset(
Sym, Res))
451 if (
Asm.isThumbFunc(&
Sym))
458 uint8_t
Type = newType;
495 if (!Symbol->isVariable() ||
496 !(
Value = dyn_cast<MCSymbolRefExpr>(Symbol->getVariableValue())) ||
500 Symbol = &cast<MCSymbolELF>(
Value->getSymbol());
505void ELFWriter::writeSymbol(
const MCAssembler &Asm, SymbolTableWriter &Writer,
506 uint32_t StringIndex, ELFSymbolData &MSD) {
507 const auto &
Symbol = cast<MCSymbolELF>(*MSD.Symbol);
509 cast_or_null<MCSymbolELF>(
Asm.getBaseSymbol(Symbol));
516 uint8_t Binding =
Symbol.getBinding();
523 uint8_t
Info = (Binding << 4) |
Type;
527 uint8_t Visibility =
Symbol.getVisibility();
533 const MCExpr *ESize = MSD.Symbol->getSize();
534 if (!ESize &&
Base) {
536 ESize =
Base->getSize();
543 while (
Sym->isVariable()) {
545 dyn_cast<MCSymbolRefExpr>(
Sym->getVariableValue(
false))) {
546 Sym = cast<MCSymbolELF>(&Expr->getSymbol());
549 ESize =
Sym->getSize();
563 Writer.writeSymbol(StringIndex, Info,
Value,
Size,
Other, MSD.SectionIndex,
568 bool Used,
bool Renamed) {
569 if (
Symbol.isVariable()) {
572 if (
const auto *
T = dyn_cast<MCTargetExpr>(Expr))
573 if (
T->inlineAssignedExpr())
589 Asm.getBaseSymbol(Symbol);
602void ELFWriter::computeSymbolTable(
MCAssembler &Asm,
603 const RevGroupMapTy &RevGroupMap) {
605 SymbolTableWriter Writer(*
this,
is64Bit());
612 SymbolTableIndex = addToSectionTable(SymtabSection);
617 Writer.writeSymbol(0, 0, 0, 0, 0, 0,
false);
619 std::vector<ELFSymbolData> LocalSymbolData;
620 std::vector<ELFSymbolData> ExternalSymbolData;
623 for (
const std::pair<std::string, size_t> &
F : FileNames)
624 StrTabBuilder.add(
F.first);
627 bool HasLargeSectionIndex =
false;
629 const auto &
Symbol = cast<MCSymbolELF>(It.value());
631 bool WeakrefUsed =
Symbol.isWeakrefUsedInReloc();
632 bool isSignature =
Symbol.isSignature();
634 if (!
isInSymtab(Asm, Symbol, Used || WeakrefUsed || isSignature,
635 OWriter.Renames.count(&Symbol)))
644 MSD.Symbol = cast<MCSymbolELF>(&Symbol);
645 MSD.Order = It.index();
650 if (
Symbol.isAbsolute()) {
652 }
else if (
Symbol.isCommon()) {
653 if (
Symbol.isTargetCommon()) {
654 MSD.SectionIndex =
Symbol.getIndex();
659 }
else if (
Symbol.isUndefined()) {
660 if (isSignature && !Used) {
661 MSD.SectionIndex = RevGroupMap.lookup(&Symbol);
663 HasLargeSectionIndex =
true;
680 "Undefined section reference: " +
Symbol.getName());
686 MSD.SectionIndex =
Section.getOrdinal();
687 assert(MSD.SectionIndex &&
"Invalid section index!");
689 HasLargeSectionIndex =
true;
703 StrTabBuilder.add(
Name);
707 LocalSymbolData.push_back(MSD);
709 ExternalSymbolData.push_back(MSD);
713 unsigned SymtabShndxSectionIndex = 0;
715 if (HasLargeSectionIndex) {
718 SymtabShndxSectionIndex = addToSectionTable(SymtabShndxSection);
722 StrTabBuilder.finalize();
726 auto FileNameIt = FileNames.begin();
727 if (!FileNames.empty())
728 FileNames[0].second = 0;
730 for (ELFSymbolData &MSD : LocalSymbolData) {
732 for (; FileNameIt != FileNames.end() && FileNameIt->second <= MSD.Order;
734 Writer.writeSymbol(StrTabBuilder.getOffset(FileNameIt->first),
742 : StrTabBuilder.getOffset(MSD.Name);
743 MSD.Symbol->setIndex(
Index++);
744 writeSymbol(Asm, Writer, StringIndex, MSD);
746 for (; FileNameIt != FileNames.end(); ++FileNameIt) {
747 Writer.writeSymbol(StrTabBuilder.getOffset(FileNameIt->first),
754 LastLocalSymbolIndex =
Index;
756 for (ELFSymbolData &MSD : ExternalSymbolData) {
757 unsigned StringIndex = StrTabBuilder.getOffset(MSD.Name);
758 MSD.Symbol->setIndex(
Index++);
759 writeSymbol(Asm, Writer, StringIndex, MSD);
767 if (ShndxIndexes.
empty()) {
768 assert(SymtabShndxSectionIndex == 0);
771 assert(SymtabShndxSectionIndex != 0);
773 SecStart =
W.OS.tell();
774 MCSectionELF *SymtabShndxSection = SectionTable[SymtabShndxSectionIndex - 1];
777 SecEnd =
W.OS.tell();
778 SymtabShndxSection->
setOffsets(SecStart, SecEnd);
781void ELFWriter::writeAddrsigSection() {
783 if (
Sym->getIndex() != 0)
789 if (OWriter.Relocations[&Sec].empty())
798 if (TO && TO->
Crel) {
805 const bool Rela = OWriter.usesRela(TO, Sec);
821bool ELFWriter::maybeWriteCompression(
826 if (
Size <= HdrSize + CompressedContents.
size())
847 auto &Ctx =
Asm.getContext();
850 : DebugCompressionType::None;
851 if (CompressionType == DebugCompressionType::None ||
853 Asm.writeSectionData(
W.OS, &Section);
859 Asm.writeSectionData(VecOS, &Section);
861 ArrayRef(
reinterpret_cast<uint8_t *
>(UncompressedData.
data()),
862 UncompressedData.
size());
866 switch (CompressionType) {
867 case DebugCompressionType::None:
869 case DebugCompressionType::Zlib:
872 case DebugCompressionType::Zstd:
878 if (!maybeWriteCompression(ChType, UncompressedData.
size(), Compressed,
880 W.OS << UncompressedData;
903 WriteWord(Alignment ? Alignment->value() : 0);
904 WriteWord(EntrySize);
909 using uint = std::conditional_t<Is64, uint64_t, uint32_t>;
911 uint32_t SymIdx = R.Symbol ? R.Symbol->getIndex() : 0;
913 std::make_signed_t<uint>(R.Addend)};
917void ELFWriter::writeRelocations(
const MCAssembler &Asm,
919 std::vector<ELFRelocationEntry> &Relocs = OWriter.Relocations[&Sec];
921 const bool Rela = OWriter.usesRela(TO, Sec);
924 OWriter.TargetObjectWriter->sortRelocs(Asm, Relocs);
926 if (OWriter.TargetObjectWriter->getEMachine() ==
ELF::EM_MIPS) {
932 write(OWriter.TargetObjectWriter->getRSsym(
Entry.Type));
933 write(OWriter.TargetObjectWriter->getRType3(
Entry.Type));
934 write(OWriter.TargetObjectWriter->getRType2(
Entry.Type));
935 write(OWriter.TargetObjectWriter->getRType(
Entry.Type));
946 OWriter.TargetObjectWriter->getRType2(
Entry.Type)) {
953 OWriter.TargetObjectWriter->getRType3(
Entry.Type)) {
961 }
else if (TO && TO->
Crel) {
963 encodeCrel<true>(Relocs,
W.OS);
965 encodeCrel<false>(Relocs,
W.OS);
1004 sh_link = SymbolTableIndex;
1005 assert(sh_link &&
".symtab not found");
1012 sh_link = StringTableIndex;
1013 sh_info = LastLocalSymbolIndex;
1019 sh_link = SymbolTableIndex;
1023 sh_link = SymbolTableIndex;
1024 sh_info = GroupSymbolIndex;
1032 if (
Sym &&
Sym->isInSection())
1033 sh_link =
Sym->getSection().getOrdinal();
1036 WriteSecHdrEntry(StrTabBuilder.getOffset(
Section.getName()),
1038 sh_link, sh_info,
Section.getAlign(),
1042void ELFWriter::writeSectionHeader(
const MCAssembler &Asm) {
1043 const unsigned NumSections = SectionTable.size();
1048 WriteSecHdrEntry(0, 0, 0, 0, 0, FirstSectionSize, 0, 0, std::nullopt, 0);
1054 GroupSymbolIndex = 0;
1056 GroupSymbolIndex =
Section->getGroup()->getIndex();
1061 Size =
Asm.getSectionAddressSize(*Section);
1065 writeSection(GroupSymbolIndex,
Offsets.first,
Size, *Section);
1075 StringTableIndex = addToSectionTable(StrtabSection);
1077 RevGroupMapTy RevGroupMap;
1098 writeSectionData(Asm, Section);
1101 Section.setOffsets(SecStart, SecEnd);
1103 MCSectionELF *RelSection = createRelocationSection(Ctx, Section);
1105 unsigned *GroupIdxEntry =
nullptr;
1106 if (SignatureSymbol) {
1107 GroupIdxEntry = &RevGroupMap[SignatureSymbol];
1108 if (!*GroupIdxEntry) {
1111 *GroupIdxEntry = addToSectionTable(Group);
1114 GroupMap.
resize(*GroupIdxEntry + 1);
1115 GroupMap[*GroupIdxEntry] =
Groups.size();
1120 Section.setOrdinal(addToSectionTable(&Section));
1122 RelSection->
setOrdinal(addToSectionTable(RelSection));
1126 if (GroupIdxEntry) {
1127 auto &Members =
Groups[GroupMap[*GroupIdxEntry]];
1128 Members.second.push_back(
Section.getOrdinal());
1130 Members.second.push_back(RelSection->
getOrdinal());
1133 OWriter.TargetObjectWriter->addTargetSectionFlags(Ctx, Section);
1136 for (
auto &[Group, Members] :
Groups) {
1141 W.write<
unsigned>(Members);
1147 if (Mode == DwoOnly) {
1150 StrTabBuilder.finalize();
1153 if (OWriter.EmitAddrsigSection) {
1156 addToSectionTable(AddrsigSection);
1160 computeSymbolTable(Asm, RevGroupMap);
1166 writeRelocations(Asm,
1173 if (OWriter.EmitAddrsigSection) {
1175 writeAddrsigSection();
1177 AddrsigSection->
setOffsets(SecStart, SecEnd);
1183 StrTabBuilder.write(
W.OS);
1190 writeSectionHeader(Asm);
1192 uint16_t NumSections = support::endian::byte_swap<uint16_t>(
1194 : SectionTable.size() + 1,
1196 unsigned NumSectionsOffset;
1201 support::endian::byte_swap<uint64_t>(SectionHeaderOffset,
W.Endian);
1202 Stream.pwrite(
reinterpret_cast<char *
>(&Val),
sizeof(Val),
1207 support::endian::byte_swap<uint32_t>(SectionHeaderOffset,
W.Endian);
1208 Stream.pwrite(
reinterpret_cast<char *
>(&Val),
sizeof(Val),
1212 Stream.pwrite(
reinterpret_cast<char *
>(&NumSections),
sizeof(NumSections),
1215 return W.OS.tell() - StartOffset;
1218bool ELFObjectWriter::hasRelocationAddend()
const {
1219 return TargetObjectWriter->hasRelocationAddend();
1222void ELFObjectWriter::executePostLayoutBinding(
MCAssembler &Asm) {
1227 const auto &
Symbol = cast<MCSymbolELF>(*S.
Sym);
1228 size_t Pos = AliasName.
find(
'@');
1238 cast<MCSymbolELF>(
Asm.getContext().getOrCreateSymbol(Prefix +
Tail));
1239 Asm.registerSymbol(*Alias);
1241 Alias->setVariableValue(
Value);
1245 Alias->setBinding(
Symbol.getBinding());
1246 Alias->setVisibility(
Symbol.getVisibility());
1247 Alias->setOther(
Symbol.getOther());
1254 Asm.getContext().reportError(S.
Loc,
"default version symbol " +
1255 AliasName +
" must be defined");
1259 if (Renames.count(&Symbol) && Renames[&Symbol] != Alias) {
1260 Asm.getContext().reportError(S.
Loc,
Twine(
"multiple versions for ") +
1265 Renames.insert(std::make_pair(&Symbol, Alias));
1269 if (
const MCSymbol *R = Renames.lookup(cast<MCSymbolELF>(
Sym)))
1271 if (
Sym->isInSection() &&
Sym->getName().starts_with(
".L"))
1272 Sym =
Sym->getSection().getBeginSymbol();
1273 Sym->setUsedInReloc();
1280bool ELFObjectWriter::shouldRelocateWithSymbol(
const MCAssembler &Asm,
1284 unsigned Type)
const {
1321 if (
Sym->isUndefined())
1330 if (
Sym->isMemtag())
1333 unsigned Binding =
Sym->getBinding();
1364 if (
Sym->isInSection()) {
1365 auto &Sec = cast<MCSectionELF>(
Sym->getSection());
1373 if (TargetObjectWriter->getEMachine() ==
ELF::EM_386 &&
1374 Type == ELF::R_386_GOTOFF)
1384 if (TargetObjectWriter->getEMachine() ==
ELF::EM_MIPS &&
1385 !hasRelocationAddend())
1401 if (
Asm.isThumbFunc(
Sym))
1404 if (TargetObjectWriter->needsRelocateWithSymbol(Val, *
Sym,
Type))
1409void ELFObjectWriter::recordRelocation(
MCAssembler &Asm,
1418 uint64_t FixupOffset =
Asm.getFragmentOffset(*Fragment) +
Fixup.getOffset();
1423 const auto &SymB = cast<MCSymbolELF>(RefB->getSymbol());
1424 if (SymB.isUndefined()) {
1426 Twine(
"symbol '") + SymB.getName() +
1427 "' can not be undefined in a subtraction expression");
1431 assert(!SymB.isAbsolute() &&
"Should have been folded");
1432 const MCSection &SecB = SymB.getSection();
1433 if (&SecB != &FixupSection) {
1435 "Cannot represent a difference across sections");
1439 assert(!IsPCRel &&
"should have been folded");
1441 C += FixupOffset -
Asm.getSymbolOffset(SymB);
1446 const auto *SymA = RefA ? cast<MCSymbolELF>(&RefA->
getSymbol()) : nullptr;
1448 bool ViaWeakRef =
false;
1449 if (SymA && SymA->isVariable()) {
1450 const MCExpr *Expr = SymA->getVariableValue();
1451 if (
const auto *Inner = dyn_cast<MCSymbolRefExpr>(Expr)) {
1453 SymA = cast<MCSymbolELF>(&Inner->getSymbol());
1459 const MCSectionELF *SecA = (SymA && SymA->isInSection())
1460 ? cast<MCSectionELF>(&SymA->getSection())
1462 if (!checkRelocation(Ctx,
Fixup.getLoc(), &FixupSection, SecA))
1465 unsigned Type = TargetObjectWriter->getRelocType(Ctx,
Target,
Fixup, IsPCRel);
1466 const auto *Parent = cast<MCSectionELF>(Fragment->
getParent());
1468 bool RelocateWithSymbol =
1469 shouldRelocateWithSymbol(Asm,
Target, SymA,
C,
Type) ||
1473 FixedValue = !RelocateWithSymbol && SymA && !SymA->isUndefined()
1474 ?
C +
Asm.getSymbolOffset(*SymA)
1476 if (usesRela(TO, FixupSection)) {
1477 Addend = FixedValue;
1481 if (!RelocateWithSymbol) {
1482 const auto *SectionSymbol =
1485 SectionSymbol->setUsedInReloc();
1487 Relocations[&FixupSection].push_back(Rec);
1502 Relocations[&FixupSection].push_back(Rec);
1507 return (hasRelocationAddend() &&
1512bool ELFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
1514 bool InSet,
bool IsPCRel)
const {
1515 const auto &SymA = cast<MCSymbolELF>(SA);
1522 return &SymA.getSection() == FB.
getParent();
1525std::unique_ptr<MCObjectWriter>
1528 return std::make_unique<ELFSingleObjectWriter>(std::move(MOTW),
OS,
1532std::unique_ptr<MCObjectWriter>
1535 bool IsLittleEndian) {
1536 return std::make_unique<ELFDwoObjectWriter>(std::move(MOTW),
OS, DwoOS,
#define offsetof(TYPE, MEMBER)
BlockVerifier::State From
Analysis containing CSE Info
Given that RA is a live value
This file defines the DenseMap class.
static uint8_t mergeTypeForSet(uint8_t origType, uint8_t newType)
static void encodeCrel(ArrayRef< ELFRelocationEntry > Relocs, raw_ostream &OS)
static bool isIFunc(const MCSymbolELF *Symbol)
std::optional< std::vector< StOtherPiece > > Other
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
static bool isInSymtab(const MCSymbolWasm &Sym)
static bool isDwoSection(const MCSection &Sec)
static bool is64Bit(const char *name)
static const X86InstrFMA3Group Groups[]
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - Check if the array is empty.
Generic interface to target specific assembler backends.
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
Context object for machine code objects.
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
void reportError(SMLoc L, const Twine &Msg)
const MCTargetOptions * getTargetOptions() const
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group, bool IsComdat)
Base class for the full range of assembler expressions which are needed for parsing.
bool evaluateKnownAbsolute(int64_t &Res, const MCAssembler &Asm) const
Aggressive variant of evaluateAsRelocatable when relocations are unavailable (e.g.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
MCSection * getParent() const
Defines the object file and target independent interfaces used by the assembler backend to write nati...
virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const
virtual void executePostLayoutBinding(MCAssembler &Asm)
Perform any late binding of symbols (for example, to assign symbol indices for use when generating re...
virtual void reset()
lifetime management
virtual void markGnuAbi()
ELF only. Mark that we have seen GNU ABI usage (e.g. SHF_GNU_RETAIN).
virtual void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)=0
Record a relocation entry.
virtual void setOverrideABIVersion(uint8_t ABIVersion)
ELF only, override the default ABIVersion in the ELF header.
This represents a section on linux, lots of unix variants and some bare metal systems.
const MCSection * getLinkedToSection() const
unsigned getFlags() const
void setOffsets(uint64_t Start, uint64_t End)
const MCSymbolELF * getGroup() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
void setAlignment(Align Value)
unsigned getOrdinal() const
void setOrdinal(unsigned Value)
StringRef getName() const
MCSymbol * getBeginSymbol()
void setIsWeakrefUsedInReloc() const
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
VariantKind getKind() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void setUsedInReloc() const
DebugCompressionType CompressDebugSections
This represents an "assembler immediate".
const MCSymbolRefExpr * getSymA() const
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Represents a location in source code.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
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.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
static constexpr size_t npos
Utility for building string tables with deduplicated suffixes.
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
An abstract base class for streams implementations that also support a pwrite operation.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ C
The default llvm calling convention, compatible with C.
static const char ElfMagic[]
@ SHT_LLVM_CALL_GRAPH_PROFILE
void compress(Params P, ArrayRef< uint8_t > Input, SmallVectorImpl< uint8_t > &Output)
StringRef toStringRef(const std::optional< DWARFFormValue > &V, StringRef Default={})
Take an optional DWARFFormValue and try to extract a string value from it.
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.
std::unique_ptr< MCObjectWriter > createELFObjectWriter(std::unique_ptr< MCELFObjectTargetWriter > MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
Construct a new ELF writer instance.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are are tuples (A,...
std::unique_ptr< MCObjectWriter > createELFDwoObjectWriter(std::unique_ptr< MCELFObjectTargetWriter > MOTW, raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS, bool IsLittleEndian)
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
@ Ref
The access may reference the value stored in memory.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.
void setSymbolAndType(Elf32_Word s, unsigned char t)
void setSymbolAndType(Elf64_Word s, Elf64_Word t)
@ FKF_IsPCRel
Is this fixup kind PCrelative? This is used by the assembler backend to evaluate fixup values in a ta...
unsigned Flags
Flags describing additional information on this fixup kind.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Adapter to write values to a stream in a particular byte order.