annotate ticoff/disasm.c @ 125:b8ac21536779

tiobjd disasm: bss handling
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 04 Apr 2014 18:56:23 +0000
parents 700d77d5cf00
children 03f8a618689e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
118
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
17 static void
121
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
18 find_better_symbol(sec, symp, addp)
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
19 struct internal_scnhdr *sec;
118
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
20 struct internal_syment **symp;
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
21 unsigned *addp;
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
22 {
120
4d8dfdbd2ea1 tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 118
diff changeset
23 unsigned addr, delta;
4d8dfdbd2ea1 tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 118
diff changeset
24 struct internal_syment *sym;
118
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
25 unsigned n;
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
26
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
27 addr = *addp;
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
28 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
29 sym = sec->sorted_symbols[n];
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
30 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
31 return;
4d8dfdbd2ea1 tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 118
diff changeset
32 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
33 continue;
4d8dfdbd2ea1 tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 118
diff changeset
34 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
35 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
36 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
37 *symp = sym;
4d8dfdbd2ea1 tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 118
diff changeset
38 *addp = delta;
4d8dfdbd2ea1 tiobjd: auto-translation of section-relative relocs made more conservative
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 118
diff changeset
39 }
118
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
40 }
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
41 }
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
42
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 void
112
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
44 disasm_reloc_target(sec, rel, addend)
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
45 struct internal_scnhdr *sec;
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
46 struct internal_reloc *rel;
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
47 unsigned addend;
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
48 {
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
49 struct internal_syment *sym = rel->sym;
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
50
121
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
51 if (sym)
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
52 addend -= sym->value;
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
53 if (!sym || sym->section && !strcmp(sym->name, sym->section->name))
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
54 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
55 if (sym)
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
56 fputs(sym->name, stdout);
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
57 else
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
58 fputs(sec->name, stdout);
112
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
59 if (addend >= 10)
121
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
60 printf("+0x%x", addend);
112
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
61 else if (addend)
121
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 120
diff changeset
62 printf("+%u", addend);
112
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
63 }
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
64
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
65 void
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
66 disasm_word32_reloc(sec, rel)
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
67 struct internal_scnhdr *sec;
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
68 struct internal_reloc *rel;
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 unsigned word;
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
71
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
72 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
73 printf("%08x R\t.word\t", word);
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
74 disasm_reloc_target(sec, rel, word);
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
75 putchar('\n');
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
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
78 void
124
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
79 disasm_end_of_section(sec, symnum)
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
80 struct internal_scnhdr *sec;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
81 unsigned symnum;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
82 {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
83 struct internal_syment *sym;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
84 char *sym_comment;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
85
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
86 putchar('\n');
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
87 while (symnum < sec->nsymbols) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
88 sym = sec->sorted_symbols[symnum];
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
89 if (sym->value != sec->size) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
90 printf("error: expecting symbol at end of section\n");
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
91 return;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
92 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
93 switch (sym->class) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
94 case C_EXT:
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
95 sym_comment = "Global";
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
96 break;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
97 case C_STAT:
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
98 sym_comment = "static";
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
99 break;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
100 case C_LABEL:
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
101 sym_comment = "label";
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
102 break;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
103 default:
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
104 sym_comment = "unexpected class!";
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
105 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
106 printf("%s:\t; %s\n", sym->name, sym_comment);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
107 symnum++;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
108 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
109 printf("%8x:\t<end of section>\n", sec->size);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
110 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
111
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
112 void
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 disasm_text_section(sec)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 struct internal_scnhdr *sec;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 unsigned symnum, relnum;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 unsigned pos, incr, headroom;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 int state = -1, linebrk = 0;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 struct internal_syment *sym;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 struct internal_reloc *rel;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 char *sym_comment;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 printf("Disassembling code section:\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 if (sec->nsymbols)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 sort_symbols_of_sec(sec);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 if (sec->nreloc)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 get_relocs_of_sec(sec);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 symnum = relnum = 0;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 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
130 headroom = sec->size - pos;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 while (symnum < sec->nsymbols) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 sym = sec->sorted_symbols[symnum];
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 if (sym->value > pos) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 if (sym->value - pos < headroom)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 headroom = sym->value - pos;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 break;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 /* hit symbol */
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 if (!linebrk) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 linebrk = 1;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 switch (sym->class) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 case C_EXT:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 sym_comment = "Global";
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 break;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 case C_STAT:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 sym_comment = "static";
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 break;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 case C_LABEL:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 sym_comment = "label";
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 if (!strcmp(sym->name, "$CODE16"))
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 state = 1;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 else if (!strcmp(sym->name, "$CODE32"))
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 state = 0;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 break;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 default:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 sym_comment = "unexpected class!";
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 printf("%s:\t; %s\n", sym->name, sym_comment);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 symnum++;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 if (relnum < sec->nreloc) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 rel = sec->int_relocs + relnum;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 if (rel->location == pos)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 relnum++; /* it's ours */
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 else {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 if (rel->location - pos < headroom)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 headroom = rel->location - pos;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 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
171 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 } else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 rel = 0;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 printf("%8x:\t", pos);
112
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
175 if (rel && rel->type == RTYPE_LONG) {
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
176 if (pos & 3) {
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
177 printf("MISALIGNED pos for word32 reloc, aborting\n");
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
178 return;
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
179 }
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
180 disasm_word32_reloc(sec, rel);
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
181 incr = 4;
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
182 goto next;
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
183 }
123
5f9cc99930a8 tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 121
diff changeset
184 if (pos & 1 || headroom < 2) {
5f9cc99930a8 tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 121
diff changeset
185 if (rel) {
5f9cc99930a8 tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 121
diff changeset
186 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
187 return;
5f9cc99930a8 tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 121
diff changeset
188 }
5f9cc99930a8 tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 121
diff changeset
189 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
190 incr = 1;
5f9cc99930a8 tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 121
diff changeset
191 goto next;
5f9cc99930a8 tiobjd: handling of $CODE16 symbols at byte positions
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 121
diff changeset
192 }
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 switch (state) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 case 0: /* ARM */
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195 if (pos & 3) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 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
197 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 }
114
ca8e43288836 tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 112
diff changeset
199 if (rel) {
ca8e43288836 tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 112
diff changeset
200 if (rel->type != RTYPE_ARM_B) {
ca8e43288836 tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 112
diff changeset
201 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
202 return;
ca8e43288836 tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 112
diff changeset
203 }
ca8e43288836 tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 112
diff changeset
204 arm_branch_reloc(sec, rel);
ca8e43288836 tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 112
diff changeset
205 } else
ca8e43288836 tiobjd: ARM_B reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 112
diff changeset
206 arm_disasm_line(sec, pos);
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 incr = 4;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208 break;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 case 1: /* Thumb */
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 if (pos & 1) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211 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
212 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 }
117
f9fde7f36ae3 tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 114
diff changeset
214 if (rel) {
f9fde7f36ae3 tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 114
diff changeset
215 if (rel->type != RTYPE_THUMB_BL) {
f9fde7f36ae3 tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 114
diff changeset
216 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
217 return;
f9fde7f36ae3 tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 114
diff changeset
218 }
f9fde7f36ae3 tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 114
diff changeset
219 thumb_bl_reloc(sec, rel);
f9fde7f36ae3 tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 114
diff changeset
220 incr = 4;
f9fde7f36ae3 tiobjd: Thumb_BL reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 114
diff changeset
221 } 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
222 incr = 4;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223 else {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 thumb_disasm_line(sec, pos);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 incr = 2;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 break;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228 default:
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 printf("UNKNOWN T state, aborting\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231 }
112
61a58677dc68 tiobjd disasm: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 111
diff changeset
232 next: linebrk = 0;
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 if (incr > headroom) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 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
235 incr, headroom);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236 return;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 }
124
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
239 if (symnum < sec->nsymbols)
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
240 disasm_end_of_section(sec, symnum);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
241 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
242
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
243 void
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
244 disasm_data_section(sec)
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
245 struct internal_scnhdr *sec;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
246 {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
247 unsigned symnum, relnum;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
248 unsigned pos, incr, headroom;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
249 int linebrk = 0;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
250 struct internal_syment *sym;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
251 struct internal_reloc *rel;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
252 char *sym_comment;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
253
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
254 printf("Disassembling data section:\n");
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
255 if (sec->nsymbols)
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
256 sort_symbols_of_sec(sec);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
257 if (sec->nreloc)
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
258 get_relocs_of_sec(sec);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
259 symnum = relnum = 0;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
260 for (pos = 0; pos < sec->size; pos += incr) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
261 headroom = sec->size - pos;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
262 while (symnum < sec->nsymbols) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
263 sym = sec->sorted_symbols[symnum];
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
264 if (sym->value > pos) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
265 if (sym->value - pos < headroom)
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
266 headroom = sym->value - pos;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
267 break;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
268 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
269 /* hit symbol */
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
270 if (!linebrk) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
271 putchar('\n');
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
272 linebrk = 1;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
273 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
274 switch (sym->class) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
275 case C_EXT:
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
276 sym_comment = "Global";
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
277 break;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
278 case C_STAT:
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
279 sym_comment = "static";
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
280 break;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
281 case C_LABEL:
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
282 sym_comment = "label";
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
283 break;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
284 default:
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
285 sym_comment = "unexpected class!";
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
286 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
287 printf("%s:\t; %s\n", sym->name, sym_comment);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
288 symnum++;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
289 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
290 if (relnum < sec->nreloc) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
291 rel = sec->int_relocs + relnum;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
292 if (rel->location == pos)
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
293 relnum++; /* it's ours */
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
294 else {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
295 if (rel->location - pos < headroom)
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
296 headroom = rel->location - pos;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
297 rel = 0; /* no reloc for current pos */
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
298 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
299 } else
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
300 rel = 0;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
301 printf("%8x:\t", pos);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
302 if (rel) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
303 if (rel->type != RTYPE_LONG) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
304 printf("error: reloc other than word32 in data section\n");
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
305 return;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
306 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
307 if (pos & 3) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
308 printf("MISALIGNED pos for word32 reloc, aborting\n");
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
309 return;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
310 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
311 disasm_word32_reloc(sec, rel);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
312 incr = 4;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
313 } else if (pos & 1 || headroom < 2) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
314 printf("%02x\n", filemap[sec->data_offset + pos]);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
315 incr = 1;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
316 } else if (pos & 2 || headroom < 4) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
317 printf("%04x\n",
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
318 get_u16(filemap + sec->data_offset + pos));
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
319 incr = 2;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
320 } else {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
321 printf("%08x\n",
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
322 get_u32(filemap + sec->data_offset + pos));
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
323 incr = 4;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
324 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
325 linebrk = 0;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
326 if (incr > headroom) {
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
327 printf("error: increment %u > headroom %u, aborting\n",
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
328 incr, headroom);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
329 return;
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
330 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
331 }
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
332 if (symnum < sec->nsymbols)
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
333 disasm_end_of_section(sec, symnum);
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 void
125
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
337 disasm_bss(sec)
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
338 struct internal_scnhdr *sec;
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
339 {
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
340 unsigned m;
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
341 struct internal_syment *sym;
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
342 char classbuf[8];
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
343
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
344 putchar('\n');
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
345 for (m = 0; m < sec->nsymbols; m++) {
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
346 sym = sec->sorted_symbols[m];
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
347 printf("%08X %-7s %s\n", sym->value,
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
348 storage_class_to_string(sym->class, classbuf),
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
349 sym->name);
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
350 }
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
351 printf("%08X <end of section>\n", sec->size);
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
352 }
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
353
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
354 void
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
355 disasm_sectype_by_name(sec)
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 struct internal_scnhdr *sec;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
357 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358 if (!strncmp(sec->name, ".text", 5))
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 disasm_text_section(sec);
124
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
360 else if (!strcmp(sec->name, ".const"))
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
361 disasm_data_section(sec);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
362 else if (!strcmp(sec->name, ".cinit"))
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
363 disasm_data_section(sec);
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
364 else if (!strcmp(sec->name, ".data"))
700d77d5cf00 tiobjd disasm: data section handling added
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 123
diff changeset
365 disasm_data_section(sec);
125
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
366 else if (!strcmp(sec->name, ".bss"))
b8ac21536779 tiobjd disasm: bss handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 124
diff changeset
367 disasm_bss(sec);
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368 else
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
369 printf("Unrecognized section type, skipped\n");
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
370 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 cmd_disasm()
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
373 {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 struct internal_scnhdr *sec;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
375 unsigned secnum;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
377 printf("%s:\n", objfilename);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
378 dump_filehdr_info();
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
379 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380 get_int_section_table();
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381 get_int_symbol_table();
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
382 extern_profile_report("Module");
118
193926ccd1ec tiobjd: better handling of section-relative relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 117
diff changeset
383 sort_symbols_of_all_sec();
111
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 for (secnum = 0; secnum < nsections; secnum++) {
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
385 sec = sections + secnum;
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
386 printf("=== %s ===\n", sec->name);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387 disasm_sectype_by_name(sec);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388 putchar('\n');
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 }
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390 exit(0);
0f94d17899b3 tiobjd: disassembly integrated, no relocs or hints yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
391 }