FreeCalypso > hg > freecalypso-reveng
annotate leo-obj/tool/ln.c @ 198:30ba25056ecd
pirelli/rfcal: Rx agcparams and calchan were swapped
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Tue, 12 May 2015 20:38:15 +0000 |
parents | fcf1ef773a57 |
children | 71e25510f5af |
rev | line source |
---|---|
143
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Dumping of line number records |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include "filestruct.h" |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include "intstruct.h" |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "coffconst.h" |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "globals.h" |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 extern unsigned get_u16(), get_u32(); |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 cmd_ln() |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 { |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 unsigned n, m; |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 struct internal_scnhdr *sec; |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 u_char *rec; |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 get_int_section_table(); |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 for (n = 0; n < nsections; n++) { |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 sec = sections + n; |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 if (!sec->nlineent) |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 continue; |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 printf("%s:\n\n", sec->name); |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 rec = filemap + sec->line_offset; |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 for (m = 0; m < sec->nlineent; m++, rec += 6) |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 printf("%08X %04X\n", get_u32(rec), get_u16(rec + 4)); |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 putchar('\n'); |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 } |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 exit(0); |
fbdb7686a9e9
tiobjd: raw dump of line number records implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 } |
152
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
34 |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
35 get_lineno_addrs(sec, arr_rtn, count_rtn) |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
36 struct internal_scnhdr *sec; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
37 unsigned **arr_rtn, *count_rtn; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
38 { |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
39 unsigned *array, cur, last; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
40 unsigned n, m; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
41 u_char *rec; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
42 |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
43 array = malloc(sizeof(unsigned) * sec->nlineent); |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
44 if (!array) { |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
45 perror("malloc"); |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
46 exit(1); |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
47 } |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
48 m = 0; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
49 rec = filemap + sec->line_offset; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
50 for (n = 0; n < sec->nlineent; n++, rec += 6) { |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
51 if (!get_u16(rec + 4)) |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
52 continue; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
53 cur = get_u32(rec); |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
54 if (m) { |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
55 if (cur < last) { |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
56 fprintf(stderr, |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
57 "error: line # addresses in section %s going backward\n", |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
58 sec->name); |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
59 exit(1); |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
60 } |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
61 if (cur == last) |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
62 continue; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
63 } |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
64 array[m++] = cur; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
65 last = cur; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
66 } |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
67 *arr_rtn = array; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
68 *count_rtn = m; |
fcf1ef773a57
tiobjd disasm: implemented -l option to show line markers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
143
diff
changeset
|
69 } |