Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: class-dump/src/CDSection32.m

Issue 7793008: Add the 3.3.3 sources for class-dump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « class-dump/src/CDSection32.h ('k') | class-dump/src/CDSection64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 "CDSection32.h"
7
8 #import "CDFatFile.h"
9 #import "CDMachOFile.h"
10 #import "CDLCSegment32.h"
11
12 @implementation CDSection32
13
14 // Just to resolve multiple different definitions...
15 - (id)initWithDataCursor:(CDDataCursor *)cursor segment:(CDLCSegment32 *)aSegmen t;
16 {
17 char buf[17];
18 NSString *str;
19
20 if ([super init] == nil)
21 return nil;
22
23 nonretained_segment = aSegment;
24
25 [cursor readBytesOfLength:16 intoBuffer:section.sectname];
26 [cursor readBytesOfLength:16 intoBuffer:section.segname];
27 section.addr = [cursor readInt32];
28 section.size = [cursor readInt32];
29 section.offset = [cursor readInt32];
30 section.align = [cursor readInt32];
31 section.reloff = [cursor readInt32];
32 section.nreloc = [cursor readInt32];
33 section.flags = [cursor readInt32];
34 section.reserved1 = [cursor readInt32];
35 section.reserved2 = [cursor readInt32];
36
37 // These aren't guaranteed to be null terminated. Witness __cstring_object in __OBJC segment
38
39 memcpy(buf, section.segname, 16);
40 buf[16] = 0;
41 str = [[NSString alloc] initWithBytes:buf length:strlen(buf) encoding:NSASCI IStringEncoding];
42 [self setSegmentName:str];
43 [str release];
44
45 memcpy(buf, section.sectname, 16);
46 buf[16] = 0;
47 str = [[NSString alloc] initWithBytes:buf length:strlen(buf) encoding:NSASCI IStringEncoding];
48 [self setSectionName:str];
49 [str release];
50
51 return self;
52 }
53
54 - (CDLCSegment32 *)segment;
55 {
56 return nonretained_segment;
57 }
58
59 - (CDMachOFile *)machOFile;
60 {
61 return [[self segment] machOFile];
62 }
63
64 - (NSUInteger)addr;
65 {
66 return section.addr;
67 }
68
69 - (NSUInteger)size;
70 {
71 return section.size;
72 }
73
74 - (uint32_t)offset;
75 {
76 return section.offset;
77 }
78
79 - (void)loadData;
80 {
81 if (_flags.hasLoadedData == NO) {
82 data = [[NSData alloc] initWithBytes:[[nonretained_segment machOFile] ma chODataBytes] + section.offset length:section.size];
83 _flags.hasLoadedData = YES;
84 }
85 }
86
87 #if 1
88 - (NSString *)description;
89 {
90 return [NSString stringWithFormat:@"addr: 0x%08x, offset: %8d, size: %8d [0x %8x], segment; '%@', section: '%@'",
91 section.addr, section.offset, section.size, section.size, s egmentName, sectionName];
92 }
93 #endif
94
95 - (BOOL)containsAddress:(NSUInteger)address;
96 {
97 return (address >= section.addr) && (address < section.addr + section.size);
98 }
99
100 - (NSUInteger)fileOffsetForAddress:(NSUInteger)address;
101 {
102 NSParameterAssert([self containsAddress:address]);
103 return section.offset + address - section.addr;
104 }
105
106 @end
OLDNEW
« no previous file with comments | « class-dump/src/CDSection32.h ('k') | class-dump/src/CDSection64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698