Mercurial > hg > index.cgi
comparison lwlink/link.c @ 2:7317fbe024af
Clean up insane number of compiler warnings under -Wall
author | lost@l-w.ca |
---|---|
date | Thu, 20 Jan 2011 22:39:46 -0700 |
parents | 2c24602be78f |
children | fdc11ef4115b |
comparison
equal
deleted
inserted
replaced
1:96c4dc89016e | 2:7317fbe024af |
---|---|
21 Resolve section and symbol addresses; handle incomplete references | 21 Resolve section and symbol addresses; handle incomplete references |
22 */ | 22 */ |
23 | 23 |
24 #include <stdio.h> | 24 #include <stdio.h> |
25 #include <stdlib.h> | 25 #include <stdlib.h> |
26 #include <string.h> | |
26 | 27 |
27 #include "expr.h" | 28 #include "expr.h" |
28 #include "lwlink.h" | 29 #include "lwlink.h" |
29 #include "util.h" | 30 #include "util.h" |
30 | 31 |
39 if (fn -> forced == 0) | 40 if (fn -> forced == 0) |
40 return; | 41 return; |
41 | 42 |
42 for (sn = 0; sn < fn -> nsections; sn++) | 43 for (sn = 0; sn < fn -> nsections; sn++) |
43 { | 44 { |
44 if (!strcmp(name, fn -> sections[sn].name)) | 45 if (!strcmp(name, (char *)(fn -> sections[sn].name))) |
45 { | 46 { |
46 // we have a match | 47 // we have a match |
47 sectlist = lw_realloc(sectlist, sizeof(struct section_list) * (nsects + 1)); | 48 sectlist = lw_realloc(sectlist, sizeof(struct section_list) * (nsects + 1)); |
48 sectlist[nsects].ptr = &(fn -> sections[sn]); | 49 sectlist[nsects].ptr = &(fn -> sections[sn]); |
49 | 50 |
71 { | 72 { |
72 // ignore if the noflags tell us to | 73 // ignore if the noflags tell us to |
73 if (noflags && (fn -> sections[sn].flags & noflags)) | 74 if (noflags && (fn -> sections[sn].flags & noflags)) |
74 continue; | 75 continue; |
75 // ignore unless the yesflags tell us not to | 76 // ignore unless the yesflags tell us not to |
76 if (yesflags && (fn -> sections[sn].flags & yesflags == 0)) | 77 if (yesflags && ((fn -> sections[sn].flags & yesflags) == 0)) |
77 continue; | 78 continue; |
78 // ignore it if already processed | 79 // ignore it if already processed |
79 if (fn -> sections[sn].processed) | 80 if (fn -> sections[sn].processed) |
80 continue; | 81 continue; |
81 | 82 |
82 // we have a match - now collect *all* sections of the same name! | 83 // we have a match - now collect *all* sections of the same name! |
83 add_matching_sections(fn -> sections[sn].name, 0, 0, base); | 84 add_matching_sections((char *)(fn -> sections[sn].name), 0, 0, base); |
84 | 85 |
85 // and then continue looking for sections | 86 // and then continue looking for sections |
86 } | 87 } |
87 for (sn = 0; sn < fn -> nsubs; sn++) | 88 for (sn = 0; sn < fn -> nsubs; sn++) |
88 { | 89 { |
152 { | 153 { |
153 // ignore if the "no flags" bit says to | 154 // ignore if the "no flags" bit says to |
154 if (linkscript.lines[ln].noflags && (inputfiles[fn0] -> sections[sn0].flags & linkscript.lines[ln].noflags)) | 155 if (linkscript.lines[ln].noflags && (inputfiles[fn0] -> sections[sn0].flags & linkscript.lines[ln].noflags)) |
155 continue; | 156 continue; |
156 // ignore unless the yes flags tell us not to | 157 // ignore unless the yes flags tell us not to |
157 if (linkscript.lines[ln].yesflags && (inputfiles[fn0] -> sections[sn0].flags & linkscript.lines[ln].yesflags == 0)) | 158 if (linkscript.lines[ln].yesflags && ((inputfiles[fn0] -> sections[sn0].flags & linkscript.lines[ln].yesflags) == 0)) |
158 continue; | 159 continue; |
159 if (inputfiles[fn0] -> sections[sn0].processed == 0) | 160 if (inputfiles[fn0] -> sections[sn0].processed == 0) |
160 { | 161 { |
161 sname = inputfiles[fn0] -> sections[sn0].name; | 162 sname = (char *)(inputfiles[fn0] -> sections[sn0].name); |
162 for (fn = 0; fn < ninputfiles; fn++) | 163 for (fn = 0; fn < ninputfiles; fn++) |
163 { | 164 { |
164 for (sn = 0; sn < inputfiles[fn] -> nsections; sn++) | 165 for (sn = 0; sn < inputfiles[fn] -> nsections; sn++) |
165 { | 166 { |
166 if (!strcmp(sname, inputfiles[fn] -> sections[sn].name)) | 167 if (!strcmp(sname, (char *)(inputfiles[fn] -> sections[sn].name))) |
167 { | 168 { |
168 // we have a match | 169 // we have a match |
169 sectlist = lw_realloc(sectlist, sizeof(struct section_list) * (nsects + 1)); | 170 sectlist = lw_realloc(sectlist, sizeof(struct section_list) * (nsects + 1)); |
170 sectlist[nsects].ptr = &(inputfiles[fn] -> sections[sn]); | 171 sectlist[nsects].ptr = &(inputfiles[fn] -> sections[sn]); |
171 | 172 |
205 | 206 |
206 for (sn = 0; sn < fn -> nsections; sn++) | 207 for (sn = 0; sn < fn -> nsections; sn++) |
207 { | 208 { |
208 for (se = fn -> sections[sn].exportedsyms; se; se = se -> next) | 209 for (se = fn -> sections[sn].exportedsyms; se; se = se -> next) |
209 { | 210 { |
210 if (!strcmp(sym, se -> sym)) | 211 if (!strcmp(sym, (char *)(se -> sym))) |
211 { | 212 { |
212 if (!(fn -> forced)) | 213 if (!(fn -> forced)) |
213 { | 214 { |
214 fn -> forced = 1; | 215 fn -> forced = 1; |
215 nforced = 1; | 216 nforced = 1; |
262 } | 263 } |
263 | 264 |
264 // start with this section | 265 // start with this section |
265 for (se = sect -> localsyms; se; se = se -> next) | 266 for (se = sect -> localsyms; se; se = se -> next) |
266 { | 267 { |
267 if (!strcmp(se -> sym, sym)) | 268 if (!strcmp((char *)(se -> sym), sym)) |
268 { | 269 { |
269 val = se -> offset + sect -> loadaddress; | 270 val = se -> offset + sect -> loadaddress; |
270 goto out; | 271 goto out; |
271 } | 272 } |
272 } | 273 } |
273 // not in this section - check all sections in this file | 274 // not in this section - check all sections in this file |
274 for (i = 0; i < sect -> file -> nsections; i++) | 275 for (i = 0; i < sect -> file -> nsections; i++) |
275 { | 276 { |
276 for (se = sect -> file -> sections[i].localsyms; se; se = se -> next) | 277 for (se = sect -> file -> sections[i].localsyms; se; se = se -> next) |
277 { | 278 { |
278 if (!strcmp(se -> sym, sym)) | 279 if (!strcmp((char *)(se -> sym), sym)) |
279 { | 280 { |
280 val = se -> offset + sect -> file -> sections[i].loadaddress; | 281 val = se -> offset + sect -> file -> sections[i].loadaddress; |
281 goto out; | 282 goto out; |
282 } | 283 } |
283 } | 284 } |