annotate old-trunk/lwlink/link.c @ 354:60568b123281

Added os9 opcodes and ERROR
author lost@starbug
date Tue, 30 Mar 2010 23:10:01 -0600
parents eb230fa7d28e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
1 /*
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
2 link.c
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
3 Copyright © 2009 William Astle
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
4
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
5 This file is part of LWLINK.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
6
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
7 LWLINK is free software: you can redistribute it and/or modify it under the
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
10 version.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
11
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
15 more details.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
16
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
19
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
20
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
21 Resolve section and symbol addresses; handle incomplete references
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
22 */
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
23
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
24 #include <config.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
25
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
26 #include <stdio.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
27 #include <stdlib.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
28
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
29 #include "expr.h"
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
30 #include "lwlink.h"
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
31 #include "util.h"
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
32
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
33 struct section_list *sectlist = NULL;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
34 int nsects = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
35 static int nforced = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
36
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
37 void check_section_name(char *name, int *base, fileinfo_t *fn)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
38 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
39 int sn;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
40
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
41 if (fn -> forced == 0)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
42 return;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
43
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
44 for (sn = 0; sn < fn -> nsections; sn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
45 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
46 if (!strcmp(name, fn -> sections[sn].name))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
47 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
48 // we have a match
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
49 sectlist = lw_realloc(sectlist, sizeof(struct section_list) * (nsects + 1));
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
50 sectlist[nsects].ptr = &(fn -> sections[sn]);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
51
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
52 fn -> sections[sn].processed = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
53 fn -> sections[sn].loadaddress = *base;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
54 *base += fn -> sections[sn].codesize;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
55 nsects++;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
56 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
57 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
58 for (sn = 0; sn < fn -> nsubs; sn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
59 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
60 check_section_name(name, base, fn -> subs[sn]);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
61 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
62 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
63
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
64 void add_matching_sections(char *name, int yesflags, int noflags, int *base);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
65 void check_section_flags(int yesflags, int noflags, int *base, fileinfo_t *fn)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
66 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
67 int sn;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
68
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
69 if (fn -> forced == 0)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
70 return;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
71
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
72 for (sn = 0; sn < fn -> nsections; sn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
73 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
74 // ignore if the noflags tell us to
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
75 if (noflags && (fn -> sections[sn].flags & noflags))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
76 continue;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
77 // ignore unless the yesflags tell us not to
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
78 if (yesflags && (fn -> sections[sn].flags & yesflags == 0))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
79 continue;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
80 // ignore it if already processed
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
81 if (fn -> sections[sn].processed)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
82 continue;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
83
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
84 // we have a match - now collect *all* sections of the same name!
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
85 add_matching_sections(fn -> sections[sn].name, 0, 0, base);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
86
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
87 // and then continue looking for sections
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
88 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
89 for (sn = 0; sn < fn -> nsubs; sn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
90 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
91 check_section_flags(yesflags, noflags, base, fn -> subs[sn]);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
92 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
93 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
94
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
95
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
96
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
97 void add_matching_sections(char *name, int yesflags, int noflags, int *base)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
98 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
99 int fn;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
100 if (name)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
101 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
102 // named section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
103 // look for all instances of a section by the specified name
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
104 // and resolve base addresses and add to the list
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
105 for (fn = 0; fn < ninputfiles; fn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
106 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
107 check_section_name(name, base, inputfiles[fn]);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
108 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
109 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
110 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
111 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
112 // wildcard section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
113 // named section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
114 // look for all instances of a section by the specified name
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
115 // and resolve base addresses and add to the list
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
116 for (fn = 0; fn < ninputfiles; fn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
117 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
118 check_section_flags(yesflags, noflags, base, inputfiles[fn]);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
119 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
120 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
121 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
122
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
123 // work out section load order and resolve base addresses for each section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
124 // make a list of sections to load in order
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
125 void resolve_sections(void)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
126 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
127 int laddr = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
128 int ln, sn, fn;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
129
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
130 for (ln = 0; ln < linkscript.nlines; ln++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
131 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
132 if (linkscript.lines[ln].loadat >= 0)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
133 laddr = linkscript.lines[ln].loadat;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
134 add_matching_sections(linkscript.lines[ln].sectname, linkscript.lines[ln].yesflags, linkscript.lines[ln].noflags, &laddr);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
135
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
136 if (linkscript.lines[ln].sectname)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
137 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
138 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
139 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
140 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
141 // wildcard section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
142 // look for all sections not yet processed that match flags
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
143
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
144 int f = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
145 int fn0, sn0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
146 char *sname;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
147
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
148 // named section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
149 // look for all instances of a section by the specified name
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
150 // and resolve base addresses and add to the list
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
151 for (fn0 = 0; fn0 < ninputfiles; fn0++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
152 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
153 for (sn0 = 0; sn0 < inputfiles[fn0] -> nsections; sn0++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
154 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
155 // ignore if the "no flags" bit says to
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
156 if (linkscript.lines[ln].noflags && (inputfiles[fn0] -> sections[sn0].flags & linkscript.lines[ln].noflags))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
157 continue;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
158 // ignore unless the yes flags tell us not to
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
159 if (linkscript.lines[ln].yesflags && (inputfiles[fn0] -> sections[sn0].flags & linkscript.lines[ln].yesflags == 0))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
160 continue;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
161 if (inputfiles[fn0] -> sections[sn0].processed == 0)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
162 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
163 sname = inputfiles[fn0] -> sections[sn0].name;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
164 for (fn = 0; fn < ninputfiles; fn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
165 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
166 for (sn = 0; sn < inputfiles[fn] -> nsections; sn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
167 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
168 if (!strcmp(sname, inputfiles[fn] -> sections[sn].name))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
169 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
170 // we have a match
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
171 sectlist = lw_realloc(sectlist, sizeof(struct section_list) * (nsects + 1));
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
172 sectlist[nsects].ptr = &(inputfiles[fn] -> sections[sn]);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
173
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
174 inputfiles[fn] -> sections[sn].processed = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
175 if (!f && linkscript.lines[ln].loadat >= 0)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
176 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
177 f = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
178 sectlist[nsects].forceaddr = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
179 laddr = linkscript.lines[ln].loadat;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
180 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
181 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
182 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
183 sectlist[nsects].forceaddr = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
184 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
185 inputfiles[fn] -> sections[sn].loadaddress = laddr;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
186 laddr += inputfiles[fn] -> sections[sn].codesize;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
187 nsects++;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
188 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
189 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
190 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
191 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
192 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
193 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
194 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
195 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
196
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
197 // theoretically, all the base addresses are set now
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
198 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
199
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
200 lw_expr_stack_t *find_external_sym_recurse(char *sym, fileinfo_t *fn)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
201 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
202 int sn;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
203 lw_expr_stack_t *r;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
204 lw_expr_term_t *term;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
205 symtab_t *se;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
206 int val;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
207
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
208 for (sn = 0; sn < fn -> nsections; sn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
209 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
210 for (se = fn -> sections[sn].exportedsyms; se; se = se -> next)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
211 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
212 if (!strcmp(sym, se -> sym))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
213 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
214 if (!(fn -> forced))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
215 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
216 fn -> forced = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
217 nforced = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
218 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
219 val = se -> offset + fn -> sections[sn].loadaddress;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
220 r = lw_expr_stack_create();
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
221 term = lw_expr_term_create_int(val & 0xffff);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
222 lw_expr_stack_push(r, term);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
223 lw_expr_term_free(term);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
224 return r;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
225 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
226 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
227 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
228
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
229 for (sn = 0; sn < fn -> nsubs; sn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
230 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
231 r = find_external_sym_recurse(sym, fn -> subs[sn]);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
232 if (r)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
233 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
234 if (!(fn -> forced))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
235 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
236 nforced = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
237 fn -> forced = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
238 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
239 return r;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
240 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
241 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
242 return NULL;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
243 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
244
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
245 // resolve all incomplete references now
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
246 // anything that is unresolvable at this stage will throw an error
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
247 // because we know the load address of every section now
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
248 lw_expr_stack_t *resolve_sym(char *sym, int symtype, void *state)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
249 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
250 section_t *sect = state;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
251 lw_expr_term_t *term;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
252 int val = 0, i, fn;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
253 lw_expr_stack_t *s;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
254 symtab_t *se;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
255 fileinfo_t *fp;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
256
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
257 if (symtype == 1)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
258 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
259 // local symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
260 if (!sym)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
261 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
262 val = sect -> loadaddress;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
263 goto out;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
264 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
265
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
266 // start with this section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
267 for (se = sect -> localsyms; se; se = se -> next)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
268 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
269 if (!strcmp(se -> sym, sym))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
270 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
271 val = se -> offset + sect -> loadaddress;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
272 goto out;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
273 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
274 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
275 // not in this section - check all sections in this file
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
276 for (i = 0; i < sect -> file -> nsections; i++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
277 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
278 for (se = sect -> file -> sections[i].localsyms; se; se = se -> next)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
279 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
280 if (!strcmp(se -> sym, sym))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
281 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
282 val = se -> offset + sect -> file -> sections[i].loadaddress;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
283 goto out;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
284 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
285 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
286 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
287 // not found
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
288 symerr = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
289 fprintf(stderr, "Local symbol %s not found in %s:%s\n", sym, sect -> file -> filename, sect -> name);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
290 goto outerr;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
291 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
292 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
293 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
294 // external symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
295 // read all files in order until found (or not found)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
296 if (sect)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
297 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
298 for (fp = sect -> file; fp; fp = fp -> parent)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
299 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
300 s = find_external_sym_recurse(sym, fp);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
301 if (s)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
302 return s;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
303 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
304 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
305
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
306 for (fn = 0; fn < ninputfiles; fn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
307 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
308 s = find_external_sym_recurse(sym, inputfiles[fn]);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
309 if (s)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
310 return s;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
311 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
312 if (sect)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
313 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
314 fprintf(stderr, "External symbol %s not found in %s:%s\n", sym, sect -> file -> filename, sect -> name);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
315 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
316 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
317 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
318 fprintf(stderr, "External symbol %s not found\n", sym);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
319 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
320 symerr = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
321 goto outerr;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
322 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
323 fprintf(stderr, "Shouldn't ever get here!!!\n");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
324 exit(88);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
325 out:
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
326 s = lw_expr_stack_create();
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
327 term = lw_expr_term_create_int(val & 0xffff);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
328 lw_expr_stack_push(s, term);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
329 lw_expr_term_free(term);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
330 return s;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
331 outerr:
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
332 return NULL;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
333 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
334
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
335 void resolve_references(void)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
336 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
337 int sn;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
338 reloc_t *rl;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
339 int rval;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
340
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
341 // resolve entry point if required
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
342 // this must resolve to an *exported* symbol and will resolve to the
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
343 // first instance of that symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
344 if (linkscript.execsym)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
345 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
346 lw_expr_stack_t *s;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
347
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
348 s = resolve_sym(linkscript.execsym, 0, NULL);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
349 if (!s)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
350 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
351 fprintf(stderr, "Cannot resolve exec address '%s'\n", linkscript.execsym);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
352 symerr = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
353 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
354 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
355 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
356 linkscript.execaddr = lw_expr_get_value(s);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
357 lw_expr_stack_free(s);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
358 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
359 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
360
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
361 for (sn = 0; sn < nsects; sn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
362 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
363 for (rl = sectlist[sn].ptr -> incompletes; rl; rl = rl -> next)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
364 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
365 // do a "simplify" on the expression
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
366 rval = lw_expr_reval(rl -> expr, resolve_sym, sectlist[sn].ptr);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
367
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
368 // is it constant? error out if not
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
369 if (rval != 0 || !lw_expr_is_constant(rl -> expr))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
370 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
371 fprintf(stderr, "Incomplete reference at %s:%s+%02X\n", sectlist[sn].ptr -> file -> filename, sectlist[sn].ptr -> name, rl -> offset);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
372 symerr = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
373 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
374 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
375 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
376 // put the value into the relocation address
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
377 rval = lw_expr_get_value(rl -> expr);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
378 if (rl -> flags & RELOC_8BIT)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
379 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
380 sectlist[sn].ptr -> code[rl -> offset] = rval & 0xff;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
381 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
382 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
383 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
384 sectlist[sn].ptr -> code[rl -> offset] = (rval >> 8) & 0xff;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
385 sectlist[sn].ptr -> code[rl -> offset + 1] = rval & 0xff;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
386 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
387 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
388 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
389 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
390
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
391 if (symerr)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
392 exit(1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
393 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
394
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
395 /*
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
396 This is just a pared down version of the algo for resolving references.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
397 */
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
398 void resolve_files(void)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
399 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
400 int sn;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
401 int fn;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
402 reloc_t *rl;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
403 lw_expr_stack_t *te;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
404
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
405 int rval;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
406
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
407 // resolve entry point if required
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
408 // this must resolve to an *exported* symbol and will resolve to the
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
409 // first instance of that symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
410 if (linkscript.execsym)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
411 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
412 lw_expr_stack_t *s;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
413
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
414 s = resolve_sym(linkscript.execsym, 0, NULL);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
415 if (!s)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
416 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
417 fprintf(stderr, "Cannot resolve exec address '%s'\n", linkscript.execsym);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
418 symerr = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
419 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
420 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
421
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
422 do
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
423 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
424 nforced = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
425 for (fn = 0; fn < ninputfiles; fn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
426 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
427 if (inputfiles[fn] -> forced == 0)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
428 continue;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
429
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
430 for (sn = 0; sn < inputfiles[fn] -> nsections; sn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
431 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
432 for (rl = inputfiles[fn] -> sections[sn].incompletes; rl; rl = rl -> next)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
433 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
434 // do a "simplify" on the expression
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
435 te = lw_expr_stack_dup(rl -> expr);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
436 rval = lw_expr_reval(te, resolve_sym, &(inputfiles[fn] -> sections[sn]));
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
437
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
438 // is it constant? error out if not
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
439 if (rval != 0 || !lw_expr_is_constant(te))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
440 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
441 fprintf(stderr, "Incomplete reference at %s:%s+%02X\n", inputfiles[fn] -> filename, inputfiles[fn] -> sections[sn].name, rl -> offset);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
442 symerr = 1;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
443 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
444 lw_expr_stack_free(te);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
445 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
446 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
447 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
448 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
449 while (nforced == 1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
450
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
451 if (symerr)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
452 exit(1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
453
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
454 // theoretically, all files referenced by other files now have "forced" set to 1
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
455 for (fn = 0; fn < ninputfiles; fn++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
456 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
457 if (inputfiles[fn] -> forced == 1)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
458 continue;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
459
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
460 fprintf(stderr, "Warning: %s (%d) does not resolve any symbols\n", inputfiles[fn] -> filename, fn);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
461 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
462 }