LLVM 22.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/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/LEB128.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.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) |
#define HANDLE_SWIFT_SECTION | ( | KIND, | |
MACHO, | |||
ELF, | |||
COFF | |||
) | .Case(MACHO, llvm::binaryformat::Swift5ReflectionSectionKind::KIND) |
|
static |
Definition at line 787 of file MachOObjectFile.cpp.
References D, for(), malformedError(), P, and llvm::Error::success().
|
static |
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, llvm::object::Binary::getData(), 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::StringRef::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 738 of file MachOObjectFile.cpp.
References D, for(), malformedError(), P, and llvm::Error::success().
Referenced by checkDylibIdCommand().
|
static |
Definition at line 770 of file MachOObjectFile.cpp.
References checkDylibCommand(), llvm::MachO::mach_header::filetype, llvm::object::MachOObjectFile::getHeader(), malformedError(), llvm::MachO::MH_DYLIB, llvm::MachO::MH_DYLIB_STUB, and llvm::Error::success().
|
static |
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, llvm::object::Binary::getData(), llvm::MachO::dysymtab_command::indirectsymoff, llvm::object::MachOObjectFile::is64Bit(), 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::StringRef::size(), llvm::Error::success(), and llvm::MachO::dysymtab_command::tocoff.
|
static |
Definition at line 918 of file MachOObjectFile.cpp.
References llvm::object::Binary::getData(), malformedError(), llvm::StringRef::size(), and llvm::Error::success().
|
static |
Definition at line 601 of file MachOObjectFile.cpp.
References checkOverlappingElement(), llvm::MachO::linkedit_data_command::cmdsize, llvm::MachO::linkedit_data_command::dataoff, llvm::MachO::linkedit_data_command::datasize, llvm::object::Binary::getData(), malformedError(), llvm::StringRef::size(), and llvm::Error::success().
|
static |
Definition at line 942 of file MachOObjectFile.cpp.
References llvm::StringRef::find(), malformedError(), and llvm::Error::success().
|
static |
Definition at line 834 of file MachOObjectFile.cpp.
References checkOverlappingElement(), llvm::object::Binary::getData(), malformedError(), llvm::MachO::note_command::offset, llvm::StringRef::size(), llvm::MachO::note_command::size, and llvm::Error::success().
|
static |
Definition at line 253 of file MachOObjectFile.cpp.
References malformedError(), N, Name, llvm::Offset, Size, and llvm::Error::success().
Referenced by checkDyldInfoCommand(), checkDysymtabCommand(), checkLinkeditDataCommand(), checkNoteCommand(), checkSymtabCommand(), checkTwoLevelHintsCommand(), and parseSegmentLoadCommand().
|
static |
Definition at line 886 of file MachOObjectFile.cpp.
References for(), malformedError(), P, and llvm::Error::success().
|
static |
Definition at line 982 of file MachOObjectFile.cpp.
References for(), malformedError(), P, and llvm::Error::success().
|
static |
Definition at line 410 of file MachOObjectFile.cpp.
References checkOverlappingElement(), llvm::MachO::symtab_command::cmdsize, llvm::object::Binary::getData(), llvm::object::MachOObjectFile::is64Bit(), malformedError(), llvm::MachO::symtab_command::nsyms, llvm::StringRef::size(), llvm::MachO::symtab_command::stroff, llvm::MachO::symtab_command::strsize, llvm::Error::success(), and llvm::MachO::symtab_command::symoff.
|
static |
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(), llvm::object::Binary::isLittleEndian(), llvm::sys::IsLittleEndianHost, malformedError(), 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 1200 of file MachOObjectFile.cpp.
References checkOverlappingElement(), llvm::object::Binary::getData(), malformedError(), llvm::MachO::twolevel_hints_command::nhints, llvm::MachO::twolevel_hints_command::offset, llvm::StringRef::size(), and llvm::Error::success().
|
static |
Definition at line 819 of file MachOObjectFile.cpp.
References malformedError(), and llvm::Error::success().
|
static |
Definition at line 5148 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, N, Ptr, and llvm::sys::swapByteOrder().
|
static |
Definition at line 136 of file MachOObjectFile.cpp.
Referenced by llvm::object::MachOObjectFile::getArch(), llvm::object::MachOUniversalBinary::ObjectForArch::getArchFlagName(), and llvm::object::MachOUniversalBinary::ObjectForArch::getTriple().
|
static |
Definition at line 132 of file MachOObjectFile.cpp.
Referenced by checkThreadCommand(), llvm::object::MachOObjectFile::getArch(), llvm::object::MachOUniversalBinary::ObjectForArch::getArchFlagName(), llvm::object::MachOObjectFile::getFileFormatName(), llvm::object::MachOUniversalBinary::ObjectForArch::getTriple(), and llvm::object::MachOObjectFile::isRelocationScattered().
Definition at line 5139 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 208 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::getHeader(), getLoadCommandInfo(), llvm::object::MachOObjectFile::getMachOFilesetEntryOffset(), getPtr(), llvm::object::MachOObjectFile::is64Bit(), malformedError(), and llvm::MachO::mach_header::sizeofcmds.
|
static |
Definition at line 192 of file MachOObjectFile.cpp.
References assert(), llvm::StringRef::end(), llvm::object::Binary::getData(), malformedError(), and Ptr.
Referenced by getFirstLoadCommandInfo(), and getNextLoadCommandInfo().
|
static |
Definition at line 219 of file MachOObjectFile.cpp.
References llvm::StringRef::data(), llvm::object::Binary::getData(), llvm::object::MachOObjectFile::getHeader(), getLoadCommandInfo(), llvm::object::MachOObjectFile::getMachOFilesetEntryOffset(), llvm::object::MachOObjectFile::is64Bit(), malformedError(), and llvm::MachO::mach_header::sizeofcmds.
|
static |
Definition at line 141 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 162 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationLength().
|
static |
Definition at line 150 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationPCRel().
|
static |
Definition at line 174 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word1.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationType().
|
static |
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().
|
static |
Definition at line 146 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationAddress().
|
static |
Definition at line 170 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationLength().
|
static |
Definition at line 158 of file MachOObjectFile.cpp.
References llvm::MachO::any_relocation_info::r_word0.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationPCRel().
|
static |
Definition at line 181 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 97 of file MachOObjectFile.cpp.
Referenced by llvm::object::MachOObjectFile::getSection(), llvm::object::MachOObjectFile::getSection64(), and parseSegmentLoadCommand().
Definition at line 71 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, P, llvm::report_fatal_error(), and llvm::MachO::swapStruct().
|
static |
Definition at line 84 of file MachOObjectFile.cpp.
References llvm::sys::IsLittleEndianHost, malformedError(), P, and llvm::MachO::swapStruct().
|
static |
Definition at line 119 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 1239 of file MachOObjectFile.cpp.
References llvm::MachO::linker_option_command::cmd.
Definition at line 63 of file MachOObjectFile.cpp.
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().
|
static |
Definition at line 863 of file MachOObjectFile.cpp.
References malformedError(), llvm::MachO::build_version_command::ntools, llvm::SmallVectorImpl< T >::resize(), and llvm::Error::success().
|
static |
Definition at line 232 of file MachOObjectFile.cpp.
References llvm::object::Binary::getData(), llvm::object::MachOObjectFile::getMachOFilesetEntryOffset(), getPtr(), malformedError(), and llvm::StringRef::size().
|
static |
Definition at line 286 of file MachOObjectFile.cpp.
References checkOverlappingElement(), llvm::MachO::mach_header::filetype, llvm::object::Binary::getData(), llvm::object::MachOObjectFile::getHeader(), getSectionPtr(), 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, llvm::StringRef::size(), and llvm::Error::success().
Definition at line 124 of file MachOObjectFile.cpp.
References P.
Referenced by llvm::object::MachOObjectFile::getSectionFinalSegmentName(), and llvm::object::MachOObjectFile::getSectionName().