64 #define DEBUG_TYPE "reloc-info"
70 class ELFObjectWriter;
72 class SymbolTableWriter {
73 ELFObjectWriter &EWriter;
77 std::vector<uint32_t> ShndxIndexes;
82 void createSymtabShndx();
87 SymbolTableWriter(ELFObjectWriter &EWriter,
bool Is64Bit);
90 uint8_t other,
uint32_t shndx,
bool Reserved);
98 bool Used,
bool Renamed);
101 struct ELFSymbolData {
107 bool operator<(
const ELFSymbolData &RHS)
const {
108 unsigned LHSType = Symbol->
getType();
109 unsigned RHSType = RHS.Symbol->getType();
115 return SectionIndex < RHS.SectionIndex;
116 return Name < RHS.Name;
121 std::unique_ptr<MCELFObjectTargetWriter> TargetObjectWriter;
138 unsigned LastLocalSymbolIndex;
140 unsigned StringTableIndex;
142 unsigned SymbolTableIndex;
145 std::vector<const MCSectionELF *> SectionTable;
149 bool is64Bit()
const {
return TargetObjectWriter->is64Bit(); }
150 bool hasRelocationAddend()
const {
151 return TargetObjectWriter->hasRelocationAddend();
155 return TargetObjectWriter->getRelocType(Ctx, Target, Fixup, IsPCRel);
158 void align(
unsigned Alignment);
160 bool maybeWriteCompression(uint64_t
Size,
162 bool ZLibStyle,
unsigned Alignment);
169 ~ELFObjectWriter()
override =
default;
171 void reset()
override {
174 StrTabBuilder.clear();
175 SectionTable.clear();
179 void WriteWord(uint64_t W) {
186 template <
typename T>
void write(
T Val) {
195 void writeSymbol(SymbolTableWriter &Writer,
uint32_t StringIndex,
199 using SectionOffsetsTy =
200 std::map<const MCSectionELF *, std::pair<uint64_t, uint64_t>>;
202 bool shouldRelocateWithSymbol(
const MCAssembler &Asm,
205 unsigned Type)
const;
209 MCValue Target, uint64_t &FixedValue)
override;
220 const SectionIndexMapTy &SectionIndexMap,
221 const RevGroupMapTy &RevGroupMap,
222 SectionOffsetsTy &SectionOffsets);
233 const SectionIndexMapTy &SectionIndexMap,
234 const SectionOffsetsTy &SectionOffsets);
247 bool isSymbolRefDifferenceFullyResolvedImpl(
const MCAssembler &Asm,
250 bool IsPCRel)
const override;
253 void writeSection(
const SectionIndexMapTy &SectionIndexMap,
254 uint32_t GroupSymbolIndex, uint64_t Offset, uint64_t Size,
260 void ELFObjectWriter::align(
unsigned Alignment) {
265 unsigned ELFObjectWriter::addToSectionTable(
const MCSectionELF *Sec) {
266 SectionTable.push_back(Sec);
268 return SectionTable.size();
271 void SymbolTableWriter::createSymtabShndx() {
272 if (!ShndxIndexes.empty())
275 ShndxIndexes.resize(NumWritten);
279 EWriter.write(Value);
282 SymbolTableWriter::SymbolTableWriter(ELFObjectWriter &EWriter,
bool Is64Bit)
283 : EWriter(EWriter), Is64Bit(Is64Bit), NumWritten(0) {}
285 void SymbolTableWriter::writeSymbol(
uint32_t name, uint8_t
info, uint64_t value,
286 uint64_t size, uint8_t other,
293 if (!ShndxIndexes.empty()) {
295 ShndxIndexes.push_back(shndx);
297 ShndxIndexes.push_back(0);
340 write8(TargetObjectWriter->getOSABI());
347 write16(TargetObjectWriter->getEMachine());
374 uint64_t ELFObjectWriter::SymbolValue(
const MCSymbol &Sym,
389 void ELFObjectWriter::executePostLayoutBinding(
MCAssembler &Asm,
394 const auto &Alias = cast<MCSymbolELF>(
A);
396 if (!Alias.isVariable())
401 const auto &
Symbol = cast<MCSymbolELF>(Ref->getSymbol());
404 size_t Pos = AliasName.
find(
'@');
405 if (Pos == StringRef::npos)
410 Alias.setExternal(
Symbol.isExternal());
411 Alias.setBinding(
Symbol.getBinding());
422 Renames.insert(std::make_pair(&
Symbol, &Alias));
427 uint8_t
Type = newType;
461 void ELFObjectWriter::writeSymbol(SymbolTableWriter &Writer,
462 uint32_t StringIndex, ELFSymbolData &MSD,
464 const auto &
Symbol = cast<MCSymbolELF>(*MSD.Symbol);
470 bool IsReserved = !Base ||
Symbol.isCommon();
473 uint8_t Binding =
Symbol.getBinding();
478 uint8_t Info = (Binding << 4) | Type;
485 uint64_t Value = SymbolValue(*MSD.Symbol, Layout);
488 const MCExpr *ESize = MSD.Symbol->getSize();
490 ESize = Base->getSize();
500 Writer.writeSymbol(StringIndex, Info, Value, Size, Other, MSD.SectionIndex,
507 bool ELFObjectWriter::shouldRelocateWithSymbol(
const MCAssembler &Asm,
510 unsigned Type)
const {
511 const auto *Sym = cast_or_null<MCSymbolELF>(S);
527 case MCSymbolRefExpr::VK_PPC_TOCBASE:
534 case MCSymbolRefExpr::VK_GOT:
535 case MCSymbolRefExpr::VK_PLT:
536 case MCSymbolRefExpr::VK_GOTPCREL:
537 case MCSymbolRefExpr::VK_PPC_GOT_LO:
538 case MCSymbolRefExpr::VK_PPC_GOT_HI:
539 case MCSymbolRefExpr::VK_PPC_GOT_HA:
545 assert(Sym &&
"Expected a symbol");
549 unsigned Binding = Sym->getBinding();
574 auto &Sec = cast<MCSectionELF>(Sym->
getSection());
582 if (!hasRelocationAddend())
601 if (TargetObjectWriter->needsRelocateWithSymbol(*Sym, Type))
626 void ELFObjectWriter::recordRelocation(
MCAssembler &Asm,
630 uint64_t &FixedValue) {
633 MCFixupKindInfo::FKF_IsPCRel;
650 "No relocation available to represent this relative expression");
654 const auto &SymB = cast<MCSymbolELF>(RefB->getSymbol());
656 if (SymB.isUndefined()) {
658 Twine(
"symbol '") + SymB.getName() +
659 "' can not be undefined in a subtraction expression");
663 assert(!SymB.isAbsolute() &&
"Should have been folded");
664 const MCSection &SecB = SymB.getSection();
665 if (&SecB != &FixupSection) {
667 "Cannot represent a difference across sections");
672 uint64_t K = SymBOffset - FixupOffset;
679 const auto *SymA = RefA ? cast<MCSymbolELF>(&RefA->
getSymbol()) :
nullptr;
681 bool ViaWeakRef =
false;
682 if (SymA && SymA->isVariable()) {
683 const MCExpr *Expr = SymA->getVariableValue();
684 if (
const auto *Inner = dyn_cast<MCSymbolRefExpr>(Expr)) {
685 if (Inner->getKind() == MCSymbolRefExpr::VK_WEAKREF) {
686 SymA = cast<MCSymbolELF>(&Inner->getSymbol());
692 unsigned Type =
getRelocType(Ctx, Target, Fixup, IsPCRel);
693 uint64_t OriginalC =
C;
694 bool RelocateWithSymbol = shouldRelocateWithSymbol(Asm, RefA, SymA, C, Type);
695 if (!RelocateWithSymbol && SymA && !SymA->isUndefined())
699 if (hasRelocationAddend()) {
706 if (!RelocateWithSymbol) {
708 (SymA && !SymA->isUndefined()) ? &SymA->getSection() :
nullptr;
709 auto *ELFSec = cast_or_null<MCSectionELF>(SecA);
710 const auto *SectionSymbol =
711 ELFSec ? cast<MCSymbolELF>(ELFSec->getBeginSymbol()) :
nullptr;
713 SectionSymbol->setUsedInReloc();
716 Relocations[&FixupSection].push_back(Rec);
720 const auto *RenamedSymA = SymA;
726 RenamedSymA->setIsWeakrefUsedInReloc();
728 RenamedSymA->setUsedInReloc();
732 Relocations[&FixupSection].push_back(Rec);
735 bool ELFObjectWriter::isInSymtab(
const MCAsmLayout &Layout,
741 if (Ref->getKind() == MCSymbolRefExpr::VK_WEAKREF)
770 void ELFObjectWriter::computeSymbolTable(
772 const SectionIndexMapTy &SectionIndexMap,
const RevGroupMapTy &RevGroupMap,
773 SectionOffsetsTy &SectionOffsets) {
775 SymbolTableWriter Writer(*
this,
is64Bit());
782 SymbolTableIndex = addToSectionTable(SymtabSection);
785 uint64_t SecStart = getStream().tell();
788 Writer.writeSymbol(0, 0, 0, 0, 0, 0,
false);
790 std::vector<ELFSymbolData> LocalSymbolData;
791 std::vector<ELFSymbolData> ExternalSymbolData;
794 bool HasLargeSectionIndex =
false;
796 const auto &Symbol = cast<MCSymbolELF>(S);
801 if (!isInSymtab(Layout, Symbol, Used || WeakrefUsed || isSignature,
802 Renames.count(&Symbol)))
811 MSD.Symbol = cast<MCSymbolELF>(&
Symbol);
822 if (isSignature && !Used) {
823 MSD.SectionIndex = RevGroupMap.lookup(&Symbol);
825 HasLargeSectionIndex =
true;
832 MSD.SectionIndex = SectionIndexMap.lookup(&Section);
833 assert(MSD.SectionIndex &&
"Invalid section index!");
835 HasLargeSectionIndex =
true;
868 size_t Pos = Name.
find(
"@@@");
869 if (Pos != StringRef::npos) {
870 Buf += Name.
substr(0, Pos);
872 Buf += Name.
substr(Pos + Skip);
873 Name = VersionSymSaver.save(Buf.
c_str());
880 StrTabBuilder.add(Name);
884 LocalSymbolData.push_back(MSD);
886 ExternalSymbolData.push_back(MSD);
890 unsigned SymtabShndxSectionIndex = 0;
892 if (HasLargeSectionIndex) {
895 SymtabShndxSectionIndex = addToSectionTable(SymtabShndxSection);
900 for (
const std::string &Name : FileNames)
901 StrTabBuilder.add(Name);
903 StrTabBuilder.finalize();
907 for (
const std::string &Name : FileNames)
908 Writer.writeSymbol(StrTabBuilder.getOffset(Name),
914 array_pod_sort(ExternalSymbolData.begin(), ExternalSymbolData.end());
918 unsigned Index = FileNames.size() + 1;
920 for (ELFSymbolData &MSD : LocalSymbolData) {
923 : StrTabBuilder.getOffset(MSD.Name);
924 MSD.Symbol->setIndex(Index++);
925 writeSymbol(Writer, StringIndex, MSD, Layout);
929 LastLocalSymbolIndex = Index;
931 for (ELFSymbolData &MSD : ExternalSymbolData) {
932 unsigned StringIndex = StrTabBuilder.getOffset(MSD.Name);
933 MSD.Symbol->setIndex(Index++);
934 writeSymbol(Writer, StringIndex, MSD, Layout);
938 uint64_t SecEnd = getStream().tell();
939 SectionOffsets[SymtabSection] = std::make_pair(SecStart, SecEnd);
942 if (ShndxIndexes.
empty()) {
943 assert(SymtabShndxSectionIndex == 0);
946 assert(SymtabShndxSectionIndex != 0);
948 SecStart = getStream().tell();
950 SectionTable[SymtabShndxSectionIndex - 1];
953 SecEnd = getStream().tell();
954 SectionOffsets[SymtabShndxSection] = std::make_pair(SecStart, SecEnd);
958 ELFObjectWriter::createRelocationSection(
MCContext &Ctx,
960 if (Relocations[&Sec].empty())
964 std::string RelaSectionName = hasRelocationAddend() ?
".rela" :
".rel";
968 if (hasRelocationAddend())
979 Flags, EntrySize, Sec.
getGroup(), &Sec);
985 bool ELFObjectWriter::maybeWriteCompression(
987 unsigned Alignment) {
991 if (Size <= HdrSize + CompressedContents.
size())
997 write(static_cast<ELF::Elf64_Word>(0));
998 write(static_cast<ELF::Elf64_Xword>(Size));
999 write(static_cast<ELF::Elf64_Xword>(Alignment));
1003 write(static_cast<ELF::Elf32_Word>(Size));
1004 write(static_cast<ELF::Elf32_Word>(Alignment));
1012 if (Size <= Magic.
size() +
sizeof(
Size) + CompressedContents.
size())
1030 bool CompressionEnabled =
1032 if (!CompressionEnabled || !SectionName.
startswith(
".debug_") ||
1033 SectionName ==
".debug_frame") {
1038 assert((MAI->compressDebugSections() == DebugCompressionType::Z ||
1039 MAI->compressDebugSections() == DebugCompressionType::GNU) &&
1040 "expected zlib or zlib-gnu style compression");
1047 setStream(OldStream);
1052 CompressedContents)) {
1054 getStream() << UncompressedData;
1058 bool ZlibStyle = MAI->compressDebugSections() == DebugCompressionType::Z;
1059 if (!maybeWriteCompression(UncompressedData.
size(), CompressedContents,
1061 getStream() << UncompressedData;
1070 MC.renameELFSection(&Section, (
".z" + SectionName.
drop_front(1)).str());
1071 getStream() << CompressedContents;
1075 uint64_t Flags, uint64_t
Address,
1076 uint64_t
Offset, uint64_t Size,
1079 uint64_t EntrySize) {
1088 WriteWord(Alignment);
1089 WriteWord(EntrySize);
1092 void ELFObjectWriter::writeRelocations(
const MCAssembler &Asm,
1094 std::vector<ELFRelocationEntry> &Relocs = Relocations[&Sec];
1103 TargetObjectWriter->sortRelocs(Asm, Relocs);
1105 for (
unsigned i = 0, e = Relocs.size(); i != e; ++i) {
1111 if (TargetObjectWriter->isN64()) {
1114 write(TargetObjectWriter->getRSsym(Entry.
Type));
1115 write(TargetObjectWriter->getRType3(Entry.
Type));
1116 write(TargetObjectWriter->getRType2(Entry.
Type));
1117 write(TargetObjectWriter->getRType(Entry.
Type));
1121 write(ERE64.r_info);
1123 if (hasRelocationAddend())
1130 write(ERE32.r_info);
1132 if (hasRelocationAddend())
1139 const MCSectionELF *StrtabSection = SectionTable[StringTableIndex - 1];
1140 StrTabBuilder.write(getStream());
1141 return StrtabSection;
1144 void ELFObjectWriter::writeSection(
const SectionIndexMapTy &SectionIndexMap,
1147 uint64_t sh_link = 0;
1148 uint64_t sh_info = 0;
1160 sh_link = SymbolTableIndex;
1161 assert(sh_link &&
".symtab not found");
1163 sh_info = SectionIndexMap.lookup(cast<MCSectionELF>(InfoSection));
1169 sh_link = StringTableIndex;
1170 sh_info = LastLocalSymbolIndex;
1174 sh_link = SymbolTableIndex;
1178 sh_link = SymbolTableIndex;
1179 sh_info = GroupSymbolIndex;
1186 sh_link = SectionIndexMap.lookup(Sec);
1189 WriteSecHdrEntry(StrTabBuilder.getOffset(Section.
getSectionName()),
1195 void ELFObjectWriter::writeSectionHeader(
1196 const MCAsmLayout &Layout,
const SectionIndexMapTy &SectionIndexMap,
1197 const SectionOffsetsTy &SectionOffsets) {
1198 const unsigned NumSections = SectionTable.size();
1201 uint64_t FirstSectionSize =
1203 WriteSecHdrEntry(0, 0, 0, 0, 0, FirstSectionSize, 0, 0, 0, 0);
1207 unsigned Type = Section->
getType();
1209 GroupSymbolIndex = 0;
1213 const std::pair<uint64_t, uint64_t> &
Offsets =
1214 SectionOffsets.find(Section)->second;
1219 Size = Offsets.second - Offsets.first;
1221 writeSection(SectionIndexMap, GroupSymbolIndex, Offsets.first, Size,
1226 void ELFObjectWriter::writeObject(
MCAssembler &Asm,
1231 StringTableIndex = addToSectionTable(StrtabSection);
1233 RevGroupMapTy RevGroupMap;
1234 SectionIndexMapTy SectionIndexMap;
1236 std::map<const MCSymbol *, std::vector<const MCSectionELF *>> GroupMembers;
1242 SectionOffsetsTy SectionOffsets;
1243 std::vector<MCSectionELF *> Groups;
1244 std::vector<MCSectionELF *> Relocations;
1251 uint64_t SecStart = getStream().tell();
1254 writeSectionData(Asm, Section, Layout);
1256 uint64_t SecEnd = getStream().tell();
1257 SectionOffsets[&
Section] = std::make_pair(SecStart, SecEnd);
1259 MCSectionELF *RelSection = createRelocationSection(Ctx, Section);
1261 if (SignatureSymbol) {
1262 Asm.registerSymbol(*SignatureSymbol);
1263 unsigned &GroupIdx = RevGroupMap[SignatureSymbol];
1266 GroupIdx = addToSectionTable(Group);
1268 Groups.push_back(Group);
1270 std::vector<const MCSectionELF *> &Members =
1271 GroupMembers[SignatureSymbol];
1272 Members.push_back(&Section);
1274 Members.push_back(RelSection);
1277 SectionIndexMap[&
Section] = addToSectionTable(&Section);
1279 SectionIndexMap[RelSection] = addToSectionTable(RelSection);
1280 Relocations.push_back(RelSection);
1288 uint64_t SecStart = getStream().tell();
1293 for (
const MCSectionELF *Member : GroupMembers[SignatureSymbol]) {
1294 uint32_t SecIndex = SectionIndexMap.lookup(Member);
1298 uint64_t SecEnd = getStream().tell();
1299 SectionOffsets[Group] = std::make_pair(SecStart, SecEnd);
1303 computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap, SectionOffsets);
1309 uint64_t SecStart = getStream().tell();
1311 writeRelocations(Asm,
1314 uint64_t SecEnd = getStream().tell();
1315 SectionOffsets[RelSection] = std::make_pair(SecStart, SecEnd);
1319 uint64_t SecStart = getStream().tell();
1321 uint64_t SecEnd = getStream().tell();
1322 SectionOffsets[Sec] = std::make_pair(SecStart, SecEnd);
1325 uint64_t NaturalAlignment =
is64Bit() ? 8 : 4;
1326 align(NaturalAlignment);
1328 const uint64_t SectionHeaderOffset = getStream().tell();
1331 writeSectionHeader(Layout, SectionIndexMap, SectionOffsets);
1335 : SectionTable.size() + 1;
1338 unsigned NumSectionsOffset;
1341 uint64_t Val = SectionHeaderOffset;
1344 getStream().pwrite(reinterpret_cast<char *>(&Val),
sizeof(Val),
1348 uint32_t Val = SectionHeaderOffset;
1351 getStream().pwrite(reinterpret_cast<char *>(&Val),
sizeof(Val),
1355 getStream().pwrite(reinterpret_cast<char *>(&NumSections),
1356 sizeof(NumSections), NumSectionsOffset);
1359 bool ELFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
1361 bool InSet,
bool IsPCRel)
const {
1362 const auto &SymA = cast<MCSymbolELF>(SA);
1368 return MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB,
1374 bool IsLittleEndian) {
1375 return new ELFObjectWriter(MOTW, OS, IsLittleEndian);
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
bool evaluateKnownAbsolute(int64_t &Res, const MCAsmLayout &Layout) const
Instances of this class represent a uniqued identifier for a section in the current translation unit...
const MCAsmInfo * getAsmInfo() const
StringRef getSectionName() const
void setSymbolAndType(Elf32_Word s, unsigned char t)
void swapByteOrder(T &Value)
const MCSymbol & getSymbol() const
bool isBindingSet() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This represents an "assembler immediate".
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MCSection * getAssociatedSection() const
void setAlignment(unsigned Value)
unsigned getFlags() const
bool getSymbolOffset(const MCSymbol &S, uint64_t &Val) const
Get the offset of the given symbol, as computed in the current layout.
A raw_ostream that writes to an SmallVector or SmallString.
unsigned getEntrySize() const
ELFYAML::ELF_STV Visibility
void setSymbolAndType(Elf64_Word s, Elf64_Word t)
unsigned getELFHeaderEFlags() const
ELF e_header flags.
unsigned getAlignment() const
MCContext & getContext() const
Defines the object file and target independent interfaces used by the assembler backend to write nati...
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
DebugCompressionType compressDebugSections() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Encapsulates the layout of an assembly file at a particular point in time.
Base class for the full range of assembler expressions which are needed for parsing.
void write32(void *P, uint32_t V, endianness E)
Represent a reference to a symbol from inside an expression.
static unsigned getRelocType(const MCValue &Target, const MCFixupKind FixupKind, const bool IsPCRel)
Translates generic PPC fixup kind to Mach-O/PPC relocation type enum.
ArrayRef< std::string > getFileNames()
Context object for machine code objects.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
static const bool IsLittleEndianHost
Utility for building string tables with deduplicated suffixes.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
const MCSymbolELF * getGroup() const
bool isThumbFunc(const MCSymbol *Func) const
Check whether a given symbol has been flagged with .thumb_func.
static uint8_t mergeTypeForSet(uint8_t origType, uint8_t newType)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
uint32_t getOffset() const
const MCSymbol * getAssociatedSymbol() const
bool isAbsolute(bool SetUsed=true) const
isAbsolute - Check if this is an absolute symbol.
const MCSymbol * getBaseSymbol(const MCSymbol &Symbol) const
If this symbol is equivalent to A + Constant, return A.
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
void writeSectionData(const MCSection *Section, const MCAsmLayout &Layout) const
Emit the section contents using the given object writer.
The instances of the Type class are immutable: once they are created, they are never changed...
Allocate memory in an ever growing pool, as if by bump-pointer.
virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B, bool InSet) const
void write16(void *P, uint16_t V, endianness E)
static bool is64Bit(const char *name)
uint32_t getIndex() const
Get the (implementation defined) index.
virtual void reset()
lifetime management
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
unsigned getBinding() const
unsigned getCommonAlignment() const
Return the alignment of a 'common' symbol.
void setFlags(unsigned F)
uint64_t getSectionAddressSize(const MCSection *Sec) const
Get the address space size of the given section, as it effects layout.
void reportError(SMLoc L, const Twine &Msg)
bool empty() const
empty - Check if the array is empty.
bool isInSection(bool SetUsed=true) const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
MCFixupKind getKind() const
const MCSymbolRefExpr * getSymB() const
static void write(bool isBE, void *P, T V)
void consumeError(Error Err)
Consume a Error without doing anything.
PowerPC TLS Dynamic Call Fixup
static const char *const Magic
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
static const char ElfMagic[]
Error compress(StringRef InputBuffer, SmallVectorImpl< char > &CompressedBuffer, CompressionLevel Level=DefaultCompression)
const MCSymbolRefExpr * getSymA() const
bool isUsedInReloc() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
MCSection * getParent() const
Target - Wrapper for Target specific information.
static bool isWeak(const MCSymbolELF &Sym)
const MCExpr * getVariableValue(bool SetUsed=true) const
getVariableValue - Get the value for variable symbols.
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
MCSection & getSection(bool SetUsed=true) const
Get the section associated with a defined, non-absolute symbol.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
static std::vector< std::string > Flags
MCObjectWriter * createELFObjectWriter(MCELFObjectTargetWriter *MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
Construct a new ELF writer instance.
Saves strings in the inheritor's stable storage and returns a StringRef with a stable character point...
StringRef getName() const
getName - Get the symbol name.
pointer data()
Return a pointer to the vector's buffer, even if empty().
MCAsmBackend & getBackend() const
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool isCommon() const
Is this a 'common' symbol.
This represents a section on linux, lots of unix variants and some bare metal systems.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group)
bool isVariable() const
isVariable - Check if this is a variable symbol.
An abstract base class for streams implementations that also support a pwrite operation.
void write64(void *P, uint64_t V, endianness E)
VariantKind getKind() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
int64_t getConstant() const
bool operator<(int64_t V1, const APSInt &V2)
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
LLVM Value Representation.
Generic interface to target specific assembler backends.
Lightweight error class with error context and mandatory checking.
bool isWeakrefUsedInReloc() const
MCAssembler & getAssembler() const
Get the assembler object this is a layout for.
uint64_t OffsetToAlignment(uint64_t Value, uint64_t Align)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
StringRef - Represent a constant reference to a string, i.e.
const MCSymbolELF * Symbol
Represents a location in source code.
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).