#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSectionXCOFF.h"
#include "llvm/MC/MCSymbolXCOFF.h"
#include "llvm/MC/MCValue.h"
#include "llvm/MC/MCXCOFFObjectWriter.h"
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <deque>
#include <map>
usingnamespacellvm;
namespace {
constexpr unsigned DefaultSectionAlign = …;
constexpr int16_t MaxSectionIndex = …;
uint8_t getEncodedType(const MCSectionXCOFF *);
struct XCOFFRelocation { … };
struct Symbol { … };
struct XCOFFSection { … };
CsectGroup;
CsectGroups;
struct SectionEntry { … };
struct CsectSectionEntry : public SectionEntry { … };
struct DwarfSectionEntry : public SectionEntry { … };
struct ExceptionTableEntry { … };
struct ExceptionInfo { … };
struct ExceptionSectionEntry : public SectionEntry { … };
struct CInfoSymInfo { … };
struct CInfoSymSectionEntry : public SectionEntry { … };
class XCOFFObjectWriter : public MCObjectWriter { … };
XCOFFObjectWriter::XCOFFObjectWriter(
std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW, raw_pwrite_stream &OS)
: … { … }
void XCOFFObjectWriter::reset() { … }
CsectGroup &XCOFFObjectWriter::getCsectGroup(const MCSectionXCOFF *MCSec) { … }
static MCSectionXCOFF *getContainingCsect(const MCSymbolXCOFF *XSym) { … }
void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm) { … }
void XCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) { … }
void XCOFFObjectWriter::writeSections(const MCAssembler &Asm) { … }
uint64_t XCOFFObjectWriter::writeObject(MCAssembler &Asm) { … }
bool XCOFFObjectWriter::nameShouldBeInStringTable(const StringRef &SymbolName) { … }
void XCOFFObjectWriter::writeSymbolName(const StringRef &SymbolName) { … }
void XCOFFObjectWriter::writeSymbolEntry(StringRef SymbolName, uint64_t Value,
int16_t SectionNumber,
uint16_t SymbolType,
uint8_t StorageClass,
uint8_t NumberOfAuxEntries) { … }
void XCOFFObjectWriter::writeSymbolAuxCsectEntry(uint64_t SectionOrLength,
uint8_t SymbolAlignmentAndType,
uint8_t StorageMappingClass) { … }
bool XCOFFObjectWriter::auxFileSymNameShouldBeInStringTable(
const StringRef &SymbolName) { … }
void XCOFFObjectWriter::writeAuxFileSymName(const StringRef &SymbolName) { … }
void XCOFFObjectWriter::writeSymbolAuxFileEntry(StringRef &Name,
uint8_t ftype) { … }
void XCOFFObjectWriter::writeSymbolAuxDwarfEntry(
uint64_t LengthOfSectionPortion, uint64_t NumberOfRelocEnt) { … }
void XCOFFObjectWriter::writeSymbolEntryForCsectMemberLabel(
const Symbol &SymbolRef, const XCOFFSection &CSectionRef,
int16_t SectionIndex, uint64_t SymbolOffset) { … }
void XCOFFObjectWriter::writeSymbolEntryForDwarfSection(
const XCOFFSection &DwarfSectionRef, int16_t SectionIndex) { … }
void XCOFFObjectWriter::writeSymbolEntryForControlSection(
const XCOFFSection &CSectionRef, int16_t SectionIndex,
XCOFF::StorageClass StorageClass) { … }
void XCOFFObjectWriter::writeSymbolAuxFunctionEntry(uint32_t EntryOffset,
uint32_t FunctionSize,
uint64_t LineNumberPointer,
uint32_t EndIndex) { … }
void XCOFFObjectWriter::writeSymbolAuxExceptionEntry(uint64_t EntryOffset,
uint32_t FunctionSize,
uint32_t EndIndex) { … }
void XCOFFObjectWriter::writeFileHeader() { … }
void XCOFFObjectWriter::writeAuxFileHeader() { … }
void XCOFFObjectWriter::writeSectionHeader(const SectionEntry *Sec) { … }
void XCOFFObjectWriter::writeSectionHeaderTable() { … }
void XCOFFObjectWriter::writeRelocation(XCOFFRelocation Reloc,
const XCOFFSection &Section) { … }
void XCOFFObjectWriter::writeRelocations() { … }
void XCOFFObjectWriter::writeSymbolTable(MCAssembler &Asm) { … }
void XCOFFObjectWriter::finalizeRelocationInfo(SectionEntry *Sec,
uint64_t RelCount) { … }
void XCOFFObjectWriter::calcOffsetToRelocations(SectionEntry *Sec,
uint64_t &RawPointer) { … }
void XCOFFObjectWriter::finalizeSectionInfo() { … }
void XCOFFObjectWriter::addExceptionEntry(
const MCSymbol *Symbol, const MCSymbol *Trap, unsigned LanguageCode,
unsigned ReasonCode, unsigned FunctionSize, bool hasDebug) { … }
unsigned XCOFFObjectWriter::getExceptionSectionSize() { … }
unsigned XCOFFObjectWriter::getExceptionOffset(const MCSymbol *Symbol) { … }
void XCOFFObjectWriter::addCInfoSymEntry(StringRef Name, StringRef Metadata) { … }
void XCOFFObjectWriter::assignAddressesAndIndices(MCAssembler &Asm) { … }
void XCOFFObjectWriter::writeSectionForControlSectionEntry(
const MCAssembler &Asm, const CsectSectionEntry &CsectEntry,
uint64_t &CurrentAddressLocation) { … }
void XCOFFObjectWriter::writeSectionForDwarfSectionEntry(
const MCAssembler &Asm, const DwarfSectionEntry &DwarfEntry,
uint64_t &CurrentAddressLocation) { … }
void XCOFFObjectWriter::writeSectionForExceptionSectionEntry(
const MCAssembler &Asm, ExceptionSectionEntry &ExceptionEntry,
uint64_t &CurrentAddressLocation) { … }
void XCOFFObjectWriter::writeSectionForCInfoSymSectionEntry(
const MCAssembler &Asm, CInfoSymSectionEntry &CInfoSymEntry,
uint64_t &CurrentAddressLocation) { … }
uint8_t getEncodedType(const MCSectionXCOFF *Sec) { … }
}
std::unique_ptr<MCObjectWriter>
llvm::createXCOFFObjectWriter(std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW,
raw_pwrite_stream &OS) { … }
void XCOFF::addExceptionEntry(MCObjectWriter &Writer, const MCSymbol *Symbol,
const MCSymbol *Trap, unsigned LanguageCode,
unsigned ReasonCode, unsigned FunctionSize,
bool hasDebug) { … }
void XCOFF::addCInfoSymEntry(MCObjectWriter &Writer, StringRef Name,
StringRef Metadata) { … }