aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Object/MachO.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Object/MachO.h')
-rw-r--r--include/llvm/Object/MachO.h123
1 files changed, 79 insertions, 44 deletions
diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h
index 710ad7e..e93ebb8 100644
--- a/include/llvm/Object/MachO.h
+++ b/include/llvm/Object/MachO.h
@@ -40,9 +40,9 @@ public:
void moveNext();
- error_code getOffset(uint32_t &Result) const;
- error_code getLength(uint16_t &Result) const;
- error_code getKind(uint16_t &Result) const;
+ std::error_code getOffset(uint32_t &Result) const;
+ std::error_code getLength(uint16_t &Result) const;
+ std::error_code getKind(uint16_t &Result) const;
DataRefImpl getRawDataRefImpl() const;
const ObjectFile *getObjectFile() const;
@@ -56,54 +56,75 @@ public:
MachO::load_command C; // The command itself.
};
- MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian, bool Is64Bits,
- error_code &EC, bool BufferOwned = true);
+ MachOObjectFile(std::unique_ptr<MemoryBuffer> Object, bool IsLittleEndian,
+ bool Is64Bits, std::error_code &EC);
void moveSymbolNext(DataRefImpl &Symb) const override;
- error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const override;
- error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const override;
- error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const override;
- error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
- error_code getSymbolType(DataRefImpl Symb,
- SymbolRef::Type &Res) const override;
+ std::error_code getSymbolName(DataRefImpl Symb,
+ StringRef &Res) const override;
+
+ // MachO specific.
+ std::error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const;
+
+ std::error_code getSymbolAddress(DataRefImpl Symb,
+ uint64_t &Res) const override;
+ std::error_code getSymbolAlignment(DataRefImpl Symb,
+ uint32_t &Res) const override;
+ std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
+ std::error_code getSymbolType(DataRefImpl Symb,
+ SymbolRef::Type &Res) const override;
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
- error_code getSymbolSection(DataRefImpl Symb,
- section_iterator &Res) const override;
+ std::error_code getSymbolSection(DataRefImpl Symb,
+ section_iterator &Res) const override;
void moveSectionNext(DataRefImpl &Sec) const override;
- error_code getSectionName(DataRefImpl Sec, StringRef &Res) const override;
- error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const override;
- error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
- error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const override;
- error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res) const override;
- error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
- error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
- error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
- error_code isSectionRequiredForExecution(DataRefImpl Sec,
- bool &Res) const override;
- error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
- error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
- error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const override;
- error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
- bool &Result) const override;
+ std::error_code getSectionName(DataRefImpl Sec,
+ StringRef &Res) const override;
+ std::error_code getSectionAddress(DataRefImpl Sec,
+ uint64_t &Res) const override;
+ std::error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
+ std::error_code getSectionContents(DataRefImpl Sec,
+ StringRef &Res) const override;
+ std::error_code getSectionAlignment(DataRefImpl Sec,
+ uint64_t &Res) const override;
+ std::error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
+ std::error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
+ std::error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
+ std::error_code isSectionRequiredForExecution(DataRefImpl Sec,
+ bool &Res) const override;
+ std::error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
+ std::error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
+ std::error_code isSectionReadOnlyData(DataRefImpl Sec,
+ bool &Res) const override;
+ std::error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
+ bool &Result) const override;
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
void moveRelocationNext(DataRefImpl &Rel) const override;
- error_code getRelocationAddress(DataRefImpl Rel,
- uint64_t &Res) const override;
- error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const override;
+ std::error_code getRelocationAddress(DataRefImpl Rel,
+ uint64_t &Res) const override;
+ std::error_code getRelocationOffset(DataRefImpl Rel,
+ uint64_t &Res) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
- error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const override;
- error_code getRelocationTypeName(DataRefImpl Rel,
- SmallVectorImpl<char> &Result) const override;
- error_code getRelocationValueString(DataRefImpl Rel,
- SmallVectorImpl<char> &Result) const override;
- error_code getRelocationHidden(DataRefImpl Rel, bool &Result) const override;
+ std::error_code getRelocationType(DataRefImpl Rel,
+ uint64_t &Res) const override;
+ std::error_code
+ getRelocationTypeName(DataRefImpl Rel,
+ SmallVectorImpl<char> &Result) const override;
+ std::error_code
+ getRelocationValueString(DataRefImpl Rel,
+ SmallVectorImpl<char> &Result) const override;
+ std::error_code getRelocationHidden(DataRefImpl Rel,
+ bool &Result) const override;
+
+ std::error_code getLibraryNext(DataRefImpl LibData,
+ LibraryRef &Res) const override;
+ std::error_code getLibraryPath(DataRefImpl LibData,
+ StringRef &Res) const override;
- error_code getLibraryNext(DataRefImpl LibData,
- LibraryRef &Res) const override;
- error_code getLibraryPath(DataRefImpl LibData, StringRef &Res) const override;
+ // MachO specific.
+ std::error_code getLibraryShortNameByIndex(unsigned Index, StringRef &Res);
// TODO: Would be useful to have an iterator based version
// of the load command interface too.
@@ -180,6 +201,8 @@ public:
getLinkerOptionsLoadCommand(const LoadCommandInfo &L) const;
MachO::version_min_command
getVersionMinLoadCommand(const LoadCommandInfo &L) const;
+ MachO::dylib_command
+ getDylibIDLoadCommand(const LoadCommandInfo &L) const;
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const;
MachO::data_in_code_entry getDice(DataRefImpl Rel) const;
@@ -198,15 +221,27 @@ public:
bool is64Bit() const;
void ReadULEB128s(uint64_t Index, SmallVectorImpl<uint64_t> &Out) const;
+ static StringRef guessLibraryShortName(StringRef Name, bool &isFramework,
+ StringRef &Suffix);
+
static Triple::ArchType getArch(uint32_t CPUType);
+ static Triple getArch(uint32_t CPUType, uint32_t CPUSubType);
+ static Triple getArch(StringRef ArchFlag);
+ static Triple getHostArch();
static bool classof(const Binary *v) {
return v->isMachO();
}
+ const char *getSectionPointer(DataRefImpl Rel) const;
+
private:
- typedef SmallVector<const char*, 1> SectionList;
+ typedef SmallVector<const char *, 1> SectionList;
SectionList Sections;
+ typedef SmallVector<const char *, 1> LibraryList;
+ LibraryList Libraries;
+ typedef SmallVector<StringRef, 1> LibraryShortName;
+ LibraryShortName LibrariesShortNames;
const char *SymtabLoadCmd;
const char *DysymtabLoadCmd;
const char *DataInCodeLoadCmd;
@@ -234,7 +269,7 @@ inline void DiceRef::moveNext() {
// the OwningObject ObjectFile is a MachOObjectFile a static_cast<> is used for
// the methods that get the values of the fields of the reference.
-inline error_code DiceRef::getOffset(uint32_t &Result) const {
+inline std::error_code DiceRef::getOffset(uint32_t &Result) const {
const MachOObjectFile *MachOOF =
static_cast<const MachOObjectFile *>(OwningObject);
MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
@@ -242,7 +277,7 @@ inline error_code DiceRef::getOffset(uint32_t &Result) const {
return object_error::success;
}
-inline error_code DiceRef::getLength(uint16_t &Result) const {
+inline std::error_code DiceRef::getLength(uint16_t &Result) const {
const MachOObjectFile *MachOOF =
static_cast<const MachOObjectFile *>(OwningObject);
MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
@@ -250,7 +285,7 @@ inline error_code DiceRef::getLength(uint16_t &Result) const {
return object_error::success;
}
-inline error_code DiceRef::getKind(uint16_t &Result) const {
+inline std::error_code DiceRef::getKind(uint16_t &Result) const {
const MachOObjectFile *MachOOF =
static_cast<const MachOObjectFile *>(OwningObject);
MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);