forked from ddeville/class-dump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDLCFunctionStarts.m
35 lines (28 loc) · 1010 Bytes
/
CDLCFunctionStarts.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// -*- 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-2014 Steve Nygard.
#import "CDLCFunctionStarts.h"
#import "ULEB128.h"
@implementation CDLCFunctionStarts
{
NSArray *_functionStarts;
}
#pragma mark -
- (NSArray *)functionStarts;
{
if (_functionStarts == nil) {
NSData *functionStartsData = [self linkeditData];
const uint8_t *start = (uint8_t *)[functionStartsData bytes];
const uint8_t *end = start + [functionStartsData length];
uint64_t startAddress;
uint64_t previousAddress = 0;
NSMutableArray *functionStarts = [[NSMutableArray alloc] init];
while ((startAddress = read_uleb128(&start, end))) {
[functionStarts addObject:@(startAddress + previousAddress)];
previousAddress += startAddress;
}
_functionStarts = [functionStarts copy];
}
return _functionStarts;
}
@end