#include "InputFiles.h"
#include "Config.h"
#include "Driver.h"
#include "Dwarf.h"
#include "EhFrame.h"
#include "ExportTrie.h"
#include "InputSection.h"
#include "MachOStructs.h"
#include "ObjC.h"
#include "OutputSection.h"
#include "OutputSegment.h"
#include "SymbolTable.h"
#include "Symbols.h"
#include "SyntheticSections.h"
#include "Target.h"
#include "lld/Common/CommonLinkerContext.h"
#include "lld/Common/DWARF.h"
#include "lld/Common/Reproduce.h"
#include "llvm/ADT/iterator.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/LTO/LTO.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TarWriter.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/TextAPI/Architecture.h"
#include "llvm/TextAPI/InterfaceFile.h"
#include <optional>
#include <type_traits>
usingnamespacellvm;
usingnamespacellvm::MachO;
usingnamespacellvm::support::endian;
usingnamespacellvm::sys;
usingnamespacelld;
usingnamespacelld::macho;
std::string lld::toString(const InputFile *f) { … }
std::string lld::toString(const Section &sec) { … }
SetVector<InputFile *> macho::inputFiles;
std::unique_ptr<TarWriter> macho::tar;
int InputFile::idCount = …;
static VersionTuple decodeVersion(uint32_t version) { … }
static std::vector<PlatformInfo> getPlatformInfos(const InputFile *input) { … }
static bool checkCompatibility(const InputFile *input) { … }
template <class Header>
static bool compatWithTargetArch(const InputFile *file, const Header *hdr) { … }
DenseMap<CachedHashStringRef, MemoryBufferRef> macho::cachedReads;
std::optional<MemoryBufferRef> macho::readFile(StringRef path) { … }
InputFile::InputFile(Kind kind, const InterfaceFile &interface)
: … { … }
static std::optional<size_t> getRecordSize(StringRef segname, StringRef name) { … }
static Error parseCallGraph(ArrayRef<uint8_t> data,
std::vector<CallGraphEntry> &callGraph) { … }
template <class SectionHeader>
void ObjFile::parseSections(ArrayRef<SectionHeader> sectionHeaders) { … }
void ObjFile::splitEhFrames(ArrayRef<uint8_t> data, Section &ehFrameSection) { … }
template <class T>
static Section *findContainingSection(const std::vector<Section *> §ions,
T *offset) { … }
template <class T>
static InputSection *findContainingSubsection(const Section §ion,
T *offset) { … }
static Defined *findSymbolAtOffset(const ConcatInputSection *isec,
uint64_t off) { … }
template <class SectionHeader>
static bool validateRelocationInfo(InputFile *file, const SectionHeader &sec,
relocation_info rel) { … }
template <class SectionHeader>
void ObjFile::parseRelocations(ArrayRef<SectionHeader> sectionHeaders,
const SectionHeader &sec, Section §ion) { … }
template <class NList>
static macho::Symbol *createDefined(const NList &sym, StringRef name,
InputSection *isec, uint64_t value,
uint64_t size, bool forceHidden) { … }
template <class NList>
static macho::Symbol *createAbsolute(const NList &sym, InputFile *file,
StringRef name, bool forceHidden) { … }
template <class NList>
macho::Symbol *ObjFile::parseNonSectionSymbol(const NList &sym,
const char *strtab) { … }
template <class NList> static bool isUndef(const NList &sym) { … }
template <class LP>
void ObjFile::parseSymbols(ArrayRef<typename LP::section> sectionHeaders,
ArrayRef<typename LP::nlist> nList,
const char *strtab, bool subsectionsViaSymbols) { … }
OpaqueFile::OpaqueFile(MemoryBufferRef mb, StringRef segName,
StringRef sectName)
: … { … }
template <class LP>
void ObjFile::parseLinkerOptions(SmallVectorImpl<StringRef> &LCLinkerOptions) { … }
SmallVector<StringRef> macho::unprocessedLCLinkerOptions;
ObjFile::ObjFile(MemoryBufferRef mb, uint32_t modTime, StringRef archiveName,
bool lazy, bool forceHidden, bool compatArch,
bool builtFromBitcode)
: … { … }
template <class LP> void ObjFile::parse() { … }
template <class LP> void ObjFile::parseLazy() { … }
void ObjFile::parseDebugInfo() { … }
ArrayRef<data_in_code_entry> ObjFile::getDataInCode() const { … }
ArrayRef<uint8_t> ObjFile::getOptimizationHints() const { … }
void ObjFile::registerCompactUnwind(Section &compactUnwindSection) { … }
struct CIE { … };
static uint8_t pointerEncodingToSize(uint8_t enc) { … }
static CIE parseCIE(const InputSection *isec, const EhReader &reader,
size_t off) { … }
template <bool Invert = false>
Defined *
targetSymFromCanonicalSubtractor(const InputSection *isec,
std::vector<macho::Reloc>::iterator relocIt) { … }
Defined *findSymbolAtAddress(const std::vector<Section *> §ions,
uint64_t addr) { … }
void ObjFile::registerEhFrames(Section &ehFrameSection) { … }
std::string ObjFile::sourceFile() const { … }
lld::DWARFCache *ObjFile::getDwarf() { … }
static DylibFile *loadDylib(StringRef path, DylibFile *umbrella) { … }
static DylibFile *findDylib(StringRef path, DylibFile *umbrella,
const InterfaceFile *currentTopLevelTapi) { … }
static bool isImplicitlyLinked(StringRef path) { … }
void DylibFile::loadReexport(StringRef path, DylibFile *umbrella,
const InterfaceFile *currentTopLevelTapi) { … }
DylibFile::DylibFile(MemoryBufferRef mb, DylibFile *umbrella,
bool isBundleLoader, bool explicitlyLinked)
: … { … }
void DylibFile::parseExportedSymbols(uint32_t offset, uint32_t size) { … }
void DylibFile::parseLoadCommands(MemoryBufferRef mb) { … }
constexpr std::array<StringRef, 3> skipPlatformChecks{ … };
static bool skipPlatformCheckForCatalyst(const InterfaceFile &interface,
bool explicitlyLinked) { … }
static bool isArchABICompatible(ArchitectureSet archSet,
Architecture targetArch) { … }
static bool isTargetPlatformArchCompatible(
InterfaceFile::const_target_range interfaceTargets, Target target) { … }
DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella,
bool isBundleLoader, bool explicitlyLinked)
: … { … }
DylibFile::DylibFile(DylibFile *umbrella)
: … { … }
void DylibFile::parseReexports(const InterfaceFile &interface) { … }
bool DylibFile::isExplicitlyLinked() const { … }
DylibFile *DylibFile::getSyntheticDylib(StringRef installName,
uint32_t currentVersion,
uint32_t compatVersion) { … }
bool DylibFile::handleLDSymbol(StringRef originalName) { … }
void DylibFile::handleLDPreviousSymbol(StringRef name, StringRef originalName) { … }
void DylibFile::handleLDInstallNameSymbol(StringRef name,
StringRef originalName) { … }
void DylibFile::handleLDHideSymbol(StringRef name, StringRef originalName) { … }
void DylibFile::checkAppExtensionSafety(bool dylibIsAppExtensionSafe) const { … }
ArchiveFile::ArchiveFile(std::unique_ptr<object::Archive> &&f, bool forceHidden)
: … { … }
void ArchiveFile::addLazySymbols() { … }
static Expected<InputFile *>
loadArchiveMember(MemoryBufferRef mb, uint32_t modTime, StringRef archiveName,
uint64_t offsetInArchive, bool forceHidden, bool compatArch) { … }
Error ArchiveFile::fetch(const object::Archive::Child &c, StringRef reason) { … }
void ArchiveFile::fetch(const object::Archive::Symbol &sym) { … }
static macho::Symbol *createBitcodeSymbol(const lto::InputFile::Symbol &objSym,
BitcodeFile &file) { … }
BitcodeFile::BitcodeFile(MemoryBufferRef mb, StringRef archiveName,
uint64_t offsetInArchive, bool lazy, bool forceHidden,
bool compatArch)
: … { … }
void BitcodeFile::parse() { … }
void BitcodeFile::parseLazy() { … }
std::string macho::replaceThinLTOSuffix(StringRef path) { … }
void macho::extract(InputFile &file, StringRef reason) { … }
template void ObjFile::parse<LP64>();