-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurgeon.h
More file actions
68 lines (48 loc) · 1.04 KB
/
Copy pathsurgeon.h
File metadata and controls
68 lines (48 loc) · 1.04 KB
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
enum {
IS_DEFINED = 1,
IS_STRONG = 2,
IS_WEAK = 4,
MAKE_STRONG = 0x10,
MAKE_WEAK = 0x20,
MAKE_ENTRY = 0x40,
IS_STAR = 0x4000,
};
enum {
SEG_DELETE = 1,
SEG_KIND = 2,
SEG_LOADNAME = 4,
};
typedef struct hash_entry {
struct hash_entry *next;
unsigned hash_value;
unsigned bits;
char name[];
} hash_entry;
// TODO -- namelist could have a link to the corresponding hash_entry to save a lookup.
typedef struct name_list {
struct name_list *next;
char name[];
} name_list;
typedef struct seg_list {
struct seg_list *next;
struct name_list *alias;
struct name_list *strong;
struct name_list *weak;
unsigned bits;
unsigned kind;
char loadname[12]; // actually 10 bytes but we 0-terminate, +1 for padding.
char name[];
} seg_list;
void *xmalloc(unsigned size);
struct seg_list *parse_file(FILE *f);
enum {
// omf header displacements i care about
o_byte_count = 0,
o_label_length = 0x0d,
o_number_length = 0x0e,
o_version = 0x0f,
o_kind = 0x14,
o_number_sex = 0x20,
o_displacement_name = 0x28,
o_displacement_data = 0x2a
};