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

Unified Diff: class-dump/src/CDSection64.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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « class-dump/src/CDSection64.h ('k') | class-dump/src/CDStructureInfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: class-dump/src/CDSection64.m
===================================================================
--- class-dump/src/CDSection64.m (revision 0)
+++ class-dump/src/CDSection64.m (revision 0)
@@ -0,0 +1,100 @@
+// -*- mode: ObjC -*-
+
+// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
+// Copyright (C) 1997-1998, 2000-2001, 2004-2010 Steve Nygard.
+
+#import "CDSection64.h"
+
+#import "CDDataCursor.h"
+#import "CDMachOFile.h"
+
+@implementation CDSection64
+
+- (id)initWithDataCursor:(CDDataCursor *)cursor segment:(CDLCSegment64 *)aSegment;
+{
+ char buf[17];
+ NSString *str;
+
+ if ([super init] == nil)
+ return nil;
+
+ nonretained_segment = aSegment;
+
+ [cursor readBytesOfLength:16 intoBuffer:section.sectname];
+ [cursor readBytesOfLength:16 intoBuffer:section.segname];
+ section.addr = [cursor readInt64];
+ section.size = [cursor readInt64];
+ section.offset = [cursor readInt32];
+ section.align = [cursor readInt32];
+ section.reloff = [cursor readInt32];
+ section.nreloc = [cursor readInt32];
+ section.flags = [cursor readInt32];
+ section.reserved1 = [cursor readInt32];
+ section.reserved2 = [cursor readInt32];
+ section.reserved3 = [cursor readInt32];
+
+ // These aren't guaranteed to be null terminated. Witness __cstring_object in __OBJC segment
+
+ memcpy(buf, section.segname, 16);
+ buf[16] = 0;
+ str = [[NSString alloc] initWithBytes:buf length:strlen(buf) encoding:NSASCIIStringEncoding];
+ [self setSegmentName:str];
+ [str release];
+
+ memcpy(buf, section.sectname, 16);
+ buf[16] = 0;
+ str = [[NSString alloc] initWithBytes:buf length:strlen(buf) encoding:NSASCIIStringEncoding];
+ [self setSectionName:str];
+ [str release];
+
+ return self;
+}
+
+- (CDLCSegment64 *)segment;
+{
+ return nonretained_segment;
+}
+
+- (CDMachOFile *)machOFile;
+{
+ return [[self segment] machOFile];
+}
+
+- (NSUInteger)addr;
+{
+ return section.addr;
+}
+
+- (NSUInteger)size;
+{
+ return section.size;
+}
+
+- (void)loadData;
+{
+ if (_flags.hasLoadedData == NO) {
+ data = [[NSData alloc] initWithBytes:[[nonretained_segment machOFile] machODataBytes] + section.offset length:section.size];
+ _flags.hasLoadedData = YES;
+ }
+}
+
+- (NSString *)description;
+{
+ return [NSString stringWithFormat:@"<%@:%p> segment; '%@', section: '%-16s', addr: %016lx, size: %016lx",
+ NSStringFromClass([self class]), self,
+ segmentName, [sectionName UTF8String],
+ section.addr, section.size];
+}
+
+- (BOOL)containsAddress:(NSUInteger)address;
+{
+ return (address >= section.addr) && (address < section.addr + section.size);
+}
+
+- (NSUInteger)fileOffsetForAddress:(NSUInteger)address;
+{
+ NSParameterAssert([self containsAddress:address]);
+ return section.offset + address - section.addr;
+}
+
+@end
Property changes on: class-dump/src/CDSection64.m
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « class-dump/src/CDSection64.h ('k') | class-dump/src/CDStructureInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698