| // -*- mode: ObjC -*- |
| |
| // This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files. |
| // Copyright (C) 1997-2019 Steve Nygard. |
| |
| #import "CDLCLinkeditData.h" |
| |
| #import "CDMachOFile.h" |
| |
| @implementation CDLCLinkeditData |
| { |
| struct linkedit_data_command _linkeditDataCommand; |
| NSData *_linkeditData; |
| } |
| |
| - (id)initWithDataCursor:(CDMachOFileDataCursor *)cursor; |
| { |
| if ((self = [super initWithDataCursor:cursor])) { |
| _linkeditDataCommand.cmd = [cursor readInt32]; |
| _linkeditDataCommand.cmdsize = [cursor readInt32]; |
| |
| _linkeditDataCommand.dataoff = [cursor readInt32]; |
| _linkeditDataCommand.datasize = [cursor readInt32]; |
| } |
| |
| return self; |
| } |
| |
| #pragma mark - |
| |
| - (uint32_t)cmd; |
| { |
| return _linkeditDataCommand.cmd; |
| } |
| |
| - (uint32_t)cmdsize; |
| { |
| return _linkeditDataCommand.cmdsize; |
| } |
| |
| - (NSData *)linkeditData; |
| { |
| if (_linkeditData == NULL) { |
| _linkeditData = [[NSData alloc] initWithBytes:[self.machOFile bytesAtOffset:_linkeditDataCommand.dataoff] length:_linkeditDataCommand.datasize]; |
| } |
| |
| return _linkeditData; |
| } |
| |
| @end |