FreeCalypso > hg > freecalypso-reveng
changeset 294:ff2a6433687f
blobstat: code finished, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 21 Sep 2019 21:17:29 +0000 |
parents | 23e5b940cb8b |
children | 99f72069d867 |
files | .hgignore blobstat/Makefile blobstat/grokmap.c blobstat/main.c blobstat/output.c |
diffstat | 5 files changed, 58 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sat Sep 21 21:07:45 2019 +0000 +++ b/.hgignore Sat Sep 21 21:17:29 2019 +0000 @@ -5,6 +5,8 @@ ^arm7dis/armdis$ ^arm7dis/thumbdis$ +^blobstat/blobstat$ + ^bootrom-old/bootrom-old\.dis16 ^bootrom-old/bootrom-old\.dis32 ^bootrom-old/bootrom-old\.hex
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/blobstat/Makefile Sat Sep 21 21:17:29 2019 +0000 @@ -0,0 +1,12 @@ +CC= gcc +CFLAGS= -O2 +PROG= blobstat +OBJS= globals.o grokmap.o main.o output.o readclass.o + +all: ${PROG} + +${PROG}: ${OBJS} + ${CC} ${CFLAGS} -o $@ ${OBJS} + +clean: + rm -f *.o *.out *errs ${PROG}
--- a/blobstat/grokmap.c Sat Sep 21 21:07:45 2019 +0000 +++ b/blobstat/grokmap.c Sat Sep 21 21:17:29 2019 +0000 @@ -29,7 +29,7 @@ } static void -getline() +get_line() { char *cp; @@ -133,7 +133,7 @@ char libname[1024], *member; struct category *cat; - getline(); + get_line(); if (!linebuf[0]) return(1); if (!valid_section_name_char(linebuf[0], 1)) { @@ -153,7 +153,7 @@ if (!c) { if (i < 8) goto inv_outsec_line; - getline(); + get_line(); for (i = 0; i < 8; i++) if (linebuf[i] != ' ') goto inv_outsec_line; @@ -185,7 +185,7 @@ /* input section lines */ libname[0] = '\0'; for (;;) { - getline(); + get_line(); if (!linebuf[0]) break; if (!parse_input_section_line(libname, &member)) @@ -217,10 +217,10 @@ exit(1); } do - getline(); + get_line(); while (strcmp(linebuf, "SECTION ALLOCATION MAP")); /* 4 fixed info lines */ - getline(); + get_line(); if (linebuf[0]) { bad_sectionmap_hdr: fprintf(stderr, @@ -228,15 +228,15 @@ filename_for_errs, lineno); exit(1); } - getline(); + get_line(); if (strcmp(linebuf, " output attributes/")) goto bad_sectionmap_hdr; - getline(); + get_line(); if (strcmp(linebuf, "section page origin length input sections")) goto bad_sectionmap_hdr; - getline(); + get_line(); if (strcmp(linebuf, "-------- ---- ---------- ---------- ----------------")) goto bad_sectionmap_hdr;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/blobstat/main.c Sat Sep 21 21:17:29 2019 +0000 @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <stdlib.h> + +main(argc, argv) + char **argv; +{ + if (argc != 3) { + fprintf(stderr, "usage: %s class-file map-file\n", argv[0]); + exit(1); + } + read_class_file(argv[1]); + process_map_file(argv[2]); + print_output(); + exit(0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/blobstat/output.c Sat Sep 21 21:17:29 2019 +0000 @@ -0,0 +1,20 @@ +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include "struct.h" + +extern struct category *category_list; + +print_output() +{ + struct category *p; + u_long total = 0; + + for (p = category_list; p; p = p->next) + total += p->accum; + printf("total: 0x%lX (%lu) bytes\n", total, total); + for (p = category_list; p; p = p->next) + printf("%s: 0x%lX (%lu) bytes, %u%% of total\n", p->accum, + p->accum, p->accum * 100 / total); + return(0); +}