FreeCalypso > hg > freecalypso-reveng
comparison leo-obj/tool/richsym.c @ 208:f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Fri, 04 Mar 2016 23:36:16 +0000 |
parents | 15743b40e03a |
children |
comparison
equal
deleted
inserted
replaced
207:d12a3207b1aa | 208:f7943bdbb3ea |
---|---|
1 /* | 1 /* |
2 * Code for working with the "rich" symbolic info | 2 * Code for working with the "rich" symbolic info |
3 * present in TI's GPF libraries | 3 * present in TI's GPF libraries and L1 objects |
4 */ | 4 */ |
5 | 5 |
6 #include <sys/types.h> | 6 #include <sys/types.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
415 } | 415 } |
416 exit(0); | 416 exit(0); |
417 } | 417 } |
418 | 418 |
419 static int | 419 static int |
420 localsym_sanity_check(sym) | 420 localsym_sanity_check_aux(sym) |
421 struct internal_syment *sym; | 421 struct internal_syment *sym; |
422 { | 422 { |
423 if (!sym->aux) { | 423 if (!sym->aux) { |
424 printf("; symbol #%u of class %s has no aux record\n", | 424 printf("; symbol #%u of class %s has no aux record\n", |
425 sym->number, storage_class_to_string(sym->class, 0)); | 425 sym->number, storage_class_to_string(sym->class, 0)); |
426 return(-1); | 426 return(-1); |
427 } | 427 } |
428 return(0); | |
429 } | |
430 | |
431 static int | |
432 localsym_sanity_check_scnum(sym) | |
433 struct internal_syment *sym; | |
434 { | |
428 if (sym->scnum != -1) { | 435 if (sym->scnum != -1) { |
429 printf("; symbol #%u of class %s: section != ABS\n", | 436 printf("; symbol #%u of class %s: section != ABS\n", |
430 sym->number, storage_class_to_string(sym->class, 0)); | 437 sym->number, storage_class_to_string(sym->class, 0)); |
431 return(-1); | 438 return(-1); |
432 } | 439 } |
440 return(0); | |
441 } | |
442 | |
443 static int | |
444 localsym_sanity_check(sym) | |
445 struct internal_syment *sym; | |
446 { | |
447 int rc; | |
448 | |
449 rc = localsym_sanity_check_aux(sym); | |
450 if (rc) | |
451 return(rc); | |
452 rc = localsym_sanity_check_scnum(sym); | |
453 if (rc) | |
454 return(rc); | |
433 return(0); | 455 return(0); |
434 } | 456 } |
435 | 457 |
436 richsym_function_locals(headsym) | 458 richsym_function_locals(headsym) |
437 struct internal_syment *headsym; | 459 struct internal_syment *headsym; |
470 printf("; %s at 0x%x: ", | 492 printf("; %s at 0x%x: ", |
471 storage_class_to_string(sym->class, 0), | 493 storage_class_to_string(sym->class, 0), |
472 sym->value); | 494 sym->value); |
473 richsym_print_in_c("", sym, 0); | 495 richsym_print_in_c("", sym, 0); |
474 continue; | 496 continue; |
497 case C_STRTAG: | |
498 case C_UNTAG: | |
499 case C_ENTAG: | |
500 count++; | |
501 printf("; %s {", sym->struct_name_raw); | |
502 if (richsym_print_bitsize && sym->aux) | |
503 printf("\t/* %u bits */", get_u32(sym->aux+4)); | |
504 putchar('\n'); | |
505 continue; | |
506 case C_EOS: | |
507 count++; | |
508 fputs("; };", stdout); | |
509 if (richsym_print_bitsize && sym->aux) | |
510 printf("\t/* %u bits */", get_u32(sym->aux+4)); | |
511 putchar('\n'); | |
512 continue; | |
513 case C_MOS: | |
514 case C_MOU: | |
515 count++; | |
516 if (localsym_sanity_check(sym) < 0) | |
517 continue; | |
518 richsym_print_in_c("; ", sym, 0); | |
519 continue; | |
520 case C_MOE: | |
521 count++; | |
522 if (localsym_sanity_check_scnum(sym) < 0) | |
523 continue; | |
524 if (sym->name[0] == '_') | |
525 printf("; %s = %u;", sym->name + 1, | |
526 sym->value); | |
527 else | |
528 printf("; \"%s\" = %u;", sym->name, | |
529 sym->value); | |
530 if (sym->value >= 10) | |
531 printf("\t/* 0x%x */", sym->value); | |
532 putchar('\n'); | |
533 continue; | |
534 case C_TPDEF: | |
535 count++; | |
536 if (localsym_sanity_check_aux(sym) < 0) | |
537 continue; | |
538 richsym_print_in_c("; typedef ", sym, | |
539 !(sym->type & 0xFFF0)); | |
540 continue; | |
541 case C_STAT: | |
542 count++; | |
543 if (localsym_sanity_check_aux(sym) < 0) | |
544 continue; | |
545 richsym_print_in_c("; static ", sym, 0); | |
546 continue; | |
475 case C_FCN: | 547 case C_FCN: |
476 return(count); | 548 return(count); |
477 default: | 549 default: |
478 count++; | 550 count++; |
479 printf( | 551 printf( |