forked from nygard/class-dump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDSymbol.m
72 lines (54 loc) · 1.32 KB
/
CDSymbol.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// 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-2006 Steve Nygard
#import "CDSymbol.h"
#import <mach-o/nlist.h>
#import <mach-o/loader.h>
#import <Foundation/Foundation.h>
#import "CDMachOFile.h"
@implementation CDSymbol
- (id)initWithPointer:(const void *)ptr symtab:(const struct symtab_command *)symtabCommand machOFile:(CDMachOFile *)aMachOFile;
{
const char *str;
if ([super init] == nil)
return nil;
nlist = ptr;
str = [aMachOFile bytesAtOffset:symtabCommand->stroff + nlist->n_un.n_strx];
// TODO (2004-07-08): Not sure of the encoding, UTF-8 might not work.
name = [[NSString alloc] initWithUTF8String:str];
return self;
}
- (void)dealloc;
{
[name release];
[super dealloc];
}
- (long)strx;
{
return nlist->n_type;
}
- (unsigned char)type;
{
return nlist->n_type;
}
- (unsigned char)section;
{
return nlist->n_sect;
}
- (short)desc;
{
return nlist->n_desc;
}
- (unsigned long)value;
{
return nlist->n_value;
}
- (NSString *)name;
{
return name;
}
- (NSString *)description;
{
return [NSString stringWithFormat:@"%08x %02x %02x %04x %08x %@",
nlist->n_value, nlist->n_type, nlist->n_sect, nlist->n_desc, nlist->n_un.n_strx, name];
}
@end