LLVM: lib/Object/MachOObjectFile.cpp File Reference (original) (raw)

Go to the source code of this file.

Macros
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF)
Functions
static Error malformedError (const Twine &Msg)
template<typename T>
static T getStruct (const MachOObjectFile &O, const char *P)
template<typename T>
static Expected< T > getStructOrErr (const MachOObjectFile &O, const char *P)
static const char * getSectionPtr (const MachOObjectFile &O, MachOObjectFile::LoadCommandInfo L, unsigned Sec)
static const char * getPtr (const MachOObjectFile &O, size_t Offset, size_t MachOFilesetEntryOffset=0)
static MachO::nlist_base getSymbolTableEntryBase (const MachOObjectFile &O, DataRefImpl DRI)
static StringRef parseSegmentOrSectionName (const char *P)
static unsigned getCPUType (const MachOObjectFile &O)
static unsigned getCPUSubType (const MachOObjectFile &O)
static uint32_t getPlainRelocationAddress (const MachO::any_relocation_info &RE)
static unsigned getScatteredRelocationAddress (const MachO::any_relocation_info &RE)
static bool getPlainRelocationPCRel (const MachOObjectFile &O, const MachO::any_relocation_info &RE)
static bool getScatteredRelocationPCRel (const MachO::any_relocation_info &RE)
static unsigned getPlainRelocationLength (const MachOObjectFile &O, const MachO::any_relocation_info &RE)
static unsigned getScatteredRelocationLength (const MachO::any_relocation_info &RE)
static unsigned getPlainRelocationType (const MachOObjectFile &O, const MachO::any_relocation_info &RE)
static uint32_t getSectionFlags (const MachOObjectFile &O, DataRefImpl Sec)
static Expected< MachOObjectFile::LoadCommandInfo > getLoadCommandInfo (const MachOObjectFile &Obj, const char *Ptr, uint32_t LoadCommandIndex)
static Expected< MachOObjectFile::LoadCommandInfo > getFirstLoadCommandInfo (const MachOObjectFile &Obj)
static Expected< MachOObjectFile::LoadCommandInfo > getNextLoadCommandInfo (const MachOObjectFile &Obj, uint32_t LoadCommandIndex, const MachOObjectFile::LoadCommandInfo &L)
template<typename T>
static void parseHeader (const MachOObjectFile &Obj, T &Header, Error &Err)
static Error checkOverlappingElement (std::list< MachOElement > &Elements, uint64_t Offset, uint64_t Size, const char *Name)
template<typename Segment, typename Section>
static Error parseSegmentLoadCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, SmallVectorImpl< const char * > &Sections, bool &IsPageZeroSegment, uint32_t LoadCommandIndex, const char *CmdName, uint64_t SizeOfHeaders, std::list< MachOElement > &Elements)
static Error checkSymtabCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char **SymtabLoadCmd, std::list< MachOElement > &Elements)
static Error checkDysymtabCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char **DysymtabLoadCmd, std::list< MachOElement > &Elements)
static Error checkLinkeditDataCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char **LoadCmd, const char *CmdName, std::list< MachOElement > &Elements, const char *ElementName)
static Error checkDyldInfoCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char **LoadCmd, const char *CmdName, std::list< MachOElement > &Elements)
static Error checkDylibCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char *CmdName)
static Error checkDylibIdCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char **LoadCmd)
static Error checkDyldCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char *CmdName)
static Error checkVersCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char **LoadCmd, const char *CmdName)
static Error checkNoteCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, std::list< MachOElement > &Elements)
static Error parseBuildVersionCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, SmallVectorImpl< const char * > &BuildTools, uint32_t LoadCommandIndex)
static Error checkRpathCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex)
static Error checkEncryptCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, uint64_t cryptoff, uint64_t cryptsize, const char **LoadCmd, const char *CmdName)
static Error checkLinkerOptCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex)
static Error checkSubCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char *CmdName, size_t SizeOfCmd, const char *CmdStructName, uint32_t PathOffset, const char *PathFieldName)
static Error checkThreadCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char *CmdName)
static Error checkTwoLevelHintsCommand (const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load, uint32_t LoadCommandIndex, const char **LoadCmd, std::list< MachOElement > &Elements)
static bool isLoadCommandObsolete (uint32_t cmd)
template<typename T>
static int getEncodedOrdinal (T Value)
template<typename T, unsigned N>
static std::array< T, N > getArray (const MachOObjectFile &O, const void *Ptr)

HANDLE_SWIFT_SECTION

#define HANDLE_SWIFT_SECTION ( KIND,
MACHO,
ELF,
COFF )

Value:

.Case(MACHO, llvm::binaryformat::Swift5ReflectionSectionKind::KIND)

checkDyldCommand()

checkDyldInfoCommand()

Definition at line 639 of file MachOObjectFile.cpp.

References llvm::MachO::dyld_info_command::bind_off, llvm::MachO::dyld_info_command::bind_size, checkOverlappingElement(), llvm::MachO::dyld_info_command::cmdsize, llvm::MachO::dyld_info_command::export_off, llvm::MachO::dyld_info_command::export_size, getStructOrErr(), llvm::MachO::dyld_info_command::lazy_bind_off, llvm::MachO::dyld_info_command::lazy_bind_size, malformedError(), llvm::MachO::dyld_info_command::rebase_off, llvm::MachO::dyld_info_command::rebase_size, llvm::Error::success(), llvm::MachO::dyld_info_command::weak_bind_off, and llvm::MachO::dyld_info_command::weak_bind_size.

checkDylibCommand()

checkDylibIdCommand()

checkDysymtabCommand()

Definition at line 468 of file MachOObjectFile.cpp.

References checkOverlappingElement(), llvm::MachO::dysymtab_command::cmdsize, llvm::MachO::dysymtab_command::extrefsymoff, llvm::MachO::dysymtab_command::extreloff, getStructOrErr(), llvm::MachO::dysymtab_command::indirectsymoff, llvm::MachO::dysymtab_command::locreloff, malformedError(), llvm::MachO::dysymtab_command::modtaboff, llvm::MachO::dysymtab_command::nextrefsyms, llvm::MachO::dysymtab_command::nextrel, llvm::MachO::dysymtab_command::nindirectsyms, llvm::MachO::dysymtab_command::nlocrel, llvm::MachO::dysymtab_command::nmodtab, llvm::MachO::dysymtab_command::ntoc, llvm::Error::success(), and llvm::MachO::dysymtab_command::tocoff.

checkEncryptCommand()

checkLinkeditDataCommand()

checkLinkerOptCommand()

checkNoteCommand()

checkOverlappingElement()

Definition at line 253 of file MachOObjectFile.cpp.

References E(), malformedError(), N, llvm::Offset, Size, and llvm::Error::success().

Referenced by checkDyldInfoCommand(), checkDysymtabCommand(), checkLinkeditDataCommand(), checkNoteCommand(), checkSymtabCommand(), checkTwoLevelHintsCommand(), and parseSegmentLoadCommand().

checkRpathCommand()

checkSubCommand()

checkSymtabCommand()

checkThreadCommand()

Definition at line 1009 of file MachOObjectFile.cpp.

References llvm::MachO::ARM_THREAD_STATE, llvm::MachO::ARM_THREAD_STATE64, llvm::MachO::ARM_THREAD_STATE64_COUNT, llvm::MachO::ARM_THREAD_STATE_COUNT, llvm::count(), llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_TYPE_ARM64_32, llvm::MachO::CPU_TYPE_I386, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_TYPE_X86_64, getCPUType(), getStructOrErr(), llvm::sys::IsLittleEndianHost, malformedError(), llvm::MachO::PPC_THREAD_STATE, llvm::MachO::PPC_THREAD_STATE_COUNT, llvm::Error::success(), llvm::sys::swapByteOrder(), T, llvm::MachO::x86_EXCEPTION_STATE, llvm::MachO::x86_EXCEPTION_STATE64, llvm::MachO::x86_EXCEPTION_STATE64_COUNT, llvm::MachO::x86_EXCEPTION_STATE_COUNT, llvm::MachO::x86_FLOAT_STATE, llvm::MachO::x86_FLOAT_STATE_COUNT, llvm::MachO::x86_THREAD_STATE, llvm::MachO::x86_THREAD_STATE32, llvm::MachO::x86_THREAD_STATE32_COUNT, llvm::MachO::x86_THREAD_STATE64, llvm::MachO::x86_THREAD_STATE64_COUNT, and llvm::MachO::x86_THREAD_STATE_COUNT.

checkTwoLevelHintsCommand()

checkVersCommand()

getArray()

getCPUSubType()

getCPUType()

getEncodedOrdinal()

template<typename T>

int getEncodedOrdinal ( T Value) static

getFirstLoadCommandInfo()

getLoadCommandInfo()

getNextLoadCommandInfo()

getPlainRelocationAddress()

getPlainRelocationLength()

getPlainRelocationPCRel()

getPlainRelocationType()

getPtr()

Definition at line 111 of file MachOObjectFile.cpp.

References assert(), and llvm::Offset.

Referenced by llvm::object::MachOObjectFile::begin_dices(), llvm::Error::dynamicClassID(), llvm::object::MachOObjectFile::end_dices(), llvm::object::MachOObjectFile::getChainedFixupsHeader(), llvm::object::MachOObjectFile::getChainedFixupsSegments(), llvm::object::MachOObjectFile::getDataInCodeTableEntry(), llvm::object::MachOObjectFile::getDyldChainedFixupTargets(), llvm::object::MachOObjectFile::getDyldExportsTrie(), llvm::object::MachOObjectFile::getDyldInfoBindOpcodes(), llvm::object::MachOObjectFile::getDyldInfoExportsTrie(), llvm::object::MachOObjectFile::getDyldInfoLazyBindOpcodes(), llvm::object::MachOObjectFile::getDyldInfoRebaseOpcodes(), llvm::object::MachOObjectFile::getDyldInfoWeakBindOpcodes(), getFirstLoadCommandInfo(), llvm::object::MachOObjectFile::getIndirectSymbolTableEntry(), llvm::object::MachOObjectFile::getRelocation(), llvm::object::MachOObjectFile::getRelocationSymbol(), llvm::object::MachOObjectFile::getSymbolByIndex(), llvm::object::MachOObjectFile::getSymbolIndex(), llvm::Error::isA(), llvm::Error::operator bool(), parseHeader(), llvm::object::MachOObjectFile::symbol_end(), and llvm::Error::~Error().

getScatteredRelocationAddress()

getScatteredRelocationLength()

getScatteredRelocationPCRel()

getSectionFlags()

getSectionPtr()

getStruct()

Definition at line 71 of file MachOObjectFile.cpp.

References llvm::sys::IsLittleEndianHost, P, llvm::report_fatal_error(), llvm::MachO::swapStruct(), and T.

Referenced by llvm::object::MachOObjectFile::getBuildToolVersion(), llvm::object::MachOObjectFile::getBuildVersionLoadCommand(), llvm::object::MachOObjectFile::getDataInCodeLoadCommand(), llvm::object::MachOObjectFile::getDataInCodeTableEntry(), llvm::object::MachOObjectFile::getDice(), llvm::object::MachOObjectFile::getDyldInfoLoadCommand(), llvm::object::MachOObjectFile::getDylibIDLoadCommand(), llvm::object::MachOObjectFile::getDylinkerCommand(), llvm::object::MachOObjectFile::getDysymtabLoadCommand(), llvm::object::MachOObjectFile::getEncryptionInfoCommand(), llvm::object::MachOObjectFile::getEncryptionInfoCommand64(), llvm::object::MachOObjectFile::getEntryPointCommand(), llvm::object::MachOObjectFile::getFilesetEntryLoadCommand(), llvm::object::MachOObjectFile::getIndirectSymbolTableEntry(), llvm::object::MachOObjectFile::getLinkeditDataLoadCommand(), llvm::object::MachOObjectFile::getLinkerOptionLoadCommand(), llvm::object::MachOObjectFile::getLinkOptHintsLoadCommand(), llvm::object::MachOObjectFile::getNoteLoadCommand(), llvm::object::MachOObjectFile::getRelocation(), llvm::object::MachOObjectFile::getRoutinesCommand(), llvm::object::MachOObjectFile::getRoutinesCommand64(), llvm::object::MachOObjectFile::getRpathCommand(), llvm::object::MachOObjectFile::getSection(), llvm::object::MachOObjectFile::getSection(), llvm::object::MachOObjectFile::getSection64(), llvm::object::MachOObjectFile::getSection64(), llvm::object::MachOObjectFile::getSectionContents(), llvm::object::MachOObjectFile::getSegment64LoadCommand(), llvm::object::MachOObjectFile::getSegmentLoadCommand(), llvm::object::MachOObjectFile::getSourceVersionCommand(), llvm::object::MachOObjectFile::getSubClientCommand(), llvm::object::MachOObjectFile::getSubFrameworkCommand(), llvm::object::MachOObjectFile::getSubLibraryCommand(), llvm::object::MachOObjectFile::getSubUmbrellaCommand(), llvm::object::MachOObjectFile::getSymbol64TableEntry(), llvm::object::MachOObjectFile::getSymbolTableEntry(), getSymbolTableEntryBase(), llvm::object::MachOObjectFile::getSymtabLoadCommand(), llvm::object::MachOObjectFile::getThreadCommand(), llvm::object::MachOObjectFile::getUuidCommand(), and llvm::object::MachOObjectFile::getVersionMinLoadCommand().

getStructOrErr()

Definition at line 84 of file MachOObjectFile.cpp.

References llvm::sys::IsLittleEndianHost, malformedError(), P, llvm::MachO::swapStruct(), and T.

Referenced by checkDyldCommand(), checkDyldInfoCommand(), checkDylibCommand(), checkDysymtabCommand(), checkLinkeditDataCommand(), checkLinkerOptCommand(), checkNoteCommand(), checkRpathCommand(), checkSymtabCommand(), checkThreadCommand(), checkTwoLevelHintsCommand(), llvm::object::MachOObjectFile::getChainedFixupsHeader(), llvm::object::MachOObjectFile::getChainedFixupsLoadCommand(), llvm::object::MachOObjectFile::getChainedFixupsSegments(), llvm::object::MachOObjectFile::getDyldExportsTrie(), llvm::object::MachOObjectFile::getDyldInfoBindOpcodes(), llvm::object::MachOObjectFile::getDyldInfoExportsTrie(), llvm::object::MachOObjectFile::getDyldInfoLazyBindOpcodes(), llvm::object::MachOObjectFile::getDyldInfoRebaseOpcodes(), llvm::object::MachOObjectFile::getDyldInfoWeakBindOpcodes(), llvm::object::MachOObjectFile::getFunctionStarts(), llvm::object::MachOObjectFile::getLibraryShortNameByIndex(), getLoadCommandInfo(), parseBuildVersionCommand(), parseHeader(), and parseSegmentLoadCommand().

getSymbolTableEntryBase()

isLoadCommandObsolete()

malformedError()

Definition at line 63 of file MachOObjectFile.cpp.

References llvm::make_error().

Referenced by checkDyldCommand(), checkDyldInfoCommand(), checkDylibCommand(), checkDylibIdCommand(), checkDysymtabCommand(), checkEncryptCommand(), checkLinkeditDataCommand(), checkLinkerOptCommand(), checkNoteCommand(), checkOverlappingElement(), checkRpathCommand(), checkSubCommand(), checkSymtabCommand(), checkThreadCommand(), checkTwoLevelHintsCommand(), checkVersCommand(), getFirstLoadCommandInfo(), getLoadCommandInfo(), getNextLoadCommandInfo(), getStructOrErr(), parseBuildVersionCommand(), parseHeader(), and parseSegmentLoadCommand().

parseBuildVersionCommand()

parseHeader()

parseSegmentLoadCommand()

template<typename Segment, typename Section>

Definition at line 286 of file MachOObjectFile.cpp.

References checkOverlappingElement(), getSectionPtr(), getStructOrErr(), malformedError(), llvm::MachO::MH_DSYM, llvm::MachO::MH_DYLIB_STUB, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::MachO::S_THREAD_LOCAL_ZEROFILL, llvm::MachO::S_ZEROFILL, and llvm::Error::success().

parseSegmentOrSectionName()