14 #ifndef LLVM_OBJECT_MACHO_H 15 #define LLVM_OBJECT_MACHO_H 36 #include <system_error> 77 uint64_t flags()
const;
78 uint64_t address()
const;
79 uint64_t other()
const;
93 void pushDownUntilBottom();
94 void pushNode(uint64_t
Offset);
98 NodeState(
const uint8_t *Ptr);
100 const uint8_t *Start;
101 const uint8_t *Current;
105 const char *ImportName =
nullptr;
106 unsigned ChildCount = 0;
107 unsigned NextChildIndex = 0;
108 unsigned ParentStringLength = 0;
109 bool IsExportNode =
false;
136 const char* checkSegAndOffsets(int32_t SegIndex, uint64_t SegOffset,
137 uint8_t PointerSize,
uint32_t Count=1,
141 StringRef sectionName(int32_t SegIndex, uint64_t SegOffset);
142 uint64_t address(
uint32_t SegIndex, uint64_t SegOffset);
150 uint64_t OffsetInSegment;
151 uint64_t SegmentStartAddress;
152 int32_t SegmentIndex;
154 const SectionInfo &findSection(int32_t SegIndex, uint64_t SegOffset);
172 int32_t segmentIndex()
const;
173 uint64_t segmentOffset()
const;
177 uint64_t address()
const;
195 int32_t SegmentIndex = -1;
196 uint64_t RemainingLoopCount = 0;
197 uint64_t AdvanceAmount = 0;
213 enum class Kind { Regular, Lazy, Weak };
218 int32_t segmentIndex()
const;
219 uint64_t segmentOffset()
const;
223 int64_t addend()
const;
228 uint64_t address()
const;
240 int64_t readSLEB128(
const char **
error);
247 int32_t SegmentIndex = -1;
249 bool LibraryOrdinalSet =
false;
253 uint64_t RemainingLoopCount = 0;
254 uint64_t AdvanceAmount = 0;
275 void moveSymbolNext(
DataRefImpl &Symb)
const override;
281 Error checkSymbolTable()
const;
284 unsigned getSectionType(
SectionRef Sec)
const;
288 uint64_t getCommonSymbolSizeImpl(
DataRefImpl Symb)
const override;
295 void moveSectionNext(
DataRefImpl &Sec)
const override;
297 uint64_t getSectionAddress(
DataRefImpl Sec)
const override;
298 uint64_t getSectionIndex(
DataRefImpl Sec)
const override;
299 uint64_t getSectionSize(
DataRefImpl Sec)
const override;
302 getSectionContents(
DataRefImpl Sec)
const override;
303 uint64_t getSectionAlignment(
DataRefImpl Sec)
const override;
306 bool isSectionCompressed(
DataRefImpl Sec)
const override;
307 bool isSectionText(
DataRefImpl Sec)
const override;
308 bool isSectionData(
DataRefImpl Sec)
const override;
310 bool isSectionVirtual(
DataRefImpl Sec)
const override;
311 bool isSectionBitcode(
DataRefImpl Sec)
const override;
320 bool isSectionStripped(
DataRefImpl Sec)
const override;
328 return make_range(extrel_begin(), extrel_end());
334 void moveRelocationNext(
DataRefImpl &Rel)
const override;
335 uint64_t getRelocationOffset(
DataRefImpl Rel)
const override;
338 uint64_t getRelocationType(
DataRefImpl Rel)
const override;
341 uint8_t getRelocationLength(
DataRefImpl Rel)
const;
344 std::error_code getLibraryShortNameByIndex(
unsigned Index,
StringRef &)
const;
362 uint8_t getBytesInAddress()
const override;
364 StringRef getFileFormatName()
const override;
367 Triple getArchTriple(
const char **McpuDefault =
nullptr)
const;
420 uint8_t PointerSize,
uint32_t Count=1,
422 return BindRebaseSectionTable->checkSegAndOffsets(SegIndex, SegOffset,
423 PointerSize, Count, Skip);
437 return BindRebaseSectionTable->checkSegAndOffsets(SegIndex, SegOffset,
438 PointerSize, Count, Skip);
444 return BindRebaseSectionTable->segmentName(SegIndex);
450 return BindRebaseSectionTable->sectionName(SegIndex, SegOffset);
456 return BindRebaseSectionTable->address(SegIndex, SegOffset);
471 unsigned getPlainRelocationSymbolNum(
474 bool getScatteredRelocationScattered(
476 uint32_t getScatteredRelocationValue(
478 uint32_t getScatteredRelocationType(
509 getBuildToolVersion(
unsigned index)
const;
549 unsigned Index)
const;
551 unsigned Index)
const;
572 const char **McpuDefault =
nullptr,
573 const char **ArchFlag =
nullptr);
574 static bool isValidArch(
StringRef ArchFlag);
576 static Triple getHostArch();
578 bool isRelocatableObject()
const override;
591 return (VersionOrSDK >> 16) & 0xffff;
597 return (VersionOrSDK >> 8) & 0xff;
603 return VersionOrSDK & 0xff;
639 uint32_t major = (version >> 16) & 0xffff;
640 uint32_t minor = (version >> 8) & 0xff;
646 Version +=
"." +
utostr(update);
647 return Version.
str();
655 uint64_t getSymbolValueImpl(
DataRefImpl Symb)
const override;
670 std::unique_ptr<BindRebaseSegInfo> BindRebaseSectionTable;
671 const char *SymtabLoadCmd =
nullptr;
672 const char *DysymtabLoadCmd =
nullptr;
673 const char *DataInCodeLoadCmd =
nullptr;
674 const char *LinkOptHintsLoadCmd =
nullptr;
675 const char *DyldInfoLoadCmd =
nullptr;
676 const char *UuidLoadCmd =
nullptr;
677 bool HasPageZeroSegment =
false;
682 : DicePimpl(DiceP) , OwningObject(Owner) {}
685 return DicePimpl == Other.DicePimpl;
689 return DicePimpl < Other.DicePimpl;
695 DicePimpl.
p =
reinterpret_cast<uintptr_t
>(P + 1);
707 return std::error_code();
715 return std::error_code();
723 return std::error_code();
737 #endif // LLVM_OBJECT_MACHO_H
DataRefImpl getRawDataRefImpl() const
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.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
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...
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Optional< std::vector< StOtherPiece > > Other
static std::string getVersionString(uint32_t version)
bool hasPageZeroSegment() const
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)
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
const char * BindEntryCheckSegAndOffsets(int32_t SegIndex, uint64_t SegOffset, uint8_t PointerSize, uint32_t Count=1, uint32_t Skip=0) const
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")
std::error_code getLength(uint16_t &Result) const
const char * RebaseEntryCheckSegAndOffsets(int32_t SegIndex, uint64_t SegOffset, uint8_t PointerSize, uint32_t Count=1, uint32_t Skip=0) 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)
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
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)
static bool is64Bit(const char *name)
This is a value type class that represents a single section in the list of sections in the object fil...