OLD | NEW |
(Empty) | |
| 1 // -*- mode: ObjC -*- |
| 2 |
| 3 // This file is part of class-dump, a utility for examining the Objective-C seg
ment of Mach-O files. |
| 4 // Copyright (C) 1997-1998, 2000-2001, 2004-2010 Steve Nygard. |
| 5 |
| 6 #import "CDSection.h" |
| 7 |
| 8 #import "CDFatFile.h" |
| 9 #import "CDMachOFile.h" |
| 10 #import "CDLCSegment32.h" |
| 11 |
| 12 @implementation CDSection |
| 13 |
| 14 // Just to resolve multiple different definitions... |
| 15 - (id)init; |
| 16 { |
| 17 if ([super init] == nil) |
| 18 return nil; |
| 19 |
| 20 segmentName = nil; |
| 21 sectionName = nil; |
| 22 |
| 23 data = nil; |
| 24 _flags.hasLoadedData = NO; |
| 25 |
| 26 return self; |
| 27 } |
| 28 |
| 29 - (void)dealloc; |
| 30 { |
| 31 [segmentName release]; |
| 32 [sectionName release]; |
| 33 [data release]; |
| 34 |
| 35 [super dealloc]; |
| 36 } |
| 37 |
| 38 - (NSString *)segmentName; |
| 39 { |
| 40 return segmentName; |
| 41 } |
| 42 |
| 43 - (void)setSegmentName:(NSString *)newName; |
| 44 { |
| 45 if (newName == segmentName) |
| 46 return; |
| 47 |
| 48 [segmentName release]; |
| 49 segmentName = [newName retain]; |
| 50 } |
| 51 |
| 52 - (NSString *)sectionName; |
| 53 { |
| 54 return sectionName; |
| 55 } |
| 56 |
| 57 - (void)setSectionName:(NSString *)newName; |
| 58 { |
| 59 if (newName == sectionName) |
| 60 return; |
| 61 |
| 62 [sectionName release]; |
| 63 sectionName = [newName retain]; |
| 64 } |
| 65 |
| 66 - (NSData *)data; |
| 67 { |
| 68 [self loadData]; |
| 69 |
| 70 return data; |
| 71 } |
| 72 |
| 73 - (void)loadData; |
| 74 { |
| 75 // Impelement in subclasses |
| 76 } |
| 77 |
| 78 - (void)unloadData; |
| 79 { |
| 80 if (_flags.hasLoadedData) { |
| 81 _flags.hasLoadedData = NO; |
| 82 [data release]; |
| 83 data = nil; |
| 84 } |
| 85 } |
| 86 |
| 87 - (NSUInteger)addr; |
| 88 { |
| 89 // Implement in subclasses. |
| 90 return 0; |
| 91 } |
| 92 |
| 93 - (NSUInteger)size; |
| 94 { |
| 95 // Implement in subclasses. |
| 96 return 0; |
| 97 } |
| 98 |
| 99 - (CDMachOFile *)machOFile; |
| 100 { |
| 101 // Implement in subclass (for now). |
| 102 return nil; |
| 103 } |
| 104 |
| 105 - (NSString *)description; |
| 106 { |
| 107 return [NSString stringWithFormat:@"<%@:%p> segment; '%@', section: '%-16s'"
, |
| 108 NSStringFromClass([self class]), self, |
| 109 segmentName, [sectionName UTF8String]]; |
| 110 } |
| 111 |
| 112 - (BOOL)containsAddress:(NSUInteger)address; |
| 113 { |
| 114 // implement in subclasses. |
| 115 return NO; |
| 116 } |
| 117 |
| 118 - (NSUInteger)fileOffsetForAddress:(NSUInteger)address; |
| 119 { |
| 120 // implement in subclasses. |
| 121 return 0; |
| 122 } |
| 123 |
| 124 @end |
OLD | NEW |