FreeCalypso > hg > freecalypso-reveng
annotate leo-obj/tool/disasm.c @ 221:9f2e0c34fe33
ftmdump (C1xx factory data reverse eng) tool written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 17 Nov 2017 19:58:07 +0000 |
parents | 71e25510f5af |
children |
rev | line source |
---|---|
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Putting it all together: section-, symbol- and reloc-aware disassembly |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "intstruct.h" |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "coffconst.h" |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "globals.h" |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 extern unsigned get_u16(), get_u32(); |
125
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
15 extern char *storage_class_to_string(); |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 |
133
daeaa5950d10
tiobjd: Thumb bl w/o reloc: find symbol if there is one
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
130
diff
changeset
|
17 int auto_xlat_section_relocs = 1; |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
18 int disasm_richsym, disasm_lineno; |
148
13cc7e19ecec
tiobjd disasm -g: support -b as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
147
diff
changeset
|
19 extern int richsym_print_bitsize; |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
20 |
118
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
21 static void |
121
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
22 find_better_symbol(sec, symp, addp) |
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
23 struct internal_scnhdr *sec; |
118
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
24 struct internal_syment **symp; |
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
25 unsigned *addp; |
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
26 { |
120
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
27 unsigned addr, delta; |
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
28 struct internal_syment *sym; |
118
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
29 unsigned n; |
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
30 |
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
31 addr = *addp; |
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
32 for (n = 0; n < sec->nsymbols; n++) { |
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
33 sym = sec->sorted_symbols[n]; |
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
34 if (sym->value > addr) |
120
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
35 return; |
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
36 if (sym->class != C_EXT && sym->class != C_STAT) |
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
37 continue; |
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
38 delta = addr - sym->value; |
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
39 if (sym->name[0] == '_' && !delta || |
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
40 sym->name[0] == '$' && delta <= 1) { |
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
41 *symp = sym; |
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
42 *addp = delta; |
4d8dfdbd2ea1
tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
43 } |
118
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
44 } |
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
45 } |
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
46 |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 void |
112
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
48 disasm_reloc_target(sec, rel, addend) |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
49 struct internal_scnhdr *sec; |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
50 struct internal_reloc *rel; |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
51 unsigned addend; |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
52 { |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
53 struct internal_syment *sym = rel->sym; |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
54 |
121
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
55 if (sym) |
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
56 addend -= sym->value; |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
57 if (auto_xlat_section_relocs && |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
58 (!sym || sym->section && !strcmp(sym->name, sym->section->name))) |
121
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
59 find_better_symbol(sym ? sym->section : sec, &sym, &addend); |
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
60 if (sym) |
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
61 fputs(sym->name, stdout); |
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
62 else |
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
63 fputs(sec->name, stdout); |
112
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
64 if (addend >= 10) |
121
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
65 printf("+0x%x", addend); |
112
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
66 else if (addend) |
121
d88f2f40e3ae
tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
120
diff
changeset
|
67 printf("+%u", addend); |
112
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
68 } |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
69 |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
70 void |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
71 disasm_word32_reloc(sec, rel) |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
72 struct internal_scnhdr *sec; |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
73 struct internal_reloc *rel; |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
74 { |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
75 unsigned word; |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
76 |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
77 word = get_u32(filemap + sec->data_offset + rel->location); |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
78 printf("%08x R\t.word\t", word); |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
79 disasm_reloc_target(sec, rel, word); |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
80 putchar('\n'); |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
81 } |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
82 |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
83 static void |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
84 handle_symbol(sym, statep, linebrkp) |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
85 struct internal_syment *sym; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
86 int *statep, *linebrkp; |
124
700d77d5cf00
tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
123
diff
changeset
|
87 { |
147
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
88 char *sym_comment, *cpref; |
124
700d77d5cf00
tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
123
diff
changeset
|
89 |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
90 if (sym->class == C_FCN && !strcmp(sym->name, ".ef")) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
91 printf("; End function\n"); |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
92 return; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
93 } |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
94 if (!*linebrkp) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
95 putchar('\n'); |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
96 *linebrkp = 1; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
97 } |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
98 if (sym->class == C_FCN && !strcmp(sym->name, ".bf")) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
99 printf("; Begin function\n"); |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
100 if (disasm_richsym) |
151
6fe08feee018
tiobjd disasm -g: line break after function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
150
diff
changeset
|
101 if (richsym_function_locals(sym)) |
6fe08feee018
tiobjd disasm -g: line break after function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
150
diff
changeset
|
102 putchar('\n'); |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
103 return; |
124
700d77d5cf00
tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
123
diff
changeset
|
104 } |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
105 switch (sym->class) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
106 case C_EXT: |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
107 sym_comment = "Global"; |
147
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
108 cpref = "; "; |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
109 break; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
110 case C_STAT: |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
111 sym_comment = "static"; |
147
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
112 cpref = "; static "; |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
113 break; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
114 case C_LABEL: |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
115 sym_comment = "label"; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
116 if (!strcmp(sym->name, "$CODE16")) |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
117 *statep = 1; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
118 else if (!strcmp(sym->name, "$CODE32")) |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
119 *statep = 0; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
120 break; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
121 default: |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
122 sym_comment = "unexpected class!"; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
123 } |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
124 printf("%s:\t; %s\n", sym->name, sym_comment); |
147
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
125 if (!disasm_richsym || sym->class != C_EXT && sym->class != C_STAT) |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
126 return; |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
127 if (!sym->aux || sym->name[0] != '_' && sym->name[0] != '$') |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
128 return; |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
129 richsym_print_in_c(cpref, sym, 0); |
124
700d77d5cf00
tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
123
diff
changeset
|
130 } |
700d77d5cf00
tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
123
diff
changeset
|
131 |
700d77d5cf00
tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
123
diff
changeset
|
132 void |
136
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
133 disasm_emit_asciz(sec, pos, len) |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
134 struct internal_scnhdr *sec; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
135 unsigned pos, len; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
136 { |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
137 int c; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
138 unsigned endpos = pos + len; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
139 |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
140 fputs("\t.asciz\t\"", stdout); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
141 for (; pos < endpos; pos++) { |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
142 c = filemap[sec->data_offset + pos]; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
143 switch (c) { |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
144 case '\b': |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
145 fputs("\\b", stdout); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
146 continue; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
147 case '\t': |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
148 fputs("\\t", stdout); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
149 continue; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
150 case '\n': |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
151 fputs("\\n", stdout); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
152 continue; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
153 case '\r': |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
154 fputs("\\r", stdout); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
155 continue; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
156 case '"': |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
157 fputs("\\\"", stdout); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
158 continue; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
159 case '\\': |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
160 fputs("\\\\", stdout); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
161 continue; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
162 } |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
163 if (c >= ' ' && c <= '~') |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
164 putchar(c); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
165 else |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
166 printf("\\%03o", c); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
167 } |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
168 putchar('"'); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
169 putchar('\n'); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
170 } |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
171 |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
172 void |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
173 disasm_codedata_section(sec) |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 struct internal_scnhdr *sec; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 unsigned symnum, relnum; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 unsigned pos, incr, headroom; |
136
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
178 int state = -1, linebrk = 0, gothint; |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 struct internal_syment *sym; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 struct internal_reloc *rel; |
136
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
181 struct hint *hint = sec->hints; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
182 u_char *asciz_end; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
183 unsigned asciz_len; |
211
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
184 struct internal_lineno *lineno_arr; |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
185 unsigned lineno_cur, lineno_total; |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 if (sec->nreloc) |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 get_relocs_of_sec(sec); |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
189 if (disasm_lineno && sec->nlineent) |
211
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
190 get_lineno_array(sec, &lineno_arr, &lineno_total, |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
191 disasm_lineno >= 2); |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
192 else { |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
193 lineno_arr = 0; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
194 lineno_total = 0; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
195 } |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
196 symnum = relnum = 0; |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
197 lineno_cur = 0; |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 for (pos = 0; pos < sec->size; pos += incr) { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 headroom = sec->size - pos; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 while (symnum < sec->nsymbols) { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
201 sym = sec->sorted_symbols[symnum]; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
202 if (sym->value > pos) { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 if (sym->value - pos < headroom) |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 headroom = sym->value - pos; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 break; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 } |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 /* hit symbol */ |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
208 handle_symbol(sym, &state, &linebrk); |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
209 symnum++; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
210 } |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 if (relnum < sec->nreloc) { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
212 rel = sec->int_relocs + relnum; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
213 if (rel->location == pos) |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
214 relnum++; /* it's ours */ |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
215 else { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 if (rel->location - pos < headroom) |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
217 headroom = rel->location - pos; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
218 rel = 0; /* no reloc for current pos */ |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 } |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 } else |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
221 rel = 0; |
136
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
222 if (hint) { |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
223 if (pos >= hint->pos) |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
224 gothint++; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
225 else { |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
226 gothint = 0; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
227 if (hint->pos - pos < headroom) |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
228 headroom = hint->pos - pos; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
229 } |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
230 } else |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
231 gothint = 0; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
232 if (gothint && pos == hint->pos && hint->linebrk) |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
233 putchar('\n'); |
211
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
234 while (lineno_cur < lineno_total) { |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
235 if (pos >= lineno_arr[lineno_cur].location) { |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
236 if (disasm_lineno >= 2) |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
237 printf("; line %u\n", |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
238 lineno_arr[lineno_cur].lineno); |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
239 else |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
240 puts("; line"); |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
241 lineno_cur++; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
242 } else { |
211
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
243 if (lineno_arr[lineno_cur].location - pos < |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
244 headroom) |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
245 headroom = |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
246 lineno_arr[lineno_cur].location - pos; |
71e25510f5af
tiobjd disasm -ll: show the actual line numbers
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
152
diff
changeset
|
247 break; |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
248 } |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
249 } |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
250 printf("%8x:\t", pos); |
136
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
251 if (gothint && hint->type) { |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
252 if (rel) { |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
253 printf("error: hint/reloc conflict\n"); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
254 return; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
255 } |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
256 switch (hint->type) { |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
257 case HINT_D8: |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
258 printf("%02x\n", |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
259 filemap[sec->data_offset + pos]); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
260 incr = 1; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
261 break; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
262 case HINT_D16: |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
263 printf("%04x\n", |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
264 get_u16(filemap+sec->data_offset+pos)); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
265 incr = 2; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
266 break; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
267 case HINT_D32: |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
268 printf("%08x\n", |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
269 get_u32(filemap+sec->data_offset+pos)); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
270 incr = 4; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
271 break; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
272 case HINT_ASCIZ: |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
273 asciz_end = memchr(filemap+sec->data_offset+pos, |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
274 0, headroom); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
275 if (!asciz_end) { |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
276 printf("bad asciz hint: no 0 found\n"); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
277 return; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
278 } |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
279 asciz_len = asciz_end - filemap - |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
280 sec->data_offset - pos; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
281 disasm_emit_asciz(sec, pos, asciz_len); |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
282 incr = asciz_len + 1; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
283 } |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
284 goto next; |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
285 } |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
286 if (rel) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
287 if (rel->type == RTYPE_LONG) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
288 if (pos & 3) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
289 printf("MISALIGNED pos for word32 reloc, aborting\n"); |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
290 return; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
291 } |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
292 disasm_word32_reloc(sec, rel); |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
293 incr = 4; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
294 goto next; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
295 } else if (sec->disasm_mode == DISASM_MODE_DATA) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
296 printf("error: reloc other than word32 in data section\n"); |
112
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
297 return; |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
298 } |
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
299 } |
123
5f9cc99930a8
tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
121
diff
changeset
|
300 if (pos & 1 || headroom < 2) { |
5f9cc99930a8
tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
121
diff
changeset
|
301 if (rel) { |
5f9cc99930a8
tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
121
diff
changeset
|
302 printf("error: reloc at byte pos, aborting\n"); |
5f9cc99930a8
tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
121
diff
changeset
|
303 return; |
5f9cc99930a8
tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
121
diff
changeset
|
304 } |
5f9cc99930a8
tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
121
diff
changeset
|
305 printf("%02x\n", filemap[sec->data_offset + pos]); |
5f9cc99930a8
tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
121
diff
changeset
|
306 incr = 1; |
5f9cc99930a8
tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
121
diff
changeset
|
307 goto next; |
5f9cc99930a8
tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
121
diff
changeset
|
308 } |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
309 if (sec->disasm_mode == DISASM_MODE_DATA) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
310 if (pos & 2 || headroom < 4) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
311 printf("%04x\n", |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
312 get_u16(filemap+sec->data_offset+pos)); |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
313 incr = 2; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
314 } else { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
315 printf("%08x\n", |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
316 get_u32(filemap+sec->data_offset+pos)); |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
317 incr = 4; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
318 } |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
319 goto next; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
320 } |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
321 switch (state) { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
322 case 0: /* ARM */ |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
323 if (pos & 3) { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
324 printf("MISALIGNED pos in CODE32 state, aborting\n"); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
325 return; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
326 } |
114
ca8e43288836
tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
112
diff
changeset
|
327 if (rel) { |
ca8e43288836
tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
112
diff
changeset
|
328 if (rel->type != RTYPE_ARM_B) { |
ca8e43288836
tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
112
diff
changeset
|
329 printf("Wrong reloc type in CODE32 state, aborting\n"); |
ca8e43288836
tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
112
diff
changeset
|
330 return; |
ca8e43288836
tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
112
diff
changeset
|
331 } |
ca8e43288836
tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
112
diff
changeset
|
332 arm_branch_reloc(sec, rel); |
ca8e43288836
tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
112
diff
changeset
|
333 } else |
ca8e43288836
tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
112
diff
changeset
|
334 arm_disasm_line(sec, pos); |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
335 incr = 4; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
336 break; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
337 case 1: /* Thumb */ |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
338 if (pos & 1) { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
339 printf("MISALIGNED pos in CODE16 state, aborting\n"); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
340 return; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
341 } |
117
f9fde7f36ae3
tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
114
diff
changeset
|
342 if (rel) { |
f9fde7f36ae3
tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
114
diff
changeset
|
343 if (rel->type != RTYPE_THUMB_BL) { |
f9fde7f36ae3
tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
114
diff
changeset
|
344 printf("Wrong reloc type in CODE16 state, aborting\n"); |
f9fde7f36ae3
tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
114
diff
changeset
|
345 return; |
f9fde7f36ae3
tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
114
diff
changeset
|
346 } |
f9fde7f36ae3
tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
114
diff
changeset
|
347 thumb_bl_reloc(sec, rel); |
f9fde7f36ae3
tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
114
diff
changeset
|
348 incr = 4; |
f9fde7f36ae3
tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
114
diff
changeset
|
349 } else if (headroom >= 4 && thumb_check_bl(sec, pos)) |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
350 incr = 4; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
351 else { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
352 thumb_disasm_line(sec, pos); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
353 incr = 2; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
354 } |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
355 break; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
356 default: |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
357 printf("UNKNOWN T state, aborting\n"); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
358 return; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
359 } |
112
61a58677dc68
tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
111
diff
changeset
|
360 next: linebrk = 0; |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
361 if (incr > headroom) { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
362 printf("error: increment %u > headroom %u, aborting\n", |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
363 incr, headroom); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
364 return; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
365 } |
136
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
366 if (hint && pos >= hint->endpos) |
81fc8da9a29c
tiobjd: disasm hints work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
135
diff
changeset
|
367 hint = hint->next; |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
368 } |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
369 while (symnum < sec->nsymbols) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
370 sym = sec->sorted_symbols[symnum]; |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
371 if (sym->value != sec->size) { |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
372 printf("error: expecting symbol at end of section\n"); |
124
700d77d5cf00
tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
123
diff
changeset
|
373 return; |
700d77d5cf00
tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
123
diff
changeset
|
374 } |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
375 handle_symbol(sym, &state, &linebrk); |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
376 symnum++; |
124
700d77d5cf00
tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
123
diff
changeset
|
377 } |
139
acdf75463e30
tiobjd disasm: smarter logic for when the <end of section> line
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
136
diff
changeset
|
378 if (linebrk) |
acdf75463e30
tiobjd disasm: smarter logic for when the <end of section> line
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
136
diff
changeset
|
379 printf("%8x:\t<end of section>\n", sec->size); |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
380 if (lineno_arr) |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
381 free(lineno_arr); |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
382 } |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
383 |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
384 void |
125
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
385 disasm_bss(sec) |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
386 struct internal_scnhdr *sec; |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
387 { |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
388 unsigned m; |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
389 struct internal_syment *sym; |
147
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
390 char classbuf[8], *cpref; |
125
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
391 |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
392 putchar('\n'); |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
393 for (m = 0; m < sec->nsymbols; m++) { |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
394 sym = sec->sorted_symbols[m]; |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
395 printf("%08X %-7s %s\n", sym->value, |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
396 storage_class_to_string(sym->class, classbuf), |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
397 sym->name); |
147
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
398 if (!disasm_richsym || !sym->aux || sym->name[0] != '_') |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
399 continue; |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
400 switch (sym->class) { |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
401 case C_EXT: |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
402 cpref = "; "; |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
403 break; |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
404 case C_STAT: |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
405 cpref = "; static "; |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
406 break; |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
407 default: |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
408 continue; |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
409 } |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
410 richsym_print_in_c(cpref, sym, 0); |
125
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
411 } |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
412 printf("%08X <end of section>\n", sec->size); |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
413 } |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
414 |
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
415 void |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
416 disasm_sec_by_type(sec) |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
417 struct internal_scnhdr *sec; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
418 { |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
419 switch (sec->disasm_mode) { |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
420 case DISASM_MODE_CODE: |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
421 printf("Disassembling code section:\n"); |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
422 disasm_codedata_section(sec); |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
423 return; |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
424 case DISASM_MODE_DATA: |
135
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
425 printf("Disassembling data section:\n"); |
df432a4b1b84
tiobjd: disasm of code and data sections unified
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
133
diff
changeset
|
426 disasm_codedata_section(sec); |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
427 return; |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
428 case DISASM_MODE_BSS: |
125
b8ac21536779
tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
124
diff
changeset
|
429 disasm_bss(sec); |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
430 return; |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
431 default: |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
432 printf("Unrecognized section type, skipped\n"); |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
433 } |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
434 } |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
435 |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
436 cmd_disasm(argc, argv) |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
437 char **argv; |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
438 { |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
439 extern char *optarg; |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
440 char *hintsfile = 0; |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
441 struct internal_scnhdr *sec; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
442 unsigned secnum; |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
443 int c; |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
444 |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
445 while ((c = getopt(argc, argv, "bgh:ls")) != EOF) |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
446 switch (c) { |
148
13cc7e19ecec
tiobjd disasm -g: support -b as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
147
diff
changeset
|
447 case 'b': |
13cc7e19ecec
tiobjd disasm -g: support -b as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
147
diff
changeset
|
448 richsym_print_bitsize++; |
13cc7e19ecec
tiobjd disasm -g: support -b as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
147
diff
changeset
|
449 continue; |
147
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
450 case 'g': |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
451 disasm_richsym++; |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
452 continue; |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
453 case 'h': |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
454 hintsfile = optarg; |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
455 continue; |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
456 case 'l': |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
457 disasm_lineno++; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
458 continue; |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
459 case 's': |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
460 auto_xlat_section_relocs = 0; |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
461 continue; |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
462 default: |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
463 /* error msg already printed */ |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
464 exit(1); |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
465 } |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
466 |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
467 printf("%s:\n", objfilename); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
468 dump_filehdr_info(); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
469 putchar('\n'); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
470 get_int_section_table(); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
471 get_int_symbol_table(); |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
472 if (hintsfile) |
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
473 read_hints_file(hintsfile); |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
474 extern_profile_report("Module"); |
118
193926ccd1ec
tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
117
diff
changeset
|
475 sort_symbols_of_all_sec(); |
147
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
476 if (disasm_richsym) |
1e1815a6d701
tiobjd: beginning of disasm -g
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
139
diff
changeset
|
477 richsym_initial_preen(); |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
478 for (secnum = 0; secnum < nsections; secnum++) { |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
479 sec = sections + secnum; |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
480 printf("=== %s ===\n", sec->name); |
128
03f8a618689e
tiobjd disasm: initial hook-in of the hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
125
diff
changeset
|
481 disasm_sec_by_type(sec); |
111
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
482 putchar('\n'); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
483 } |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
484 exit(0); |
0f94d17899b3
tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
485 } |