15 #ifndef LLVM_OBJECT_MACHO_H
16 #define LLVM_OBJECT_MACHO_H
44 std::error_code
getLength(uint16_t &Result)
const;
45 std::error_code
getKind(uint16_t &Result)
const;
62 uint64_t
flags()
const;
64 uint64_t
other()
const;
76 uint64_t readULEB128(
const uint8_t *&p);
77 void pushDownUntilBottom();
78 void pushNode(uint64_t
Offset);
82 NodeState(
const uint8_t *
Ptr);
84 const uint8_t *Current;
88 const char *ImportName;
90 unsigned NextChildIndex;
91 unsigned ParentStringLength;
124 uint64_t readULEB128();
128 uint64_t SegmentOffset;
130 uint64_t RemainingLoopCount;
131 uint64_t AdvanceAmount;
166 uint64_t readULEB128();
167 int64_t readSLEB128();
171 uint64_t SegmentOffset;
177 uint64_t RemainingLoopCount;
178 uint64_t AdvanceAmount;
267 unsigned getArch()
const override;
393 unsigned Index)
const;
395 unsigned Index)
const;
416 const char **McpuDefault =
nullptr,
417 const char **ArchFlag =
nullptr);
432 return (VersionOrSDK >> 16) & 0xffff;
438 return (VersionOrSDK >> 8) & 0xff;
444 return VersionOrSDK & 0xff;
453 uint64_t getSymbolValueImpl(
DataRefImpl Symb)
const override;
460 SectionList Sections;
462 LibraryList Libraries;
465 mutable LibraryShortName LibrariesShortNames;
466 const char *SymtabLoadCmd;
467 const char *DysymtabLoadCmd;
468 const char *DataInCodeLoadCmd;
469 const char *LinkOptHintsLoadCmd;
470 const char *DyldInfoLoadCmd;
471 const char *UuidLoadCmd;
472 bool HasPageZeroSegment;
477 : DicePimpl(DiceP) , OwningObject(Owner) {}
480 return DicePimpl == Other.DicePimpl;
484 return DicePimpl < Other.DicePimpl;
490 DicePimpl.
p =
reinterpret_cast<uintptr_t
>(P + 1);
502 return std::error_code();
510 return std::error_code();
518 return std::error_code();
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const
iterator_range< export_iterator > exports() const
For use iterating over all exported symbols.
static uint32_t getVersionMinUpdate(MachO::version_min_command &C, bool SDK)
load_command_iterator end_load_commands() const
std::error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const
StringRef getStringTableData() const
std::error_code getKind(uint16_t &Result) const
StringRef getFileFormatName() const override
MachO::linkedit_data_command getLinkOptHintsLoadCommand() const
uint64_t getRelocationOffset(DataRefImpl Rel) const override
bool isSectionVirtual(DataRefImpl Sec) const override
ArrayRef< char > getSectionRawFinalSegmentName(DataRefImpl Sec) const
ArrayRef< char > getSectionRawName(DataRefImpl Sec) const
MachO::data_in_code_entry getDataInCodeTableEntry(uint32_t DataOffset, unsigned Index) const
std::error_code getSectionName(DataRefImpl Sec, StringRef &Res) const override
void moveRelocationNext(DataRefImpl &Rel) const override
ExportEntry encapsulates the current-state-of-the-walk used when doing a non-recursive walk of the tr...
StringRef typeName() const
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const
static Triple getHostArch()
uint32_t getScatteredRelocationType(const MachO::any_relocation_info &RE) const
uint8_t getRelocationLength(DataRefImpl Rel) const
This class is the base class for all object file types.
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
uint64_t getRelocationType(DataRefImpl Rel) const override
StringRef otherName() const
MachORebaseEntry encapsulates the current state in the decompression of rebasing opcodes.
uint64_t getSectionAlignment(DataRefImpl Sec) const override
ArrayRef< uint8_t > getDyldInfoLazyBindOpcodes() const
load_command_iterator begin_load_commands() const
uint32_t getIndirectSymbolTableEntry(const MachO::dysymtab_command &DLC, unsigned Index) const
bool operator==(const MachORebaseEntry &) const
iterator_range< rebase_iterator > rebaseTable() const
For use iterating over all rebase table entries.
bool isSectionBitcode(DataRefImpl Sec) const override
uint64_t getSectionAddress(DataRefImpl Sec) const override
content_iterator< ExportEntry > export_iterator
basic_symbol_iterator symbol_begin() const override
bool operator==(const ExportEntry &) const
DataRefImpl getRawDataRefImpl() const
bool isSectionText(DataRefImpl Sec) const override
struct fuzzer::@269 Flags
std::error_code getOffset(uint32_t &Result) const
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
MachO::segment_command_64 getSegment64LoadCommand(const LoadCommandInfo &L) const
MachO::uuid_command getUuidCommand(const LoadCommandInfo &L) const
uint64_t segmentOffset() const
uint64_t getSymbolIndex(DataRefImpl Symb) const
Tagged union holding either a T or a Error.
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
void ReadULEB128s(uint64_t Index, SmallVectorImpl< uint64_t > &Out) const
MachOBindEntry encapsulates the current state in the decompression of binding opcodes.
MachO::linker_option_command getLinkerOptionLoadCommand(const LoadCommandInfo &L) const
uint32_t nodeOffset() const
MachO::encryption_info_command_64 getEncryptionInfoCommand64(const LoadCommandInfo &L) const
dice_iterator end_dices() const
uint32_t getScatteredRelocationValue(const MachO::any_relocation_info &RE) const
MachO::dylib_command getDylibIDLoadCommand(const LoadCommandInfo &L) const
unsigned getArch() const override
MachO::routines_command getRoutinesCommand(const LoadCommandInfo &L) const
ExportEntry(ArrayRef< uint8_t > Trie)
SubtargetFeatures getFeatures() const override
MachO::dylinker_command getDylinkerCommand(const LoadCommandInfo &L) const
const MachO::mach_header & getHeader() const
bool getScatteredRelocationScattered(const MachO::any_relocation_info &RE) const
basic_symbol_iterator symbol_end() const override
MachO::section_64 getSection64(DataRefImpl DRI) const
MachO::entry_point_command getEntryPointCommand(const LoadCommandInfo &L) const
StringRef symbolName() const
MachO::routines_command_64 getRoutinesCommand64(const LoadCommandInfo &L) const
void moveSectionNext(DataRefImpl &Sec) const override
bool isSectionCompressed(DataRefImpl Sec) const override
unsigned getSectionID(SectionRef Sec) const
const MachO::mach_header_64 & getHeader64() const
unsigned getAnyRelocationAddress(const MachO::any_relocation_info &RE) const
ArrayRef< uint8_t > getUuid() const
iterator_range< load_command_iterator > load_commands() const
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
uint32_t segmentIndex() const
MachO::section getSection(DataRefImpl DRI) const
static bool is64Bit(const char *name)
MachO::segment_command getSegmentLoadCommand(const LoadCommandInfo &L) const
unsigned getAnyRelocationPCRel(const MachO::any_relocation_info &RE) const
ArrayRef< uint8_t > getDyldInfoRebaseOpcodes() const
MachO::source_version_command getSourceVersionCommand(const LoadCommandInfo &L) const
MachO::linkedit_data_command getDataInCodeLoadCommand() const
LoadCommandList::const_iterator load_command_iterator
bool operator==(const DiceRef &Other) const
DiceRef - This is a value type class that represents a single data in code entry in the table in a Ma...
MachORebaseEntry(ArrayRef< uint8_t > opcodes, bool is64Bit)
MachO::sub_framework_command getSubFrameworkCommand(const LoadCommandInfo &L) const
content_iterator< MachOBindEntry > bind_iterator
bool operator==(const MachOBindEntry &) const
StringRef typeName() const
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
MachO::thread_command getThreadCommand(const LoadCommandInfo &L) const
uint64_t getNValue(DataRefImpl Sym) const
Triple - Helper class for working with autoconf configuration names.
section_iterator getRelocationSection(DataRefImpl Rel) const
std::error_code getLibraryShortNameByIndex(unsigned Index, StringRef &) const
Triple getArchTriple(const char **McpuDefault=nullptr) const
section_iterator getRelocationRelocatedSection(relocation_iterator Rel) const
bool hasPageZeroSegment() const
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
void moveSymbolNext(DataRefImpl &Symb) const override
unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const
unsigned getSymbolSectionID(SymbolRef Symb) const
bool isSectionData(DataRefImpl Sec) const override
content_iterator< DiceRef > dice_iterator
StringRef getSectionFinalSegmentName(DataRefImpl Sec) const
std::error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const override
MachO::nlist_64 getSymbol64TableEntry(DataRefImpl DRI) const
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn...
ArrayRef< uint8_t > getDyldInfoExportsTrie() const
uint64_t segmentOffset() const
static uint32_t getVersionMinMinor(MachO::version_min_command &C, bool SDK)
MachO::nlist getSymbolTableEntry(DataRefImpl DRI) const
std::error_code getLength(uint16_t &Result) const
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
uint32_t getSymbolFlags(DataRefImpl Symb) const override
MachO::sub_library_command getSubLibraryCommand(const LoadCommandInfo &L) const
SectionRef getAnyRelocationSection(const MachO::any_relocation_info &RE) const
A range adaptor for a pair of iterators.
SubtargetFeatures - Manages the enabling and disabling of subtarget specific features.
MachO::encryption_info_command getEncryptionInfoCommand(const LoadCommandInfo &L) const
This is a value type class that represents a single symbol in the list of symbols in the object file...
bool operator<(const DiceRef &Other) const
static Expected< std::unique_ptr< MachOObjectFile > > create(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits, uint32_t UniversalCputype=0, uint32_t UniversalIndex=0)
MachO::mach_header_64 Header64
MachOBindEntry(ArrayRef< uint8_t > Opcodes, bool is64Bit, MachOBindEntry::Kind)
MachO::linkedit_data_command getLinkeditDataLoadCommand(const LoadCommandInfo &L) const
MachO::version_min_command getVersionMinLoadCommand(const LoadCommandInfo &L) const
static StringRef guessLibraryShortName(StringRef Name, bool &isFramework, StringRef &Suffix)
bool isSectionBSS(DataRefImpl Sec) const override
MachO::symtab_command getSymtabLoadCommand() const
basic_symbol_iterator getSymbolByIndex(unsigned Index) const
dice_iterator begin_dices() const
section_iterator section_begin() const override
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
static bool isValidArch(StringRef ArchFlag)
relocation_iterator section_rel_end(DataRefImpl Sec) const override
MachO::dysymtab_command getDysymtabLoadCommand() const
MachO::mach_header Header
MachO::rpath_command getRpathCommand(const LoadCommandInfo &L) const
MachO::data_in_code_entry getDice(DataRefImpl Rel) const
MachO::sub_umbrella_command getSubUmbrellaCommand(const LoadCommandInfo &L) const
unsigned getSectionType(SectionRef Sec) const
Lightweight error class with error context and mandatory checking.
section_iterator section_end() const override
const ObjectFile * getObjectFile() const
iterator_range< bind_iterator > lazyBindTable() const
For use iterating over all lazy bind table entries.
static uint32_t getVersionMinMajor(MachO::version_min_command &C, bool SDK)
ArrayRef< uint8_t > getDyldInfoWeakBindOpcodes() const
StringRef - Represent a constant reference to a string, i.e.
static bool classof(const Binary *v)
unsigned getPlainRelocationSymbolNum(const MachO::any_relocation_info &RE) const
MachO::dyld_info_command getDyldInfoLoadCommand(const LoadCommandInfo &L) const
bool isRelocationScattered(const MachO::any_relocation_info &RE) const
MachO::sub_client_command getSubClientCommand(const LoadCommandInfo &L) const
content_iterator< MachORebaseEntry > rebase_iterator
SmallVector< LoadCommandInfo, 4 > LoadCommandList
iterator_range< bind_iterator > bindTable() const
For use iterating over all bind table entries.
iterator_range< bind_iterator > weakBindTable() const
For use iterating over all lazy bind table entries.
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
Error checkSymbolTable() const
uint32_t segmentIndex() const
This is a value type class that represents a single section in the list of sections in the object fil...
uint64_t getSectionSize(DataRefImpl Sec) const override
ArrayRef< uint8_t > getDyldInfoBindOpcodes() const