40 #define DEBUG_TYPE "reloc-info"
46 class ELFObjectWriter;
48 class SymbolTableWriter {
49 ELFObjectWriter &EWriter;
53 std::vector<uint32_t> ShndxIndexes;
58 void createSymtabShndx();
63 SymbolTableWriter(ELFObjectWriter &EWriter,
bool Is64Bit);
65 void writeSymbol(uint32_t
name, uint8_t
info, uint64_t value, uint64_t
size,
66 uint8_t other, uint32_t shndx,
bool Reserved);
75 bool Used,
bool Renamed);
78 struct ELFSymbolData {
80 uint32_t SectionIndex;
84 bool operator<(
const ELFSymbolData &RHS)
const {
85 unsigned LHSType = Symbol->
getType();
86 unsigned RHSType = RHS.Symbol->getType();
92 return SectionIndex < RHS.SectionIndex;
93 return Name < RHS.Name;
98 std::unique_ptr<MCELFObjectTargetWriter> TargetObjectWriter;
114 unsigned LastLocalSymbolIndex;
116 unsigned StringTableIndex;
118 unsigned SymbolTableIndex;
121 std::vector<const MCSectionELF *> SectionTable;
125 bool is64Bit()
const {
return TargetObjectWriter->is64Bit(); }
126 bool hasRelocationAddend()
const {
127 return TargetObjectWriter->hasRelocationAddend();
130 bool IsPCRel)
const {
131 return TargetObjectWriter->GetRelocType(Target, Fixup, IsPCRel);
134 void align(
unsigned Alignment);
141 void reset()
override {
144 StrTabBuilder.clear();
145 SectionTable.clear();
149 ~ELFObjectWriter()
override;
151 void WriteWord(uint64_t W) {
158 template <
typename T>
void write(
T Val) {
167 void writeSymbol(SymbolTableWriter &Writer, uint32_t StringIndex,
171 typedef std::map<const MCSectionELF *, std::pair<uint64_t, uint64_t>>
174 bool shouldRelocateWithSymbol(
const MCAssembler &Asm,
177 unsigned Type)
const;
182 uint64_t &FixedValue)
override;
193 const SectionIndexMapTy &SectionIndexMap,
194 const RevGroupMapTy &RevGroupMap,
195 SectionOffsetsTy &SectionOffsets);
206 const SectionIndexMapTy &SectionIndexMap,
207 const SectionOffsetsTy &SectionOffsets);
212 void WriteSecHdrEntry(uint32_t
Name, uint32_t Type, uint64_t
Flags,
213 uint64_t
Address, uint64_t Offset, uint64_t Size,
214 uint32_t
Link, uint32_t Info, uint64_t Alignment,
219 bool isSymbolRefDifferenceFullyResolvedImpl(
const MCAssembler &Asm,
223 bool IsPCRel)
const override;
228 void writeSection(
const SectionIndexMapTy &SectionIndexMap,
229 uint32_t GroupSymbolIndex, uint64_t Offset, uint64_t Size,
234 void ELFObjectWriter::align(
unsigned Alignment) {
239 unsigned ELFObjectWriter::addToSectionTable(
const MCSectionELF *Sec) {
240 SectionTable.push_back(Sec);
242 return SectionTable.size();
245 void SymbolTableWriter::createSymtabShndx() {
246 if (!ShndxIndexes.empty())
249 ShndxIndexes.resize(NumWritten);
253 EWriter.write(Value);
256 SymbolTableWriter::SymbolTableWriter(ELFObjectWriter &EWriter,
bool Is64Bit)
257 : EWriter(EWriter), Is64Bit(Is64Bit), NumWritten(0) {}
259 void SymbolTableWriter::writeSymbol(uint32_t
name, uint8_t
info, uint64_t value,
260 uint64_t
size, uint8_t other,
261 uint32_t shndx,
bool Reserved) {
267 if (!ShndxIndexes.empty()) {
269 ShndxIndexes.push_back(shndx);
271 ShndxIndexes.push_back(0);
285 write(uint32_t(value));
286 write(uint32_t(size));
299 return FKI.
Flags & MCFixupKindInfo::FKF_IsPCRel;
302 ELFObjectWriter::~ELFObjectWriter()
306 void ELFObjectWriter::writeHeader(
const MCAssembler &Asm) {
324 write8(TargetObjectWriter->getOSABI());
331 write16(TargetObjectWriter->getEMachine());
355 write16(StringTableIndex);
358 uint64_t ELFObjectWriter::SymbolValue(
const MCSymbol &Sym,
373 void ELFObjectWriter::executePostLayoutBinding(
MCAssembler &Asm,
379 const auto &Alias = cast<MCSymbolELF>(
A);
381 if (!Alias.isVariable())
386 const auto &
Symbol = cast<MCSymbolELF>(Ref->getSymbol());
389 size_t Pos = AliasName.
find(
'@');
390 if (Pos == StringRef::npos)
395 Alias.setExternal(
Symbol.isExternal());
396 Alias.setBinding(
Symbol.getBinding());
407 Renames.insert(std::make_pair(&
Symbol, &Alias));
412 uint8_t
Type = newType;
446 void ELFObjectWriter::writeSymbol(SymbolTableWriter &Writer,
447 uint32_t StringIndex, ELFSymbolData &MSD,
449 const auto &
Symbol = cast<MCSymbolELF>(*MSD.Symbol);
450 assert((!
Symbol.getFragment() ||
451 (
Symbol.getFragment()->getParent() == &
Symbol.getSection())) &&
452 "The symbol's section doesn't match the fragment's symbol");
458 bool IsReserved = !Base ||
Symbol.isCommon();
461 uint8_t Binding =
Symbol.getBinding();
466 uint8_t Info = (Binding << 4) | Type;
473 uint64_t Value = SymbolValue(*MSD.Symbol, Layout);
476 const MCExpr *ESize = MSD.Symbol->getSize();
478 ESize = Base->getSize();
488 Writer.writeSymbol(StringIndex, Info, Value, Size, Other, MSD.SectionIndex,
495 bool ELFObjectWriter::shouldRelocateWithSymbol(
const MCAssembler &Asm,
498 unsigned Type)
const {
499 const auto *Sym = cast_or_null<MCSymbolELF>(S);
515 case MCSymbolRefExpr::VK_PPC_TOCBASE:
522 case MCSymbolRefExpr::VK_GOT:
523 case MCSymbolRefExpr::VK_PLT:
524 case MCSymbolRefExpr::VK_GOTPCREL:
525 case MCSymbolRefExpr::VK_Mips_GOT:
526 case MCSymbolRefExpr::VK_PPC_GOT_LO:
527 case MCSymbolRefExpr::VK_PPC_GOT_HI:
528 case MCSymbolRefExpr::VK_PPC_GOT_HA:
534 assert(Sym &&
"Expected a symbol");
538 unsigned Binding = Sym->getBinding();
562 auto &Sec = cast<MCSectionELF>(Sym->
getSection());
570 if (!hasRelocationAddend())
588 if (TargetObjectWriter->needsRelocateWithSymbol(*Sym, Type))
613 void ELFObjectWriter::recordRelocation(
MCAssembler &Asm,
617 bool &IsPCRel, uint64_t &FixedValue) {
623 assert(RefB->getKind() == MCSymbolRefExpr::VK_None &&
624 "Should not have constructed this");
636 "No relocation available to represent this relative expression");
638 const auto &SymB = cast<MCSymbolELF>(RefB->getSymbol());
640 if (SymB.isUndefined())
643 Twine(
"symbol '") + SymB.getName() +
644 "' can not be undefined in a subtraction expression");
646 assert(!SymB.isAbsolute() &&
"Should have been folded");
647 const MCSection &SecB = SymB.getSection();
648 if (&SecB != &FixupSection)
650 Fixup.
getLoc(),
"Cannot represent a difference across sections");
654 Fixup.
getLoc(),
"Cannot represent a subtraction with a weak symbol");
657 uint64_t K = SymBOffset - FixupOffset;
664 const auto *SymA = RefA ? cast<MCSymbolELF>(&RefA->
getSymbol()) :
nullptr;
666 bool ViaWeakRef =
false;
667 if (SymA && SymA->isVariable()) {
668 const MCExpr *Expr = SymA->getVariableValue();
669 if (
const auto *Inner = dyn_cast<MCSymbolRefExpr>(Expr)) {
670 if (Inner->getKind() == MCSymbolRefExpr::VK_WEAKREF) {
671 SymA = cast<MCSymbolELF>(&Inner->getSymbol());
677 unsigned Type = GetRelocType(Target, Fixup, IsPCRel);
678 bool RelocateWithSymbol = shouldRelocateWithSymbol(Asm, RefA, SymA, C, Type);
679 if (!RelocateWithSymbol && SymA && !SymA->isUndefined())
683 if (hasRelocationAddend()) {
690 if (!RelocateWithSymbol) {
692 (SymA && !SymA->isUndefined()) ? &SymA->getSection() :
nullptr;
693 auto *ELFSec = cast_or_null<MCSectionELF>(SecA);
694 const auto *SectionSymbol =
695 ELFSec ? cast<MCSymbolELF>(ELFSec->getBeginSymbol()) :
nullptr;
697 SectionSymbol->setUsedInReloc();
699 Relocations[&FixupSection].push_back(Rec);
708 SymA->setIsWeakrefUsedInReloc();
710 SymA->setUsedInReloc();
713 Relocations[&FixupSection].push_back(Rec);
717 bool ELFObjectWriter::isInSymtab(
const MCAsmLayout &Layout,
723 if (Ref->getKind() == MCSymbolRefExpr::VK_WEAKREF)
752 void ELFObjectWriter::computeSymbolTable(
754 const SectionIndexMapTy &SectionIndexMap,
const RevGroupMapTy &RevGroupMap,
755 SectionOffsetsTy &SectionOffsets) {
757 SymbolTableWriter Writer(*
this,
is64Bit());
764 SymbolTableIndex = addToSectionTable(SymtabSection);
767 uint64_t SecStart = OS.tell();
770 Writer.writeSymbol(0, 0, 0, 0, 0, 0,
false);
772 std::vector<ELFSymbolData> LocalSymbolData;
773 std::vector<ELFSymbolData> ExternalSymbolData;
776 bool HasLargeSectionIndex =
false;
778 const auto &Symbol = cast<MCSymbolELF>(S);
783 if (!isInSymtab(Layout, Symbol, Used || WeakrefUsed || isSignature,
784 Renames.count(&Symbol)))
791 MSD.Symbol = cast<MCSymbolELF>(&
Symbol);
802 if (isSignature && !Used) {
803 MSD.SectionIndex = RevGroupMap.lookup(&Symbol);
805 HasLargeSectionIndex =
true;
812 MSD.SectionIndex = SectionIndexMap.lookup(&Section);
813 assert(MSD.SectionIndex &&
"Invalid section index!");
815 HasLargeSectionIndex =
true;
848 size_t Pos = Name.
find(
"@@@");
849 if (Pos != StringRef::npos) {
850 Buf += Name.
substr(0, Pos);
852 Buf += Name.
substr(Pos + Skip);
859 MSD.Name = StrTabBuilder.add(Name);
862 LocalSymbolData.push_back(MSD);
864 ExternalSymbolData.push_back(MSD);
868 unsigned SymtabShndxSectionIndex = 0;
870 if (HasLargeSectionIndex) {
873 SymtabShndxSectionIndex = addToSectionTable(SymtabShndxSection);
878 for (
const std::string &Name : FileNames)
879 StrTabBuilder.add(Name);
881 StrTabBuilder.finalize(StringTableBuilder::ELF);
883 for (
const std::string &Name : FileNames)
884 Writer.writeSymbol(StrTabBuilder.getOffset(Name),
890 array_pod_sort(ExternalSymbolData.begin(), ExternalSymbolData.end());
894 unsigned Index = FileNames.size() + 1;
896 for (ELFSymbolData &MSD : LocalSymbolData) {
899 : StrTabBuilder.getOffset(MSD.Name);
900 MSD.Symbol->setIndex(Index++);
901 writeSymbol(Writer, StringIndex, MSD, Layout);
905 LastLocalSymbolIndex = Index;
907 for (ELFSymbolData &MSD : ExternalSymbolData) {
908 unsigned StringIndex = StrTabBuilder.getOffset(MSD.Name);
909 MSD.Symbol->setIndex(Index++);
910 writeSymbol(Writer, StringIndex, MSD, Layout);
914 uint64_t SecEnd = OS.tell();
915 SectionOffsets[SymtabSection] = std::make_pair(SecStart, SecEnd);
918 if (ShndxIndexes.
empty()) {
919 assert(SymtabShndxSectionIndex == 0);
922 assert(SymtabShndxSectionIndex != 0);
924 SecStart = OS.tell();
926 SectionTable[SymtabShndxSectionIndex - 1];
927 for (uint32_t Index : ShndxIndexes)
930 SectionOffsets[SymtabShndxSection] = std::make_pair(SecStart, SecEnd);
934 ELFObjectWriter::createRelocationSection(
MCContext &Ctx,
936 if (Relocations[&Sec].empty())
940 std::string RelaSectionName = hasRelocationAddend() ?
".rela" :
".rel";
941 RelaSectionName += SectionName;
944 if (hasRelocationAddend())
955 Flags, EntrySize, Sec.
getGroup(), &Sec);
966 switch (
F.getKind()) {
967 case MCFragment::FT_Data:
968 Contents = &cast<MCDataFragment>(
F).getContents();
970 case MCFragment::FT_Dwarf:
971 Contents = &cast<MCDwarfLineAddrFragment>(
F).getContents();
973 case MCFragment::FT_DwarfFrame:
974 Contents = &cast<MCDwarfCallFrameFragment>(
F).getContents();
978 "Not expecting any other fragment types in a debug_* section");
982 return UncompressedData;
992 if (Size <= Magic.
size() +
sizeof(Size) + CompressedContents.
size())
996 CompressedContents.
insert(CompressedContents.
begin(),
997 Magic.
size() +
sizeof(Size), 0);
998 std::copy(Magic.
begin(), Magic.
end(), CompressedContents.
begin());
999 std::copy(reinterpret_cast<char *>(&Size),
1000 reinterpret_cast<char *>(&Size + 1),
1001 CompressedContents.
begin() + Magic.
size());
1014 !SectionName.
startswith(
".debug_") || SectionName ==
".debug_frame") {
1027 CompressedContents);
1039 OS << CompressedContents;
1042 void ELFObjectWriter::WriteSecHdrEntry(uint32_t Name, uint32_t Type,
1043 uint64_t Flags, uint64_t
Address,
1044 uint64_t Offset, uint64_t Size,
1045 uint32_t Link, uint32_t Info,
1047 uint64_t EntrySize) {
1056 WriteWord(Alignment);
1057 WriteWord(EntrySize);
1060 void ELFObjectWriter::writeRelocations(
const MCAssembler &Asm,
1062 std::vector<ELFRelocationEntry> &Relocs = Relocations[&Sec];
1066 TargetObjectWriter->sortRelocs(Asm, Relocs);
1068 for (
unsigned i = 0, e = Relocs.size(); i != e; ++i) {
1074 if (TargetObjectWriter->isN64()) {
1075 write(uint32_t(Index));
1077 write(TargetObjectWriter->getRSsym(Entry.
Type));
1078 write(TargetObjectWriter->getRType3(Entry.
Type));
1079 write(TargetObjectWriter->getRType2(Entry.
Type));
1080 write(TargetObjectWriter->getRType(Entry.
Type));
1084 write(ERE64.r_info);
1086 if (hasRelocationAddend())
1093 write(ERE32.r_info);
1095 if (hasRelocationAddend())
1102 const MCSectionELF *StrtabSection = SectionTable[StringTableIndex - 1];
1103 OS << StrTabBuilder.data();
1104 return StrtabSection;
1107 void ELFObjectWriter::writeSection(
const SectionIndexMapTy &SectionIndexMap,
1108 uint32_t GroupSymbolIndex, uint64_t Offset,
1110 uint64_t sh_link = 0;
1111 uint64_t sh_info = 0;
1123 sh_link = SymbolTableIndex;
1124 assert(sh_link &&
".symtab not found");
1126 sh_info = SectionIndexMap.lookup(InfoSection);
1132 sh_link = StringTableIndex;
1133 sh_info = LastLocalSymbolIndex;
1137 sh_link = SymbolTableIndex;
1141 sh_link = SymbolTableIndex;
1142 sh_info = GroupSymbolIndex;
1146 if (TargetObjectWriter->getEMachine() ==
ELF::EM_ARM &&
1150 WriteSecHdrEntry(StrTabBuilder.getOffset(Section.
getSectionName()),
1156 void ELFObjectWriter::writeSectionHeader(
1157 const MCAsmLayout &Layout,
const SectionIndexMapTy &SectionIndexMap,
1158 const SectionOffsetsTy &SectionOffsets) {
1159 const unsigned NumSections = SectionTable.size();
1162 uint64_t FirstSectionSize =
1164 WriteSecHdrEntry(0, 0, 0, 0, 0, FirstSectionSize, 0, 0, 0, 0);
1167 uint32_t GroupSymbolIndex;
1168 unsigned Type = Section->
getType();
1170 GroupSymbolIndex = 0;
1174 const std::pair<uint64_t, uint64_t> &
Offsets =
1175 SectionOffsets.find(Section)->second;
1180 Size = Offsets.second - Offsets.first;
1182 writeSection(SectionIndexMap, GroupSymbolIndex, Offsets.first, Size,
1187 void ELFObjectWriter::writeObject(
MCAssembler &Asm,
1192 StringTableIndex = addToSectionTable(StrtabSection);
1194 RevGroupMapTy RevGroupMap;
1195 SectionIndexMapTy SectionIndexMap;
1197 std::map<const MCSymbol *, std::vector<const MCSectionELF *>> GroupMembers;
1203 SectionOffsetsTy SectionOffsets;
1204 std::vector<MCSectionELF *> Groups;
1205 std::vector<MCSectionELF *> Relocations;
1212 uint64_t SecStart = OS.tell();
1215 writeSectionData(Asm, Section, Layout);
1217 uint64_t SecEnd = OS.tell();
1218 SectionOffsets[&
Section] = std::make_pair(SecStart, SecEnd);
1220 MCSectionELF *RelSection = createRelocationSection(Ctx, Section);
1222 if (SignatureSymbol) {
1223 Asm.registerSymbol(*SignatureSymbol);
1224 unsigned &GroupIdx = RevGroupMap[SignatureSymbol];
1227 GroupIdx = addToSectionTable(Group);
1229 Groups.push_back(Group);
1231 std::vector<const MCSectionELF *> &Members =
1232 GroupMembers[SignatureSymbol];
1233 Members.push_back(&Section);
1235 Members.push_back(RelSection);
1238 SectionIndexMap[&
Section] = addToSectionTable(&Section);
1240 SectionIndexMap[RelSection] = addToSectionTable(RelSection);
1241 Relocations.push_back(RelSection);
1249 uint64_t SecStart = OS.tell();
1252 assert(SignatureSymbol);
1254 for (
const MCSectionELF *Member : GroupMembers[SignatureSymbol]) {
1255 uint32_t SecIndex = SectionIndexMap.lookup(Member);
1259 uint64_t SecEnd = OS.tell();
1260 SectionOffsets[Group] = std::make_pair(SecStart, SecEnd);
1264 computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap, SectionOffsets);
1270 uint64_t SecStart = OS.tell();
1274 uint64_t SecEnd = OS.tell();
1275 SectionOffsets[RelSection] = std::make_pair(SecStart, SecEnd);
1279 uint64_t SecStart = OS.tell();
1281 uint64_t SecEnd = OS.tell();
1282 SectionOffsets[Sec] = std::make_pair(SecStart, SecEnd);
1285 uint64_t NaturalAlignment =
is64Bit() ? 8 : 4;
1286 align(NaturalAlignment);
1288 const unsigned SectionHeaderOffset = OS.tell();
1291 writeSectionHeader(Layout, SectionIndexMap, SectionOffsets);
1295 : SectionTable.size() + 1;
1298 unsigned NumSectionsOffset;
1301 uint64_t Val = SectionHeaderOffset;
1304 OS.pwrite(reinterpret_cast<char *>(&Val),
sizeof(Val),
1308 uint32_t Val = SectionHeaderOffset;
1311 OS.pwrite(reinterpret_cast<char *>(&Val),
sizeof(Val),
1315 OS.pwrite(reinterpret_cast<char *>(&NumSections),
sizeof(NumSections),
1319 bool ELFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
1321 bool InSet,
bool IsPCRel)
const {
1322 const auto &SymA = cast<MCSymbolELF>(SA);
1328 return MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB,
1333 const auto &Sym = cast<MCSymbolELF>(S);
1349 const auto &Sec = cast<MCSectionELF>(Sym.
getSection());
1355 bool IsLittleEndian) {
1356 return new ELFObjectWriter(MOTW, OS, IsLittleEndian);
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
size_t size() const
size - Get the string size.
This represents an "assembler immediate".
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags)
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
void setAlignment(unsigned Value)
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg) const
unsigned getFlags() const
StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool getSymbolOffset(const MCSymbol &S, uint64_t &Val) const
Get the offset of the given symbol, as computed in the current layout.
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
static SmallVector< char, 128 > getUncompressedData(const MCAsmLayout &Layout, const MCSection::FragmentListType &Fragments)
MCContext & getContext() const
Defines the object file and target independent interfaces used by the assembler backend to write nati...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void renameELFSection(MCSectionELF *Section, StringRef Name)
Encapsulates the layout of an assembly file at a particular point in time.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCExpr * getVariableValue() const
getVariableValue() - Get the value for variable symbols.
Base class for the full range of assembler expressions which are needed for parsing.
Status compress(StringRef InputBuffer, SmallVectorImpl< char > &CompressedBuffer, CompressionLevel Level=DefaultCompression)
Represent a reference to a symbol from inside an expression.
ArrayRef< std::string > getFileNames()
Context object for machine code objects.
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
static const bool IsLittleEndianHost
Utility for building string tables with deduplicated suffixes.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const MCSymbolELF * getGroup() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
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)
uint32_t getOffset() const
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.
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...
static bool is64Bit(const char *name)
uint32_t getIndex() const
Get the (implementation defined) index.
virtual void reset()
lifetime management
MCFixupKind
Extensible enumeration to represent the type of a fixup.
unsigned getBinding() const
unsigned getCommonAlignment() const
Return the alignment of a 'common' symbol.
uint64_t getSectionAddressSize(const MCSection *Sec) const
Get the address space size of the given section, as it effects layout.
const MCSectionELF * getAssociatedSection() const
MCSectionELF * createELFRelSection(StringRef Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *Associated)
bool empty() const
empty - Check if the array is empty.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
const MCSymbolRefExpr * getSymB() const
bool isAbsolute() const
isAbsolute - Check if this is an absolute symbol.
PowerPC TLS Dynamic Call Fixup
static const char *const Magic
static const char ElfMagic[]
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
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 & getSection() const
Get the section associated with a defined, non-absolute symbol.
MCSection * getParent() const
Target - Wrapper for Target specific information.
static bool isWeak(const MCSymbolELF &Sym)
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool compressDebugSections() const
iterator insert(iterator I, T &&Elt)
void write(void *memory, value_type value)
Write a value to memory with a particular endianness.
MCObjectWriter * createELFObjectWriter(MCELFObjectTargetWriter *MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
Construct a new ELF writer instance.
Adapter to write values to a stream in a particular byte order.
StringRef getName() const
getName - Get the symbol name.
pointer data()
Return a pointer to the vector's buffer, even if empty().
MCAsmBackend & getBackend() const
bool isCommon() const
Is this a 'common' symbol.
MCSectionELF - This represents a section on linux, lots of unix variants and some bare metal systems...
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
static bool prependCompressionHeader(uint64_t Size, SmallVectorImpl< char > &CompressedContents)
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group)
Target independent information on a fixup kind.
bool isVariable() const
isVariable - Check if this is a variable symbol.
An abstract base class for streams implementations that also support a pwrite operation.
VariantKind getKind() const
int64_t getConstant() const
const ARM::ArchExtKind Kind
bool operator<(int64_t V1, const APSInt &V2)
LLVM Value Representation.
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...
C - The default llvm calling convention, compatible with C.
StringRef - Represent a constant reference to a string, i.e.
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
const MCSymbolELF * Symbol
Represents a location in source code.
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
MCSection::FragmentListType & getFragmentList()
unsigned Flags
Flags describing additional information on this fixup kind.