annotate lwlink/link.c @ 205:42df94f30d82

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