Merge branch 'master' of https://github.com/emonti/class-dump into emonti-master
diff --git a/Source/CDMachOFile.h b/Source/CDMachOFile.h
index 992d694..ac5c402 100644
--- a/Source/CDMachOFile.h
+++ b/Source/CDMachOFile.h
@@ -51,6 +51,7 @@
- (NSString *)filetypeDescription;
- (NSString *)flagDescription;
+- (CDLCSegment *)dataConstSegment;
- (CDLCSegment *)segmentWithName:(NSString *)segmentName;
- (CDLCSegment *)segmentContainingAddress:(NSUInteger)address;
- (NSString *)stringAtAddress:(NSUInteger)address;
diff --git a/Source/CDMachOFile.m b/Source/CDMachOFile.m
index 1dab86f..7f0a15f 100644
--- a/Source/CDMachOFile.m
+++ b/Source/CDMachOFile.m
@@ -279,6 +279,19 @@
#pragma mark -
+- (CDLCSegment *)dataConstSegment
+{
+ // macho objects from iOS 9 appear to store various sections
+ // in __DATA_CONST that were previously found in __DATA
+ CDLCSegment *seg = [self segmentWithName:@"__DATA_CONST"];
+
+ // Fall back on __DATA if it is not found for earlier behavior
+ if (!seg) {
+ seg = [self segmentWithName:@"__DATA"];
+ }
+ return seg;
+}
+
- (CDLCSegment *)segmentWithName:(NSString *)segmentName;
{
for (id loadCommand in _loadCommands) {
@@ -558,7 +571,7 @@
// 0xced: @gparker I was hoping for a flag, but that will do it, thanks.
// 0xced: @gparker Did you mean __DATA,__objc_imageinfo instead of __DATA,__objc_info ?
// gparker: @0xced Yes, it's __DATA,__objc_imageinfo.
- return [[self segmentWithName:@"__DATA"] sectionWithName:@"__objc_imageinfo"] != nil;
+ return [[self dataConstSegment] sectionWithName:@"__objc_imageinfo"] != nil;
}
- (Class)processorClass;
diff --git a/Source/CDObjectiveC2Processor.m b/Source/CDObjectiveC2Processor.m
index fe21a73..0efc715 100644
--- a/Source/CDObjectiveC2Processor.m
+++ b/Source/CDObjectiveC2Processor.m
@@ -27,7 +27,7 @@
- (void)loadProtocols;
{
- CDSection *section = [[self.machOFile segmentWithName:@"__DATA"] sectionWithName:@"__objc_protolist"];
+ CDSection *section = [[self.machOFile dataConstSegment] sectionWithName:@"__objc_protolist"];
CDMachOFileDataCursor *cursor = [[CDMachOFileDataCursor alloc] initWithSection:section];
while ([cursor isAtEnd] == NO)
@@ -36,7 +36,7 @@
- (void)loadClasses;
{
- CDSection *section = [[self.machOFile segmentWithName:@"__DATA"] sectionWithName:@"__objc_classlist"];
+ CDSection *section = [[self.machOFile dataConstSegment] sectionWithName:@"__objc_classlist"];
CDMachOFileDataCursor *cursor = [[CDMachOFileDataCursor alloc] initWithSection:section];
while ([cursor isAtEnd] == NO) {
@@ -50,7 +50,7 @@
- (void)loadCategories;
{
- CDSection *section = [[self.machOFile segmentWithName:@"__DATA"] sectionWithName:@"__objc_catlist"];
+ CDSection *section = [[self.machOFile dataConstSegment] sectionWithName:@"__objc_catlist"];
CDMachOFileDataCursor *cursor = [[CDMachOFileDataCursor alloc] initWithSection:section];
while ([cursor isAtEnd] == NO) {
@@ -490,7 +490,7 @@
- (CDSection *)objcImageInfoSection;
{
- return [[self.machOFile segmentWithName:@"__DATA"] sectionWithName:@"__objc_imageinfo"];
+ return [[self.machOFile dataConstSegment] sectionWithName:@"__objc_imageinfo"];
}
@end