15 #ifndef LLVM_OBJECT_MACHO_H 16 #define LLVM_OBJECT_MACHO_H 37 #include <system_error> 58 std::error_code
getLength(uint16_t &Result)
const;
59 std::error_code
getKind(uint16_t &Result)
const;
78 uint64_t flags()
const;
79 uint64_t address()
const;
80 uint64_t other()
const;
94 void pushDownUntilBottom();
95 void pushNode(uint64_t
Offset);
99 NodeState(
const uint8_t *Ptr);
101 const uint8_t *Start;
102 const uint8_t *Current;
106 const char *ImportName =
nullptr;
107 unsigned ChildCount = 0;
108 unsigned NextChildIndex = 0;
109 unsigned ParentStringLength = 0;
110 bool IsExportNode =
false;
137 const char *checkSegAndOffset(int32_t SegIndex, uint64_t SegOffset,
140 uint8_t PointerSize, int32_t SegIndex,
144 StringRef sectionName(int32_t SegIndex, uint64_t SegOffset);
145 uint64_t address(
uint32_t SegIndex, uint64_t SegOffset);
153 uint64_t OffsetInSegment;
154 uint64_t SegmentStartAddress;
155 int32_t SegmentIndex;
157 const SectionInfo &findSection(int32_t SegIndex, uint64_t SegOffset);
175 int32_t segmentIndex()
const;
176 uint64_t segmentOffset()
const;
180 uint64_t address()
const;
198 int32_t SegmentIndex = -1;
199 uint64_t RemainingLoopCount = 0;
200 uint64_t AdvanceAmount = 0;
216 enum class Kind { Regular, Lazy, Weak };
221 int32_t segmentIndex()
const;
222 uint64_t segmentOffset()
const;
226 int64_t addend()
const;
231 uint64_t address()
const;
243 int64_t readSLEB128(
const char **
error);
250 int32_t SegmentIndex = -1;
252 bool LibraryOrdinalSet =
false;
256 uint64_t RemainingLoopCount = 0;
257 uint64_t AdvanceAmount = 0;
278 void moveSymbolNext(
DataRefImpl &Symb)
const override;
284 Error checkSymbolTable()
const;
287 unsigned getSectionType(
SectionRef Sec)
const;
291 uint64_t getCommonSymbolSizeImpl(
DataRefImpl Symb)
const override;
298 void moveSectionNext(
DataRefImpl &Sec)
const override;
301 uint64_t getSectionAddress(
DataRefImpl Sec)
const override;
302 uint64_t getSectionIndex(
DataRefImpl Sec)
const override;
303 uint64_t getSectionSize(
DataRefImpl Sec)
const override;
304 std::error_code getSectionContents(
DataRefImpl Sec,
306 uint64_t getSectionAlignment(
DataRefImpl Sec)
const override;
309 bool isSectionCompressed(
DataRefImpl Sec)
const override;
310 bool isSectionText(
DataRefImpl Sec)
const override;
311 bool isSectionData(
DataRefImpl Sec)
const override;
313 bool isSectionVirtual(
DataRefImpl Sec)
const override;
314 bool isSectionBitcode(
DataRefImpl Sec)
const override;
323 bool isSectionStripped(
DataRefImpl Sec)
const override;
331 return make_range(extrel_begin(), extrel_end());
337 void moveRelocationNext(
DataRefImpl &Rel)
const override;
338 uint64_t getRelocationOffset(
DataRefImpl Rel)
const override;
341 uint64_t getRelocationType(
DataRefImpl Rel)
const override;
344 uint8_t getRelocationLength(
DataRefImpl Rel)
const;
347 std::error_code getLibraryShortNameByIndex(
unsigned Index,
StringRef &)
const;
365 uint8_t getBytesInAddress()
const override;
367 StringRef getFileFormatName()
const override;
370 Triple getArchTriple(
const char **McpuDefault =
nullptr)
const;
419 bool endInvalid)
const {
420 return BindRebaseSectionTable->checkSegAndOffset(SegIndex, SegOffset,
426 uint8_t PointerSize, int32_t SegIndex,
427 uint64_t SegOffset)
const {
428 return BindRebaseSectionTable->checkCountAndSkip(Count, Skip, PointerSize,
429 SegIndex, SegOffset);
435 bool endInvalid)
const {
436 return BindRebaseSectionTable->checkSegAndOffset(SegIndex, SegOffset,
442 uint8_t PointerSize, int32_t SegIndex,
443 uint64_t SegOffset)
const {
444 return BindRebaseSectionTable->checkCountAndSkip(Count, Skip, PointerSize,
445 SegIndex, SegOffset);
451 return BindRebaseSectionTable->segmentName(SegIndex);
457 return BindRebaseSectionTable->sectionName(SegIndex, SegOffset);
463 return BindRebaseSectionTable->address(SegIndex, SegOffset);
478 unsigned getPlainRelocationSymbolNum(
481 bool getScatteredRelocationScattered(
483 uint32_t getScatteredRelocationValue(
485 uint32_t getScatteredRelocationType(
516 getBuildToolVersion(
unsigned index)
const;
556 unsigned Index)
const;
558 unsigned Index)
const;
579 const char **McpuDefault =
nullptr,
580 const char **ArchFlag =
nullptr);
581 static bool isValidArch(
StringRef ArchFlag);
582 static Triple getHostArch();
584 bool isRelocatableObject()
const override;
597 return (VersionOrSDK >> 16) & 0xffff;
603 return (VersionOrSDK >> 8) & 0xff;
609 return VersionOrSDK & 0xff;
644 uint32_t major = (version >> 16) & 0xffff;
645 uint32_t minor = (version >> 8) & 0xff;
651 Version +=
"." +
utostr(update);
652 return Version.
str();
660 uint64_t getSymbolValueImpl(
DataRefImpl Symb)
const override;
675 std::unique_ptr<BindRebaseSegInfo> BindRebaseSectionTable;
676 const char *SymtabLoadCmd =
nullptr;
677 const char *DysymtabLoadCmd =
nullptr;
678 const char *DataInCodeLoadCmd =
nullptr;
679 const char *LinkOptHintsLoadCmd =
nullptr;
680 const char *DyldInfoLoadCmd =
nullptr;
681 const char *UuidLoadCmd =
nullptr;
682 bool HasPageZeroSegment =
false;
687 : DicePimpl(DiceP) , OwningObject(Owner) {}
690 return DicePimpl == Other.DicePimpl;
694 return DicePimpl < Other.DicePimpl;
700 DicePimpl.
p =
reinterpret_cast<uintptr_t
>(P + 1);
712 return std::error_code();
720 return std::error_code();
728 return std::error_code();
742 #endif // LLVM_OBJECT_MACHO_H DataRefImpl getRawDataRefImpl() const
const char * BindEntryCheckSegAndOffset(int32_t SegIndex, uint64_t SegOffset, bool endInvalid) const
For use with a SegIndex,SegOffset pair in MachOBindEntry::moveNext() to validate a MachOBindEntry...
static uint32_t getVersionMinUpdate(MachO::version_min_command &C, bool SDK)
StringRef BindRebaseSegmentName(int32_t SegIndex) const
For use with the SegIndex of a checked Mach-O Bind or Rebase entry to get the segment name...
typename SuperClass::const_iterator const_iterator
const ObjectFile * getObjectFile() const
This class represents lattice values for constants.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
ExportEntry encapsulates the current-state-of-the-walk used when doing a non-recursive walk of the tr...
const char * BindEntryCheckCountAndSkip(uint32_t Count, uint32_t Skip, uint8_t PointerSize, int32_t SegIndex, uint64_t SegOffset) const
For use in MachOBindEntry::moveNext() to validate a MachOBindEntry for the BIND_OPCODE_DO_BIND_ULEB_T...
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
static std::string getVersionString(uint32_t version)
bool hasPageZeroSegment() const
const char * RebaseEntryCheckSegAndOffset(int32_t SegIndex, uint64_t SegOffset, bool endInvalid) const
For use with a SegIndex,SegOffset pair in MachORebaseEntry::moveNext() to validate a MachORebaseEntry...
This class is the base class for all object file types.
MachORebaseEntry encapsulates the current state in the decompression of rebasing opcodes.
static unsigned getSymbolSectionID(const ObjectFile &O, SymbolRef Sym)
static std::string getBuildTool(uint32_t tools)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
static StringRef getSymbolName(SymbolKind SymKind)
Tagged union holding either a T or a Error.
MachOBindEntry encapsulates the current state in the decompression of binding opcodes.
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
static std::string getBuildPlatform(uint32_t platform)
static uint64_t readULEB128(WasmObjectFile::ReadContext &Ctx)
StringRef str() const
Explicit conversion to StringRef.
SubtargetFeatures getFeatures() const override
static Constant * SegmentOffset(IRBuilder<> &IRB, unsigned Offset, unsigned AddressSpace)
uint64_t BindRebaseAddress(uint32_t SegIndex, uint64_t SegOffset) const
For use with a SegIndex,SegOffset pair from a checked Mach-O Bind or Rebase entry to get the address...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
static bool is64Bit(const char *name)
std::error_code getLength(uint16_t &Result) const
DiceRef - This is a value type class that represents a single data in code entry in the table in a Ma...
static unsigned getSectionID(const ObjectFile &O, SectionRef Sec)
const char * RebaseEntryCheckCountAndSkip(uint32_t Count, uint32_t Skip, uint8_t PointerSize, int32_t SegIndex, uint64_t SegOffset) const
For use in MachORebaseEntry::moveNext() to validate a MachORebaseEntry for the REBASE_OPCODE_DO_*_TIM...
std::error_code getOffset(uint32_t &Result) const
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
Triple - Helper class for working with autoconf configuration names.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static uint32_t getVersionMinMinor(MachO::version_min_command &C, bool SDK)
MachO::data_in_code_entry getDice(DataRefImpl Rel) const
std::error_code getKind(uint16_t &Result) const
std::string utostr(uint64_t X, bool isNeg=false)
A range adaptor for a pair of iterators.
bool operator<(const DiceRef &Other) const
Manages the enabling and disabling of subtarget specific features.
This is a value type class that represents a single symbol in the list of symbols in the object file...
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
MachO::mach_header_64 Header64
bool operator==(const DiceRef &Other) const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
iterator_range< typename GraphTraits< GraphType >::nodes_iterator > nodes(const GraphType &G)
StringRef BindRebaseSectionName(uint32_t SegIndex, uint64_t SegOffset) const
For use with a SegIndex,SegOffset pair from a checked Mach-O Bind or Rebase entry to get the section ...
iterator_range< relocation_iterator > external_relocations() const
MachO::mach_header Header
A raw_ostream that writes to an std::string.
LoadCommandList::const_iterator load_command_iterator
Lightweight error class with error context and mandatory checking.
static uint32_t getVersionMinMajor(MachO::version_min_command &C, bool SDK)
StringRef - Represent a constant reference to a string, i.e.
static bool classof(const Binary *v)
This is a value type class that represents a single section in the list of sections in the object fil...