|
LLVM
4.0.0
|
#include "llvm/Object/MachO.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/StringSwitch.h"#include "llvm/ADT/Triple.h"#include "llvm/Support/DataExtractor.h"#include "llvm/Support/Debug.h"#include "llvm/Support/Format.h"#include "llvm/Support/Host.h"#include "llvm/Support/LEB128.h"#include "llvm/Support/MachO.h"#include "llvm/Support/MemoryBuffer.h"#include "llvm/Support/raw_ostream.h"#include <cctype>#include <cstring>#include <limits>#include <list>Go to the source code of this file.
Classes | |
| struct | MachOElement |
Functions | |
| static Error | malformedError (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) |
| template<class T > | |
| static void | advance (T &it, size_t Val) |
| 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 | 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 111 of file MachOObjectFile.cpp.
Referenced by llvm::IntervalMapOverlaps< MapA, MapB >::advanceTo(), llvm::DIExpressionCursor::consume(), DoPromotion(), llvm::SetVector< const llvm::Constant *, SmallVector< const llvm::Constant *, N >, SmallDenseSet< const llvm::Constant *, N > >::erase(), llvm::DOTGraphTraits< SelectionDAG * >::getEdgeTarget(), llvm::getGEPInductionOperand(), llvm::IntervalMapOverlaps< MapA, MapB >::IntervalMapOverlaps(), llvm::OnDiskIterableChainedHashTable< Info >::key_iterator::operator++(), llvm::OnDiskIterableChainedHashTable< Info >::data_iterator::operator++(), AllocaSlices::partition_iterator::operator++(), llvm::MachineRegisterInfo::defusechain_iterator< Uses, Defs, SkipDebug, ByOperand, ByInstr, ByBundle >::operator++(), llvm::MachineRegisterInfo::defusechain_instr_iterator< Uses, Defs, SkipDebug, ByOperand, ByInstr, ByBundle >::operator++(), llvm::IntervalMapOverlaps< MapA, MapB >::skipA(), and llvm::IntervalMapOverlaps< MapA, MapB >::skipB().
|
static |
Definition at line 743 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, llvm::MachO::load_command::cmdsize, llvm::MachO::dylinker_command::cmdsize, D, for(), i, malformedError(), llvm::MachO::dylinker_command::name, P, llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
|
static |
Definition at line 601 of file MachOObjectFile.cpp.
References llvm::MachO::dyld_info_command::bind_off, llvm::MachO::dyld_info_command::bind_size, llvm::object::MachOObjectFile::LoadCommandInfo::C, checkOverlappingElement(), llvm::MachO::load_command::cmdsize, llvm::MachO::dyld_info_command::cmdsize, llvm::MachO::dyld_info_command::export_off, llvm::MachO::dyld_info_command::export_size, llvm::MachO::dyld_info_command::lazy_bind_off, llvm::MachO::dyld_info_command::lazy_bind_size, malformedError(), llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, 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.
|
static |
Definition at line 697 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, llvm::MachO::load_command::cmdsize, llvm::MachO::dylib_command::cmdsize, D, llvm::MachO::dylib_command::dylib, for(), i, malformedError(), llvm::MachO::dylib::name, P, llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
Referenced by checkDylibIdCommand().
|
static |
Definition at line 726 of file MachOObjectFile.cpp.
References checkDylibCommand(), malformedError(), llvm::MachO::MH_DYLIB, llvm::MachO::MH_DYLIB_STUB, llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
|
static |
Definition at line 436 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, checkOverlappingElement(), llvm::MachO::load_command::cmdsize, llvm::MachO::dysymtab_command::cmdsize, llvm::MachO::dysymtab_command::extrefsymoff, llvm::MachO::dysymtab_command::extreloff, 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::object::MachOObjectFile::LoadCommandInfo::Ptr, llvm::Error::success(), and llvm::MachO::dysymtab_command::tocoff.
|
static |
Definition at line 816 of file MachOObjectFile.cpp.
References malformedError(), llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
|
static |
Definition at line 566 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, checkOverlappingElement(), llvm::MachO::load_command::cmdsize, llvm::MachO::linkedit_data_command::cmdsize, llvm::MachO::linkedit_data_command::dataoff, llvm::MachO::linkedit_data_command::datasize, malformedError(), llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
|
static |
Definition at line 840 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, llvm::MachO::load_command::cmdsize, llvm::MachO::linker_option_command::cmdsize, llvm::MachO::linker_option_command::count, llvm::StringRef::find(), i, L, malformedError(), fuzzer::min(), llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
|
static |
Definition at line 226 of file MachOObjectFile.cpp.
References E, malformedError(), N, Offset, and llvm::Error::success().
Referenced by checkDyldInfoCommand(), checkDysymtabCommand(), checkLinkeditDataCommand(), checkSymtabCommand(), checkTwoLevelHintsCommand(), and parseSegmentLoadCommand().
|
static |
Definition at line 787 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, llvm::MachO::load_command::cmdsize, llvm::MachO::rpath_command::cmdsize, for(), i, malformedError(), P, llvm::MachO::rpath_command::path, llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
|
static |
Definition at line 873 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, llvm::MachO::load_command::cmdsize, for(), i, malformedError(), P, llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
|
static |
Definition at line 380 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, checkOverlappingElement(), llvm::MachO::load_command::cmdsize, llvm::MachO::symtab_command::cmdsize, malformedError(), llvm::MachO::symtab_command::nsyms, llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, llvm::MachO::symtab_command::stroff, llvm::MachO::symtab_command::strsize, llvm::Error::success(), and llvm::MachO::symtab_command::symoff.
|
static |
Definition at line 900 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::object::MachOObjectFile::LoadCommandInfo::C, llvm::MachO::load_command::cmdsize, llvm::MachO::thread_command::cmdsize, llvm::count(), llvm::MachO::CPU_TYPE_ARM, llvm::MachO::CPU_TYPE_ARM64, llvm::MachO::CPU_TYPE_POWERPC, llvm::MachO::CPU_TYPE_X86_64, llvm::sys::path::end(), getCPUType(), llvm::sys::IsLittleEndianHost, malformedError(), llvm::MachO::PPC_THREAD_STATE, llvm::MachO::PPC_THREAD_STATE_COUNT, llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, llvm::Error::success(), llvm::sys::swapByteOrder(), llvm::MachO::x86_THREAD_STATE64, and llvm::MachO::x86_THREAD_STATE64_COUNT.
|
static |
Definition at line 1020 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, checkOverlappingElement(), llvm::MachO::load_command::cmdsize, malformedError(), llvm::MachO::twolevel_hints_command::nhints, llvm::MachO::twolevel_hints_command::offset, llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
|
static |
Definition at line 772 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, llvm::MachO::load_command::cmdsize, malformedError(), llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::Error::success().
Definition at line 116 of file MachOObjectFile.cpp.
Referenced by checkThreadCommand(), llvm::object::MachOObjectFile::getFileFormatName(), and llvm::object::MachOObjectFile::isRelocationScattered().
|
static |
Definition at line 184 of file MachOObjectFile.cpp.
References getLoadCommandInfo(), getPtr(), and malformedError().
|
static |
Definition at line 172 of file MachOObjectFile.cpp.
References malformedError(), and Ptr.
Referenced by getFirstLoadCommandInfo(), and getNextLoadCommandInfo().
|
static |
Definition at line 194 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, llvm::MachO::load_command::cmdsize, getLoadCommandInfo(), malformedError(), and llvm::object::MachOObjectFile::LoadCommandInfo::Ptr.
|
static |
Definition at line 121 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 142 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationLength().
|
static |
Definition at line 130 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationPCRel().
|
static |
Definition at line 154 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationType().
Definition at line 91 of file MachOObjectFile.cpp.
Referenced by llvm::object::MachOObjectFile::begin_dices(), 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(), parseHeader(), llvm::object::MachOObjectFile::symbol_end(), and llvm::Error::~Error().
|
static |
Definition at line 126 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationAddress().
|
static |
Definition at line 150 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationLength().
|
static |
Definition at line 138 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationPCRel().
|
static |
Definition at line 161 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(), and llvm::object::MachOObjectFile::isSectionText().
|
static |
Definition at line 77 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, and llvm::COFF::SectionSize.
Referenced by parseSegmentLoadCommand().
Definition at line 51 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, llvm::report_fatal_error(), llvm::MachO::swapStruct(), and T.
|
static |
Definition at line 64 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, malformedError(), llvm::MachO::swapStruct(), and T.
|
static |
Definition at line 96 of file MachOObjectFile.cpp.
References llvm::object::DataRefImpl::p, 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 1057 of file MachOObjectFile.cpp.
Definition at line 43 of file MachOObjectFile.cpp.
References llvm::object::parse_failed, and llvm::Twine::str().
Referenced by checkDyldCommand(), checkDyldInfoCommand(), checkDylibCommand(), checkDylibIdCommand(), checkDysymtabCommand(), checkEncryptCommand(), checkLinkeditDataCommand(), checkLinkerOptCommand(), checkOverlappingElement(), checkRpathCommand(), checkSubCommand(), llvm::object::MachOObjectFile::checkSymbolTable(), checkSymtabCommand(), checkThreadCommand(), checkTwoLevelHintsCommand(), checkVersCommand(), getFirstLoadCommandInfo(), getLoadCommandInfo(), getNextLoadCommandInfo(), getStructOrErr(), llvm::object::MachOObjectFile::getSymbolName(), llvm::object::MachOObjectFile::getSymbolSection(), parseHeader(), and parseSegmentLoadCommand().
|
static |
Definition at line 206 of file MachOObjectFile.cpp.
References getPtr(), and malformedError().
|
static |
Definition at line 259 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::LoadCommandInfo::C, checkOverlappingElement(), llvm::MachO::load_command::cmdsize, llvm::StringRef::equals(), getSectionPtr(), malformedError(), llvm::MachO::MH_DSYM, llvm::MachO::MH_DYLIB_STUB, llvm::object::MachOObjectFile::LoadCommandInfo::Ptr, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::MachO::S_THREAD_LOCAL_ZEROFILL, llvm::MachO::S_ZEROFILL, llvm::ARMBuildAttrs::Section, llvm::COFF::SectionSize, and llvm::Error::success().
Definition at line 101 of file MachOObjectFile.cpp.
References P.
Referenced by llvm::object::MachOObjectFile::getSectionFinalSegmentName(), and llvm::object::MachOObjectFile::getSectionName().
1.8.6