forked from OSchip/llvm-project
Add MachOObjectFile::getUuid()
This CL introduces MachOObjectFile::getUuid(). This function returns an ArrayRef to the object file's UUID, or an empty ArrayRef if the object file doesn't contain an LC_UUID load command. The new function is gonna be used by llvm-symbolizer. llvm-svn: 219866
This commit is contained in:
parent
900dbdc4d9
commit
6909b5b567
|
@ -380,6 +380,7 @@ public:
|
||||||
ArrayRef<uint8_t> getDyldInfoWeakBindOpcodes() const;
|
ArrayRef<uint8_t> getDyldInfoWeakBindOpcodes() const;
|
||||||
ArrayRef<uint8_t> getDyldInfoLazyBindOpcodes() const;
|
ArrayRef<uint8_t> getDyldInfoLazyBindOpcodes() const;
|
||||||
ArrayRef<uint8_t> getDyldInfoExportsTrie() const;
|
ArrayRef<uint8_t> getDyldInfoExportsTrie() const;
|
||||||
|
ArrayRef<uint8_t> getUuid() const;
|
||||||
|
|
||||||
StringRef getStringTableData() const;
|
StringRef getStringTableData() const;
|
||||||
bool is64Bit() const;
|
bool is64Bit() const;
|
||||||
|
@ -417,6 +418,7 @@ private:
|
||||||
const char *DysymtabLoadCmd;
|
const char *DysymtabLoadCmd;
|
||||||
const char *DataInCodeLoadCmd;
|
const char *DataInCodeLoadCmd;
|
||||||
const char *DyldInfoLoadCmd;
|
const char *DyldInfoLoadCmd;
|
||||||
|
const char *UuidLoadCmd;
|
||||||
bool HasPageZeroSegment;
|
bool HasPageZeroSegment;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
|
||||||
: ObjectFile(getMachOType(IsLittleEndian, Is64bits), Object),
|
: ObjectFile(getMachOType(IsLittleEndian, Is64bits), Object),
|
||||||
SymtabLoadCmd(nullptr), DysymtabLoadCmd(nullptr),
|
SymtabLoadCmd(nullptr), DysymtabLoadCmd(nullptr),
|
||||||
DataInCodeLoadCmd(nullptr), DyldInfoLoadCmd(nullptr),
|
DataInCodeLoadCmd(nullptr), DyldInfoLoadCmd(nullptr),
|
||||||
HasPageZeroSegment(false) {
|
UuidLoadCmd(nullptr), HasPageZeroSegment(false) {
|
||||||
uint32_t LoadCommandCount = this->getHeader().ncmds;
|
uint32_t LoadCommandCount = this->getHeader().ncmds;
|
||||||
MachO::LoadCommandType SegmentLoadType = is64Bit() ?
|
MachO::LoadCommandType SegmentLoadType = is64Bit() ?
|
||||||
MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT;
|
MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT;
|
||||||
|
@ -259,6 +259,9 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
|
||||||
Load.C.cmd == MachO::LC_DYLD_INFO_ONLY) {
|
Load.C.cmd == MachO::LC_DYLD_INFO_ONLY) {
|
||||||
assert(!DyldInfoLoadCmd && "Multiple dyldinfo load commands");
|
assert(!DyldInfoLoadCmd && "Multiple dyldinfo load commands");
|
||||||
DyldInfoLoadCmd = Load.Ptr;
|
DyldInfoLoadCmd = Load.Ptr;
|
||||||
|
} else if (Load.C.cmd == MachO::LC_UUID) {
|
||||||
|
assert(!UuidLoadCmd && "Multiple UUID load commands");
|
||||||
|
UuidLoadCmd = Load.Ptr;
|
||||||
} else if (Load.C.cmd == SegmentLoadType) {
|
} else if (Load.C.cmd == SegmentLoadType) {
|
||||||
uint32_t NumSections = getSegmentLoadCommandNumSections(this, Load);
|
uint32_t NumSections = getSegmentLoadCommandNumSections(this, Load);
|
||||||
for (unsigned J = 0; J < NumSections; ++J) {
|
for (unsigned J = 0; J < NumSections; ++J) {
|
||||||
|
@ -2418,6 +2421,12 @@ ArrayRef<uint8_t> MachOObjectFile::getDyldInfoExportsTrie() const {
|
||||||
return ArrayRef<uint8_t>(Ptr, DyldInfo.export_size);
|
return ArrayRef<uint8_t>(Ptr, DyldInfo.export_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayRef<uint8_t> MachOObjectFile::getUuid() const {
|
||||||
|
if (!UuidLoadCmd)
|
||||||
|
return ArrayRef<uint8_t>();
|
||||||
|
MachO::uuid_command Uuid = getStruct<MachO::uuid_command>(this, UuidLoadCmd);
|
||||||
|
return ArrayRef<uint8_t>(Uuid.uuid, 16);
|
||||||
|
}
|
||||||
|
|
||||||
StringRef MachOObjectFile::getStringTableData() const {
|
StringRef MachOObjectFile::getStringTableData() const {
|
||||||
MachO::symtab_command S = getSymtabLoadCommand();
|
MachO::symtab_command S = getSymtabLoadCommand();
|
||||||
|
|
Loading…
Reference in New Issue