Mercurial > hg-old > index.cgi
comparison lwlink/objdump.c @ 387:a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
author | lost@l-w.ca |
---|---|
date | Wed, 14 Jul 2010 20:15:23 -0600 |
parents | 1c31e9005ff7 |
children |
comparison
equal
deleted
inserted
replaced
386:af5f2c51db76 | 387:a741d2e4869f |
---|---|
31 #include "config.h" | 31 #include "config.h" |
32 #endif | 32 #endif |
33 | 33 |
34 void read_lwobj16v0(unsigned char *filedata, long filesize); | 34 void read_lwobj16v0(unsigned char *filedata, long filesize); |
35 char *program_name; | 35 char *program_name; |
36 | |
37 char *string_cleanup(char *sym) | |
38 { | |
39 static char symbuf[4096]; | |
40 int optr = 0; | |
41 while (*sym) | |
42 { | |
43 if (*sym < 33 || *sym > 126) | |
44 { | |
45 int c; | |
46 symbuf[optr++] = '\\'; | |
47 c = *sym >> 4; | |
48 c+= 48; | |
49 if (c > 57) | |
50 c += 7; | |
51 symbuf[optr++] = c; | |
52 c = *sym & 15; | |
53 c += 48; | |
54 if (c > 57) | |
55 c += 7; | |
56 symbuf[optr++] = c; | |
57 } | |
58 else if (*sym == '\\') | |
59 { | |
60 symbuf[optr++] = '\\'; | |
61 symbuf[optr++] = '\\'; | |
62 } | |
63 else | |
64 { | |
65 symbuf[optr++] = *sym; | |
66 } | |
67 sym++; | |
68 } | |
69 symbuf[optr] = '\0'; | |
70 return symbuf; | |
71 } | |
36 | 72 |
37 /* | 73 /* |
38 The logic of reading the entire file into memory is simple. All the symbol | 74 The logic of reading the entire file into memory is simple. All the symbol |
39 names in the file are NUL terminated strings and can be used directly without | 75 names in the file are NUL terminated strings and can be used directly without |
40 making additional copies. | 76 making additional copies. |
183 NEXTBYTE(); | 219 NEXTBYTE(); |
184 val |= (CURBYTE()); | 220 val |= (CURBYTE()); |
185 NEXTBYTE(); | 221 NEXTBYTE(); |
186 // val is now the symbol value | 222 // val is now the symbol value |
187 | 223 |
188 printf(" %s=%04X\n", fp, val); | 224 printf(" %s=%04X\n", string_cleanup(fp), val); |
189 | 225 |
190 } | 226 } |
191 // skip terminating NUL | 227 // skip terminating NUL |
192 NEXTBYTE(); | 228 NEXTBYTE(); |
193 | 229 |
203 NEXTBYTE(); | 239 NEXTBYTE(); |
204 val |= (CURBYTE()); | 240 val |= (CURBYTE()); |
205 NEXTBYTE(); | 241 NEXTBYTE(); |
206 // val is now the symbol value | 242 // val is now the symbol value |
207 | 243 |
208 printf(" %s=%04X\n", fp, val); | 244 printf(" %s=%04X\n", string_cleanup(fp), val); |
209 } | 245 } |
210 // skip terminating NUL | 246 // skip terminating NUL |
211 NEXTBYTE(); | 247 NEXTBYTE(); |
212 | 248 |
213 // now parse the incomplete references and make a list of | 249 // now parse the incomplete references and make a list of |
235 printf(" I16=%d", tt); | 271 printf(" I16=%d", tt); |
236 break; | 272 break; |
237 | 273 |
238 case 0x02: | 274 case 0x02: |
239 // external symbol reference | 275 // external symbol reference |
240 printf(" ES=%s", CURSTR()); | 276 printf(" ES=%s", string_cleanup(CURSTR())); |
241 break; | 277 break; |
242 | 278 |
243 case 0x03: | 279 case 0x03: |
244 // internal symbol reference | 280 // internal symbol reference |
245 printf(" IS=%s", CURSTR()); | 281 printf(" IS=%s", string_cleanup(CURSTR())); |
246 break; | 282 break; |
247 | 283 |
248 case 0x04: | 284 case 0x04: |
249 // operator | 285 // operator |
250 if (CURBYTE() > 0 && CURBYTE() <= numopers) | 286 if (CURBYTE() > 0 && CURBYTE() <= numopers) |