FreeCalypso > hg > freecalypso-reveng
annotate leo-obj/tool/tables.c @ 193:37f78f986a0a
grokdsn: tree dump implemented
author | Michael Spacefalcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Wed, 07 Jan 2015 08:09:30 +0000 |
parents | fd772de226cb |
children |
rev | line source |
---|---|
71
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This C module will contain functions for the initial parsing |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * of the section and symbol tables. |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/types.h> |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdio.h> |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdlib.h> |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <string.h> |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <strings.h> |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "filestruct.h" |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "intstruct.h" |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "globals.h" |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 extern unsigned get_u16(), get_u32(); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 static char * |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 get_secorsym_name(ptr) |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 u_char *ptr; |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 { |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 char *alloc; |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 if (ptr[0]) { |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 if (ptr[7]) { |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 alloc = malloc(9); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 if (!alloc) { |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 perror("malloc"); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 exit(1); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 } |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 bcopy(ptr, alloc, 8); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 alloc[8] = '\0'; |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 return(alloc); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 } else |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 return((char *) ptr); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 } |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 if (ptr[1] || ptr[2] || ptr[3]) { |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 fprintf(stderr, "error: malformed name in %s at offset 0x%x\n", |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 objfilename, ptr - filemap); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 exit(1); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 } |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 return(filemap + strtab_offset + get_u32(ptr+4)); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 } |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 get_int_section_table() |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 { |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 unsigned n; |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 sections = malloc(sizeof(struct internal_scnhdr) * nsections); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 if (!sections) { |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 perror("malloc"); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 exit(1); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 } |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 for (n = 0; n < nsections; n++) { |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 sections[n].name = get_secorsym_name(sections_raw[n].s_name); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 if (get_u32(sections_raw[n].s_paddr)) |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 fprintf(stderr, |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 "warning: section #%u (%s) has nonzero paddr\n", |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 n, sections[n].name); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 if (get_u32(sections_raw[n].s_vaddr)) |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 fprintf(stderr, |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 "warning: section #%u (%s) has nonzero vaddr\n", |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 n, sections[n].name); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 sections[n].size = get_u32(sections_raw[n].s_size); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 sections[n].data_offset = get_u32(sections_raw[n].s_scnptr); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 sections[n].reloc_offset = get_u32(sections_raw[n].s_relptr); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 sections[n].line_offset = get_u32(sections_raw[n].s_lnnoptr); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 sections[n].nreloc = get_u32(sections_raw[n].s_nreloc); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 sections[n].nlineent = get_u32(sections_raw[n].s_nlnno); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 sections[n].flags = get_u32(sections_raw[n].s_flags); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 if (get_u16(sections_raw[n].s_reserved)) |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 fprintf(stderr, |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 "warning: section #%u (%s): some nonzero value in s_reserved bytes\n", |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 n, sections[n].name); |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 if (get_u16(sections_raw[n].s_page)) |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 fprintf(stderr, |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 "warning: section #%u (%s): some nonzero value in s_page bytes\n", |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 n, sections[n].name); |
80
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
78 sections[n].nsymbols = 0; |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
79 sections[n].sorted_symbols = 0; |
110
e650fdc743fe
tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
80
diff
changeset
|
80 sections[n].int_relocs = 0; |
127
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
81 if (!strncmp(sections[n].name, ".text", 5)) |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
82 sections[n].disasm_mode = DISASM_MODE_CODE; |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
83 else if (!strcmp(sections[n].name, ".const")) |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
84 sections[n].disasm_mode = DISASM_MODE_DATA; |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
85 else if (!strcmp(sections[n].name, ".cinit")) |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
86 sections[n].disasm_mode = DISASM_MODE_DATA; |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
87 else if (!strcmp(sections[n].name, ".data")) |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
88 sections[n].disasm_mode = DISASM_MODE_DATA; |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
89 else if (!strcmp(sections[n].name, ".bss")) |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
90 sections[n].disasm_mode = DISASM_MODE_BSS; |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
91 else |
a314d6aa9bf1
tiobjd: section disasm mode hinting rethought
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
126
diff
changeset
|
92 sections[n].disasm_mode = DISASM_MODE_UNKNOWN; |
126
2c6b1319383b
tiobjd: first preparations for adding disasm hints mechanism
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
116
diff
changeset
|
93 sections[n].hints = 0; |
71
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 } |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 } |
c15cd3d695c0
tiobjd: successful parsing of the section header table
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 |
73
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
97 get_int_symbol_table() |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
98 { |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
99 unsigned n; |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
100 struct internal_syment *in; |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
101 |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
102 symtab = malloc(sizeof(struct internal_syment *) * nsymtab); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
103 if (!symtab) { |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
104 perror("malloc"); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
105 exit(1); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
106 } |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
107 for (n = 0; n < nsymtab; ) { |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
108 in = malloc(sizeof(struct internal_syment)); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
109 if (!in) { |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
110 perror("malloc"); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
111 exit(1); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
112 } |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
113 symtab[n] = in; |
116
5f4141ee175b
tiobjd: retain the original symtab order for symbols at the same position
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
110
diff
changeset
|
114 in->number = n; |
73
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
115 in->name = get_secorsym_name(symtab_raw[n].e_name); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
116 in->value = get_u32(symtab_raw[n].e_value); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
117 in->scnum = get_s16(symtab_raw[n].e_scnum); |
80
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
118 if (in->scnum > 0) { |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
119 if (in->scnum > nsections) { |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
120 fprintf(stderr, |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
121 "symtab entry #%u: scnum too big\n", n); |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
122 exit(1); |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
123 } |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
124 in->section = sections + in->scnum - 1; |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
125 in->section->nsymbols++; |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
126 } else if (in->scnum < -2) { |
73
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
127 fprintf(stderr, |
80
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
128 "symtab entry #%u: scnum < -2\n", n); |
73
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
129 exit(1); |
80
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
130 } else |
da103b9377e3
tiobjd: preparation for symbol sorting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
75
diff
changeset
|
131 in->section = 0; |
73
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
132 in->type = get_u16(symtab_raw[n].e_type); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
133 in->class = symtab_raw[n].e_sclass; |
144
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
130
diff
changeset
|
134 in->struct_name = 0; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
130
diff
changeset
|
135 in->struct_name_raw = 0; |
73
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
136 switch (symtab_raw[n++].e_numaux) { |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
137 case 0: |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
138 in->aux = 0; |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
139 continue; |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
140 case 1: |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
141 if (n >= nsymtab) { |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
142 fprintf(stderr, |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
143 "error: last symbol's aux spills over\n"); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
144 exit(1); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
145 } |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
146 symtab[n] = 0; |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
147 in->aux = (u_char *)(symtab_raw + n); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
148 n++; |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
149 continue; |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
150 default: |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
151 n--; |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
152 fprintf(stderr, "symtab entry #%u: invalid numaux\n", |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
153 n); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
154 exit(1); |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
155 } |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
156 } |
10f3fbff5e97
tiobjd: symbol table parsing implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
71
diff
changeset
|
157 } |