OLD | NEW |
1 // Inferno utils/nm/nm.c | 1 // Inferno utils/nm/nm.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/nm/nm.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/nm/nm.c |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) | 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) |
6 // Portions Copyright © 1997-1999 Vita Nuova Limited | 6 // Portions Copyright © 1997-1999 Vita Nuova Limited |
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) | 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) |
8 // Portions Copyright © 2004,2006 Bruce Ellis | 8 // Portions Copyright © 2004,2006 Bruce Ellis |
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) | 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) |
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others | 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 break; | 292 break; |
293 } | 293 } |
294 symptr = realloc(symptr, (nsym+1)*sizeof(Sym*)); | 294 symptr = realloc(symptr, (nsym+1)*sizeof(Sym*)); |
295 if (symptr == 0) { | 295 if (symptr == 0) { |
296 error("out of memory"); | 296 error("out of memory"); |
297 exits("memory"); | 297 exits("memory"); |
298 } | 298 } |
299 symptr[nsym++] = s; | 299 symptr[nsym++] = s; |
300 } | 300 } |
301 | 301 |
| 302 const char *skipnames[] = { |
| 303 "bss", |
| 304 "data", |
| 305 "ebss", |
| 306 "edata", |
| 307 "egcbss", |
| 308 "egcdata", |
| 309 "epclntab", |
| 310 "erodata", |
| 311 "esymtab", |
| 312 "etext", |
| 313 "etypelink", |
| 314 "rodata", |
| 315 "text", |
| 316 }; |
| 317 |
| 318 int |
| 319 skipsize(char *name) |
| 320 { |
| 321 int i; |
| 322 ········ |
| 323 for(i=0; i<nelem(skipnames); i++) |
| 324 if(strcmp(skipnames[i], name) == 0) |
| 325 return 1; |
| 326 return 0; |
| 327 } |
| 328 |
302 void | 329 void |
303 printsyms(Sym **symptr, long nsym) | 330 printsyms(Sym **symptr, long nsym) |
304 { | 331 { |
305 int i, j, wid; | 332 int i, j, wid; |
306 Sym *s; | 333 Sym *s; |
307 char *cp; | 334 char *cp; |
308 char path[512]; | 335 char path[512]; |
309 | 336 |
310 qsort(symptr, nsym, sizeof(*symptr), (void*)cmp); | 337 qsort(symptr, nsym, sizeof(*symptr), (void*)cmp); |
311 | 338 |
(...skipping 13 matching lines...) Expand all Loading... |
325 fileelem(fnames, (uchar *) s->name, path, 512); | 352 fileelem(fnames, (uchar *) s->name, path, 512); |
326 cp = path; | 353 cp = path; |
327 } else | 354 } else |
328 cp = s->name; | 355 cp = s->name; |
329 if (Tflag) | 356 if (Tflag) |
330 Bprint(&bout, "%8ux ", s->sig); | 357 Bprint(&bout, "%8ux ", s->sig); |
331 if (s->value || s->type == 'a' || s->type == 'p') | 358 if (s->value || s->type == 'a' || s->type == 'p') |
332 Bprint(&bout, "%*llux ", wid, s->value); | 359 Bprint(&bout, "%*llux ", wid, s->value); |
333 else | 360 else |
334 Bprint(&bout, "%*s ", wid, ""); | 361 Bprint(&bout, "%*s ", wid, ""); |
335 » » if(Sflag) { | 362 » » if(Sflag && !skipsize(cp)) { |
336 vlong siz; | 363 vlong siz; |
337 | 364 |
338 siz = 0; | 365 siz = 0; |
339 for(j=i+1; j<nsym; j++) { | 366 for(j=i+1; j<nsym; j++) { |
340 » » » » if(symptr[j]->type != 'a' && symptr[j]->type !=
'p') { | 367 » » » » if(!skipsize(symptr[j]->name) && symptr[j]->type
!= 'a' && symptr[j]->type != 'p') { |
341 siz = symptr[j]->value - s->value; | 368 siz = symptr[j]->value - s->value; |
342 break; | 369 break; |
343 } | 370 } |
344 } | 371 } |
345 if(siz > 0) | 372 if(siz > 0) |
346 Bprint(&bout, "%*llud ", wid, siz); | 373 Bprint(&bout, "%*llud ", wid, siz); |
347 } | 374 } |
348 Bprint(&bout, "%c %s", s->type, cp); | 375 Bprint(&bout, "%c %s", s->type, cp); |
349 if(tflag && s->gotype) | 376 if(tflag && s->gotype) |
350 Bprint(&bout, " %*llux", wid, s->gotype); | 377 Bprint(&bout, " %*llux", wid, s->gotype); |
(...skipping 10 matching lines...) Expand all Loading... |
361 | 388 |
362 fmtfdinit(&f, 2, buf, sizeof buf); | 389 fmtfdinit(&f, 2, buf, sizeof buf); |
363 fmtprint(&f, "%s: ", argv0); | 390 fmtprint(&f, "%s: ", argv0); |
364 va_start(arg, fmt); | 391 va_start(arg, fmt); |
365 fmtvprint(&f, fmt, arg); | 392 fmtvprint(&f, fmt, arg); |
366 va_end(arg); | 393 va_end(arg); |
367 fmtprint(&f, "\n"); | 394 fmtprint(&f, "\n"); |
368 fmtfdflush(&f); | 395 fmtfdflush(&f); |
369 errs = "errors"; | 396 errs = "errors"; |
370 } | 397 } |
OLD | NEW |