annotate blobstat/grokmap.c @ 408:14302e075f37 default tip

hr-bits: further conditionalize SID-1-diff
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 22 Jul 2024 10:06:38 +0000
parents 99f72069d867
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <ctype.h>
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <string.h>
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <strings.h>
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "struct.h"
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 extern struct libentry *libentry_list;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 static FILE *mapfile;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 static char linebuf[1024];
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 static int lineno;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 static char *filename_for_errs;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 static struct category *
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 find_category_of_object(libname, member)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char *libname, *member;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 struct libentry *p;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 for (p = libentry_list; p; p = p->next) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (strcmp(p->libname, libname))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 continue;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (!p->member || !strcmp(p->member, member))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 return(p->cat);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 return(0);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 static void
294
ff2a6433687f blobstat: code finished, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 293
diff changeset
32 get_line()
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 char *cp;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (!fgets(linebuf, sizeof linebuf, mapfile)) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 fprintf(stderr, "%s: premature EOF\n", filename_for_errs);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 exit(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 lineno++;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 cp = index(linebuf, '\n');
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (!cp) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 fprintf(stderr, "%s line %d: too long or unterminated\n",
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 filename_for_errs, lineno);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 exit(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (cp > linebuf && cp[-1] == '\r')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 *--cp = '\0';
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 static
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 valid_section_name_char(c, first)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 if (isalpha(c) || c == '_' || c == '.' || c == '$')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 return(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 else if (isdigit(c) && !first)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 return(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 else
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 return(0);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 static
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 parse_input_section_line(libnameout, memberout)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 char *libnameout, **memberout;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 int i;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 char *cp;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 for (i = 0; i < 18; i++)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 if (linebuf[i] != ' ') {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 inv_input_sec_line: fprintf(stderr,
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 "%s line %d: invalid input section line\n",
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 filename_for_errs, lineno);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 exit(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 while (i < 26)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 if (!isxdigit(linebuf[i++]))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 goto inv_input_sec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 while (i < 30)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 if (linebuf[i++] != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 goto inv_input_sec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 while (i < 38)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (!isxdigit(linebuf[i++]))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 goto inv_input_sec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 while (i < 43)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 if (linebuf[i++] != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 goto inv_input_sec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 if (isalpha(linebuf[43])) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 cp = linebuf + 43;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 while (isalnum(*cp) || *cp == '_')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 cp++;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 if (strncmp(cp, ".lib : ", 7))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 return(0);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 cp += 4;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 *cp++ = '\0';
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 strcpy(libnameout, linebuf + 43);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 cp += 2;
295
99f72069d867 blobstat: actually works now
Mychaela Falconia <falcon@freecalypso.org>
parents: 294
diff changeset
98 if (!isalnum(*cp) && *cp != '_')
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 goto inv_input_sec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 *memberout = cp;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 while (isalnum(*cp) || *cp == '_' || *cp == '.')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 cp++;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 if (*cp != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 goto inv_input_sec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 *cp = '\0';
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 return(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 } else if (linebuf[43] == ' ') {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 cp = linebuf + 43;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 while (*cp == ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 cp++;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 if (*cp++ != ':')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 goto inv_input_sec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 if (*cp++ != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 goto inv_input_sec_line;
295
99f72069d867 blobstat: actually works now
Mychaela Falconia <falcon@freecalypso.org>
parents: 294
diff changeset
115 if (!isalnum(*cp) && *cp != '_')
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 goto inv_input_sec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 *memberout = cp;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 while (isalnum(*cp) || *cp == '_' || *cp == '.')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 cp++;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 if (*cp != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 goto inv_input_sec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 *cp = '\0';
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 return(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 } else
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 return(0);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 static
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 process_output_section()
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 int c, i;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 int uninit;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 char libname[1024], *member;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 struct category *cat;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135
294
ff2a6433687f blobstat: code finished, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 293
diff changeset
136 get_line();
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 if (!linebuf[0])
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 return(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 if (!valid_section_name_char(linebuf[0], 1)) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 inv_outsec_line:
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 fprintf(stderr,
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 "%s line %d: invalid output section beginning line\n",
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 filename_for_errs, lineno);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 exit(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 for (i = 1; ; i++) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 c = linebuf[i];
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 if (c == '\0' || c == ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 break;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 if (!valid_section_name_char(c, 0))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 if (!c) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 if (i < 8)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 goto inv_outsec_line;
294
ff2a6433687f blobstat: code finished, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 293
diff changeset
156 get_line();
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 for (i = 0; i < 8; i++)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 if (linebuf[i] != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 } else {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 if (i > 7)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 for (; i < 8; i++)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 if (linebuf[i] != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 if (linebuf[i++] != '0')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 while (i < 13)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 if (linebuf[i++] != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 while (i < 21)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 if (!isxdigit(linebuf[i++]))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 while (i < 25)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 if (linebuf[i++] != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 while (i < 33)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 if (!isxdigit(linebuf[i++]))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 while (i < 38)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 if (linebuf[i++] != ' ')
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 goto inv_outsec_line;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 uninit = !strcmp(linebuf + 38, "UNINITIALIZED");
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 /* input section lines */
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 libname[0] = '\0';
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 for (;;) {
294
ff2a6433687f blobstat: code finished, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 293
diff changeset
188 get_line();
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 if (!linebuf[0])
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 break;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 if (!parse_input_section_line(libname, &member))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 continue;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 if (!libname[0]) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 fprintf(stderr, "%s line %d: missing library name\n",
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 filename_for_errs, lineno);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 exit(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 cat = find_category_of_object(libname, member);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 if (!cat) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 fprintf(stderr, "%s line %d: unknown library object\n",
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 filename_for_errs, lineno);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 exit(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 if (!uninit)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 cat->accum += strtoul(linebuf + 30, 0, 16);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 return(0);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 process_map_file(filename)
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 char *filename;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 filename_for_errs = filename;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 mapfile = fopen(filename, "r");
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 if (!mapfile) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 perror(filename);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 exit(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 }
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 do
294
ff2a6433687f blobstat: code finished, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 293
diff changeset
220 get_line();
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 while (strcmp(linebuf, "SECTION ALLOCATION MAP"));
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 /* 4 fixed info lines */
294
ff2a6433687f blobstat: code finished, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 293
diff changeset
223 get_line();
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 if (linebuf[0]) {
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 bad_sectionmap_hdr:
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 fprintf(stderr,
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 "%s line %d: wrong lines after SECTION ALLOCATION MAP\n",
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 filename_for_errs, lineno);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 exit(1);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 }
294
ff2a6433687f blobstat: code finished, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 293
diff changeset
231 get_line();
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 if (strcmp(linebuf,
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 " output attributes/"))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 goto bad_sectionmap_hdr;
294
ff2a6433687f blobstat: code finished, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 293
diff changeset
235 get_line();
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 if (strcmp(linebuf,
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 "section page origin length input sections"))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 goto bad_sectionmap_hdr;
294
ff2a6433687f blobstat: code finished, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 293
diff changeset
239 get_line();
293
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 if (strcmp(linebuf,
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 "-------- ---- ---------- ---------- ----------------"))
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 goto bad_sectionmap_hdr;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 while (!process_output_section())
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 ;
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 fclose(mapfile);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 return(0);
23e5b940cb8b blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 }