summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 260e7557f43..4435815b899 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -239,7 +239,7 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
: ObjectFile(getMachOType(IsLittleEndian, Is64bits), Object),
SymtabLoadCmd(nullptr), DysymtabLoadCmd(nullptr),
DataInCodeLoadCmd(nullptr), DyldInfoLoadCmd(nullptr),
- HasPageZeroSegment(false) {
+ UuidLoadCmd(nullptr), HasPageZeroSegment(false) {
uint32_t LoadCommandCount = this->getHeader().ncmds;
MachO::LoadCommandType SegmentLoadType = is64Bit() ?
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) {
assert(!DyldInfoLoadCmd && "Multiple dyldinfo load commands");
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) {
uint32_t NumSections = getSegmentLoadCommandNumSections(this, Load);
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);
}
+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 {
MachO::symtab_command S = getSymtabLoadCommand();
OpenPOWER on IntegriCloud