#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfoDarwin.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolMachO.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <string>
#include <utility>
#include <vector>
usingnamespacellvm;
#define DEBUG_TYPE …
void MachObjectWriter::reset() { … }
bool MachObjectWriter::doesSymbolRequireExternRelocation(const MCSymbol &S) { … }
bool MachObjectWriter::
MachSymbolData::operator<(const MachSymbolData &RHS) const { … }
bool MachObjectWriter::isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind) { … }
uint64_t
MachObjectWriter::getFragmentAddress(const MCAssembler &Asm,
const MCFragment *Fragment) const { … }
uint64_t MachObjectWriter::getSymbolAddress(const MCSymbol &S,
const MCAssembler &Asm) const { … }
uint64_t MachObjectWriter::getPaddingSize(const MCAssembler &Asm,
const MCSection *Sec) const { … }
static bool isSymbolLinkerVisible(const MCSymbol &Symbol) { … }
const MCSymbol *MachObjectWriter::getAtom(const MCSymbol &S) const { … }
void MachObjectWriter::writeHeader(MachO::HeaderFileType Type,
unsigned NumLoadCommands,
unsigned LoadCommandsSize,
bool SubsectionsViaSymbols) { … }
void MachObjectWriter::writeWithPadding(StringRef Str, uint64_t Size) { … }
void MachObjectWriter::writeSegmentLoadCommand(
StringRef Name, unsigned NumSections, uint64_t VMAddr, uint64_t VMSize,
uint64_t SectionDataStartOffset, uint64_t SectionDataSize, uint32_t MaxProt,
uint32_t InitProt) { … }
void MachObjectWriter::writeSection(const MCAssembler &Asm,
const MCSection &Sec, uint64_t VMAddr,
uint64_t FileOffset, unsigned Flags,
uint64_t RelocationsStart,
unsigned NumRelocations) { … }
void MachObjectWriter::writeSymtabLoadCommand(uint32_t SymbolOffset,
uint32_t NumSymbols,
uint32_t StringTableOffset,
uint32_t StringTableSize) { … }
void MachObjectWriter::writeDysymtabLoadCommand(uint32_t FirstLocalSymbol,
uint32_t NumLocalSymbols,
uint32_t FirstExternalSymbol,
uint32_t NumExternalSymbols,
uint32_t FirstUndefinedSymbol,
uint32_t NumUndefinedSymbols,
uint32_t IndirectSymbolOffset,
uint32_t NumIndirectSymbols) { … }
MachObjectWriter::MachSymbolData *
MachObjectWriter::findSymbolData(const MCSymbol &Sym) { … }
const MCSymbol &MachObjectWriter::findAliasedSymbol(const MCSymbol &Sym) const { … }
void MachObjectWriter::writeNlist(MachSymbolData &MSD, const MCAssembler &Asm) { … }
void MachObjectWriter::writeLinkeditLoadCommand(uint32_t Type,
uint32_t DataOffset,
uint32_t DataSize) { … }
static unsigned ComputeLinkerOptionsLoadCommandSize(
const std::vector<std::string> &Options, bool is64Bit)
{ … }
void MachObjectWriter::writeLinkerOptionsLoadCommand(
const std::vector<std::string> &Options)
{ … }
static bool isFixupTargetValid(const MCValue &Target) { … }
void MachObjectWriter::recordRelocation(MCAssembler &Asm,
const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) { … }
void MachObjectWriter::bindIndirectSymbols(MCAssembler &Asm) { … }
void MachObjectWriter::computeSymbolTable(
MCAssembler &Asm, std::vector<MachSymbolData> &LocalSymbolData,
std::vector<MachSymbolData> &ExternalSymbolData,
std::vector<MachSymbolData> &UndefinedSymbolData) { … }
void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm) { … }
void MachObjectWriter::executePostLayoutBinding(MCAssembler &Asm) { … }
bool MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB,
bool InSet, bool IsPCRel) const { … }
static MachO::LoadCommandType getLCFromMCVM(MCVersionMinType Type) { … }
void MachObjectWriter::populateAddrSigSection(MCAssembler &Asm) { … }
uint64_t MachObjectWriter::writeObject(MCAssembler &Asm) { … }