LLVM
8.0.1
|
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/None.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/BinaryFormat/MachO.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/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MemoryBuffer.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 <string>
#include <system_error>
Go to the source code of this file.
Classes | |
struct | MachOElement |
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 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) |
|
static |
Definition at line 758 of file MachOObjectFile.cpp.
References llvm::MachO::dylinker_command::cmdsize, D, for(), malformedError(), llvm::MachO::dylinker_command::name, P, and llvm::Error::success().
|
static |
Definition at line 616 of file MachOObjectFile.cpp.
References llvm::MachO::dyld_info_command::cmdsize, malformedError(), llvm::MachO::dyld_info_command::rebase_off, and llvm::MachO::dyld_info_command::rebase_size.
|
static |
Definition at line 712 of file MachOObjectFile.cpp.
References llvm::MachO::dylib_command::cmdsize, D, llvm::MachO::dylib_command::dylib, for(), malformedError(), llvm::MachO::dylib::name, P, and llvm::Error::success().
|
static |
Definition at line 741 of file MachOObjectFile.cpp.
|
static |
Definition at line 451 of file MachOObjectFile.cpp.
References llvm::MachO::dysymtab_command::cmdsize, malformedError(), llvm::MachO::dysymtab_command::ntoc, and llvm::MachO::dysymtab_command::tocoff.
|
static |
Definition at line 877 of file MachOObjectFile.cpp.
References malformedError(), and llvm::Error::success().
|
static |
Definition at line 581 of file MachOObjectFile.cpp.
References llvm::MachO::linkedit_data_command::cmdsize, llvm::MachO::linkedit_data_command::dataoff, llvm::MachO::linkedit_data_command::datasize, and malformedError().
|
static |
Definition at line 901 of file MachOObjectFile.cpp.
References llvm::MachO::linker_option_command::cmdsize, llvm::MachO::linker_option_command::count, llvm::StringRef::find(), malformedError(), and llvm::Error::success().
|
static |
Definition at line 802 of file MachOObjectFile.cpp.
References malformedError(), llvm::MachO::note_command::offset, and llvm::MachO::note_command::size.
|
static |
Definition at line 241 of file MachOObjectFile.cpp.
References E, malformedError(), N, Size, and llvm::Error::success().
|
static |
Definition at line 848 of file MachOObjectFile.cpp.
References llvm::MachO::rpath_command::cmdsize, for(), malformedError(), P, llvm::MachO::rpath_command::path, llvm::RISCVFenceField::R, and llvm::Error::success().
|
static |
Definition at line 934 of file MachOObjectFile.cpp.
References for(), malformedError(), P, and llvm::Error::success().
|
static |
Definition at line 395 of file MachOObjectFile.cpp.
References llvm::MachO::symtab_command::cmdsize, malformedError(), llvm::MachO::symtab_command::nsyms, and llvm::MachO::symtab_command::symoff.
|
static |
Definition at line 961 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::MachO::thread_command::cmdsize, llvm::count(), llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_TYPE_I386, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_TYPE_X86_64, llvm::sys::path::end(), getCPUType(), llvm::sys::IsLittleEndianHost, malformedError(), llvm::Intrinsic::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 1148 of file MachOObjectFile.cpp.
References malformedError(), llvm::MachO::twolevel_hints_command::nhints, and llvm::MachO::twolevel_hints_command::offset.
|
static |
Definition at line 787 of file MachOObjectFile.cpp.
References malformedError(), and llvm::Error::success().
Definition at line 128 of file MachOObjectFile.cpp.
Referenced by checkThreadCommand(), llvm::object::MachOObjectFile::getFileFormatName(), llvm::object::MachOObjectFile::isRelocationScattered(), and llvm::object::MachOObjectFile::isValidArch().
|
static |
Definition at line 199 of file MachOObjectFile.cpp.
References getLoadCommandInfo(), getPtr(), llvm::BTF::HeaderSize, and malformedError().
|
static |
Definition at line 184 of file MachOObjectFile.cpp.
References malformedError().
Referenced by getFirstLoadCommandInfo(), and getNextLoadCommandInfo().
|
static |
Definition at line 209 of file MachOObjectFile.cpp.
References getLoadCommandInfo(), llvm::BTF::HeaderSize, and malformedError().
|
static |
Definition at line 133 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 154 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationLength().
|
static |
Definition at line 142 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationPCRel().
|
static |
Definition at line 166 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationType().
Definition at line 109 of file MachOObjectFile.cpp.
References assert().
Referenced by llvm::object::MachOObjectFile::begin_dices(), llvm::Error::dynamicClassID(), llvm::object::MachOObjectFile::end_dices(), llvm::object::MachOObjectFile::getDataInCodeTableEntry(), 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 138 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationAddress().
|
static |
Definition at line 162 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationLength().
|
static |
Definition at line 150 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationPCRel().
Definition at line 173 of file MachOObjectFile.cpp.
References llvm::MachO::section::flags, and llvm::MachO::section_64::flags.
Referenced by llvm::object::MachOObjectFile::getSectionType(), llvm::object::MachOObjectFile::isSectionBSS(), llvm::object::MachOObjectFile::isSectionData(), llvm::object::MachOObjectFile::isSectionText(), and llvm::object::MachOObjectFile::isSectionVirtual().
|
static |
Definition at line 95 of file MachOObjectFile.cpp.
References llvm::COFF::SectionSize.
Referenced by llvm::object::MachOObjectFile::getSection(), llvm::object::MachOObjectFile::getSection64(), and parseSegmentLoadCommand().
Definition at line 69 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, llvm::Intrinsic::memcpy, llvm::report_fatal_error(), llvm::MachO::swapStruct(), and T.
|
static |
Definition at line 82 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, malformedError(), llvm::Intrinsic::memcpy, llvm::MachO::swapStruct(), and T.
|
static |
Definition at line 115 of file MachOObjectFile.cpp.
References llvm::RISCVFenceField::O, and P.
Referenced by llvm::object::MachOObjectFile::getIndirectName(), llvm::object::MachOObjectFile::getSymbolAlignment(), llvm::object::MachOObjectFile::getSymbolFlags(), llvm::object::MachOObjectFile::getSymbolName(), llvm::object::MachOObjectFile::getSymbolSection(), llvm::object::MachOObjectFile::getSymbolSectionID(), and llvm::object::MachOObjectFile::getSymbolType().
Definition at line 1185 of file MachOObjectFile.cpp.
Definition at line 61 of file MachOObjectFile.cpp.
References 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(), getFirstLoadCommandInfo(), getLoadCommandInfo(), getNextLoadCommandInfo(), llvm::object::MachOObjectFile::getSection(), getStructOrErr(), llvm::object::MachOObjectFile::getSymbolSection(), llvm::object::ExportEntry::moveNext(), llvm::object::MachORebaseEntry::moveNext(), llvm::object::MachOBindEntry::moveNext(), parseBuildVersionCommand(), and parseSegmentLoadCommand().
|
static |
Definition at line 828 of file MachOObjectFile.cpp.
References malformedError(), and llvm::MachO::build_version_command::ntools.
|
static |
Definition at line 221 of file MachOObjectFile.cpp.
|
static |
Definition at line 274 of file MachOObjectFile.cpp.
References getSectionPtr(), malformedError(), llvm::max(), 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, llvm::ARMBuildAttrs::Section, and llvm::COFF::SectionSize.
Definition at line 120 of file MachOObjectFile.cpp.
References P.
Referenced by llvm::object::MachOObjectFile::getSectionFinalSegmentName(), and llvm::object::MachOObjectFile::getSectionName().