LLVM
17.0.0git
|
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/bit.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/BinaryFormat/Swift.h"
#include "llvm/Object/Error.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/SymbolicFile.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <limits>
#include <list>
#include <memory>
#include <system_error>
#include "llvm/BinaryFormat/Swift.def"
Go to the source code of this file.
Classes | |
struct | MachOElement |
Macros | |
#define | HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) .Case(MACHO, llvm::binaryformat::Swift5ReflectionSectionKind::KIND) |
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) |
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) |
#define HANDLE_SWIFT_SECTION | ( | KIND, | |
MACHO, | |||
ELF, | |||
COFF | |||
) | .Case(MACHO, llvm::binaryformat::Swift5ReflectionSectionKind::KIND) |
|
static |
Definition at line 781 of file MachOObjectFile.cpp.
References D, for, i, llvm::SPII::Load, malformedError(), P, and llvm::Error::success().
|
static |
Definition at line 633 of file MachOObjectFile.cpp.
References llvm::MachO::dyld_info_command::cmdsize, llvm::SPII::Load, malformedError(), llvm::MachO::dyld_info_command::rebase_off, and llvm::MachO::dyld_info_command::rebase_size.
|
static |
Definition at line 732 of file MachOObjectFile.cpp.
References D, for, i, llvm::SPII::Load, malformedError(), P, and llvm::Error::success().
|
static |
Definition at line 764 of file MachOObjectFile.cpp.
|
static |
Definition at line 462 of file MachOObjectFile.cpp.
References llvm::MachO::dysymtab_command::cmdsize, llvm::SPII::Load, malformedError(), llvm::MachO::dysymtab_command::ntoc, and llvm::MachO::dysymtab_command::tocoff.
|
static |
Definition at line 912 of file MachOObjectFile.cpp.
References llvm::SPII::Load, malformedError(), and llvm::Error::success().
|
static |
Definition at line 595 of file MachOObjectFile.cpp.
References llvm::MachO::linkedit_data_command::cmdsize, llvm::MachO::linkedit_data_command::dataoff, llvm::MachO::linkedit_data_command::datasize, llvm::SPII::Load, and malformedError().
|
static |
Definition at line 936 of file MachOObjectFile.cpp.
References llvm::MachO::linker_option_command::cmdsize, llvm::MachO::linker_option_command::count, llvm::StringRef::find(), i, llvm::SPII::Load, malformedError(), llvm::min(), and llvm::Error::success().
|
static |
Definition at line 828 of file MachOObjectFile.cpp.
References llvm::SPII::Load, malformedError(), llvm::MachO::note_command::offset, and llvm::MachO::note_command::size.
|
static |
Definition at line 247 of file MachOObjectFile.cpp.
References E, it, malformedError(), N, and llvm::Error::success().
|
static |
Definition at line 880 of file MachOObjectFile.cpp.
References for, i, llvm::SPII::Load, malformedError(), P, llvm::RISCVFenceField::R, and llvm::Error::success().
|
static |
Definition at line 976 of file MachOObjectFile.cpp.
References for, i, llvm::SPII::Load, malformedError(), P, and llvm::Error::success().
|
static |
Definition at line 404 of file MachOObjectFile.cpp.
References llvm::MachO::symtab_command::cmdsize, llvm::SPII::Load, malformedError(), llvm::MachO::symtab_command::nsyms, and llvm::MachO::symtab_command::symoff.
|
static |
Definition at line 1003 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, llvm::sys::path::end(), getCPUType(), llvm::sys::IsLittleEndianHost, llvm::SPII::Load, malformedError(), memcpy(), llvm::MachO::PPC_THREAD_STATE, llvm::MachO::PPC_THREAD_STATE_COUNT, llvm::Error::success(), llvm::sys::swapByteOrder(), 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.
|
static |
Definition at line 1194 of file MachOObjectFile.cpp.
References llvm::SPII::Load, malformedError(), llvm::MachO::twolevel_hints_command::nhints, and llvm::MachO::twolevel_hints_command::offset.
|
static |
Definition at line 813 of file MachOObjectFile.cpp.
References llvm::SPII::Load, malformedError(), and llvm::Error::success().
|
static |
Definition at line 5133 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, memcpy(), N, llvm::RISCVFenceField::O, Ptr, and llvm::sys::swapByteOrder().
|
static |
Definition at line 134 of file MachOObjectFile.cpp.
References llvm::RISCVFenceField::O.
|
static |
Definition at line 130 of file MachOObjectFile.cpp.
References llvm::RISCVFenceField::O.
Referenced by checkThreadCommand(), llvm::object::MachOObjectFile::getFileFormatName(), and llvm::object::MachOObjectFile::isRelocationScattered().
Definition at line 5124 of file MachOObjectFile.cpp.
References llvm::MachO::BIND_SPECIAL_DYLIB_FLAT_LOOKUP, llvm::MachO::BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE, and llvm::MachO::BIND_SPECIAL_DYLIB_WEAK_LOOKUP.
|
static |
Definition at line 205 of file MachOObjectFile.cpp.
References getLoadCommandInfo(), getPtr(), llvm::BTF::HeaderSize, and malformedError().
|
static |
Definition at line 190 of file MachOObjectFile.cpp.
References malformedError(), and Ptr.
Referenced by getFirstLoadCommandInfo(), and getNextLoadCommandInfo().
|
static |
Definition at line 215 of file MachOObjectFile.cpp.
References getLoadCommandInfo(), llvm::BTF::HeaderSize, and malformedError().
|
static |
Definition at line 139 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationAddress(), and llvm::object::MachOObjectFile::isRelocationScattered().
|
static |
Definition at line 160 of file MachOObjectFile.cpp.
References llvm::RISCVFenceField::O, and llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationLength().
|
static |
Definition at line 148 of file MachOObjectFile.cpp.
References llvm::RISCVFenceField::O, and llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationPCRel().
|
static |
Definition at line 172 of file MachOObjectFile.cpp.
References llvm::RISCVFenceField::O, and llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationType().
Definition at line 111 of file MachOObjectFile.cpp.
References assert(), and llvm::RISCVFenceField::O.
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(), llvm::object::MachOObjectFile::symbol_end(), and llvm::Error::~Error().
|
static |
Definition at line 144 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationAddress().
|
static |
Definition at line 168 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationLength().
|
static |
Definition at line 156 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationPCRel().
Definition at line 179 of file MachOObjectFile.cpp.
References llvm::MachO::section::flags, llvm::MachO::section_64::flags, and llvm::RISCVFenceField::O.
Referenced by llvm::object::MachOObjectFile::getSectionType(), llvm::object::XCOFFObjectFile::isDebugSection(), llvm::object::MachOObjectFile::isSectionBSS(), llvm::object::XCOFFObjectFile::isSectionBSS(), llvm::object::MachOObjectFile::isSectionData(), llvm::object::XCOFFObjectFile::isSectionData(), llvm::object::MachOObjectFile::isSectionText(), llvm::object::XCOFFObjectFile::isSectionText(), and llvm::object::MachOObjectFile::isSectionVirtual().
|
static |
Definition at line 97 of file MachOObjectFile.cpp.
References llvm::RISCVFenceField::O, and llvm::COFF::SectionSize.
Referenced by llvm::object::MachOObjectFile::getSection(), llvm::object::MachOObjectFile::getSection64(), and parseSegmentLoadCommand().
Definition at line 71 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, memcpy(), llvm::RISCVFenceField::O, P, llvm::report_fatal_error(), and llvm::MachO::swapStruct().
|
static |
Definition at line 84 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, malformedError(), memcpy(), llvm::RISCVFenceField::O, P, and llvm::MachO::swapStruct().
|
static |
Definition at line 117 of file MachOObjectFile.cpp.
References llvm::RISCVFenceField::O, and P.
|
static |
Definition at line 1233 of file MachOObjectFile.cpp.
Definition at line 63 of file MachOObjectFile.cpp.
References llvm::AMDGPU::SendMsg::Msg, and llvm::object::parse_failed.
Referenced by checkDyldCommand(), checkDyldInfoCommand(), checkDylibCommand(), checkDysymtabCommand(), checkEncryptCommand(), checkLinkeditDataCommand(), checkLinkerOptCommand(), checkNoteCommand(), checkOverlappingElement(), checkRpathCommand(), checkSubCommand(), llvm::object::MachOObjectFile::checkSymbolTable(), checkSymtabCommand(), checkThreadCommand(), checkTwoLevelHintsCommand(), checkVersCommand(), llvm::object::MachOObjectFile::getChainedFixupsHeader(), llvm::object::MachOObjectFile::getChainedFixupsSegments(), llvm::object::MachOObjectFile::getDyldChainedFixupTargets(), getFirstLoadCommandInfo(), getLoadCommandInfo(), getNextLoadCommandInfo(), llvm::object::MachOObjectFile::getSection(), getStructOrErr(), llvm::object::ExportEntry::moveNext(), llvm::object::MachORebaseEntry::moveNext(), llvm::object::MachOBindEntry::moveNext(), llvm::object::MachOChainedFixupEntry::moveNext(), parseBuildVersionCommand(), and parseSegmentLoadCommand().
|
static |
Definition at line 857 of file MachOObjectFile.cpp.
References llvm::SPII::Load, malformedError(), and llvm::MachO::build_version_command::ntools.
|
static |
Definition at line 227 of file MachOObjectFile.cpp.
|
static |
Definition at line 280 of file MachOObjectFile.cpp.
References getSectionPtr(), llvm::SPII::Load, malformedError(), llvm::max(), llvm::MachO::MH_DSYM, llvm::MachO::MH_DYLIB_STUB, S, s, llvm::MachO::S_THREAD_LOCAL_ZEROFILL, llvm::MachO::S_ZEROFILL, and llvm::COFF::SectionSize.
Definition at line 122 of file MachOObjectFile.cpp.
References P.
Referenced by llvm::object::MachOObjectFile::getSectionFinalSegmentName(), and llvm::object::MachOObjectFile::getSectionName().