# HG changeset patch # User Mychaela Falconia # Date 1569100649 0 # Node ID ff2a6433687f511b8ab81ae6dfb57cea35f2a16e # Parent 23e5b940cb8bac368a88fb6864a0c1b1d2373fce blobstat: code finished, compiles diff -r 23e5b940cb8b -r ff2a6433687f .hgignore --- 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 diff -r 23e5b940cb8b -r ff2a6433687f blobstat/Makefile --- /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} diff -r 23e5b940cb8b -r ff2a6433687f blobstat/grokmap.c --- 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; diff -r 23e5b940cb8b -r ff2a6433687f blobstat/main.c --- /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 +#include + +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); +} diff -r 23e5b940cb8b -r ff2a6433687f blobstat/output.c --- /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 +#include +#include +#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); +}