cfb8: Fix decrypt path
[gd/nettle] / list-obj-sizes.awk
1 #! /usr/bin/awk -f
2
3 # Run this filter on the output of
4 #
5 #   objdump -h libnettle.a
6
7 function hex2int (hex, n, i) {
8   n = 0;
9   hex = tolower(hex);
10   for (i = 1; i<=length(hex); i++)
11     {
12       n = n * 16 + index("0123456789abcdef", substr(hex,i,1)) - 1;
13     }
14
15   return n;
16 }
17
18 function output () {
19   if (name)
20     {
21       printf "%25s %6d   %6d   %6d\n", name, text_size, data_size, rodata_size;
22       text_total += text_size;
23       data_total += data_size;
24       rodata_total += rodata_size; 
25     } 
26   text_size = 0;
27   data_size = 0;
28   rodata_size = 0;
29 }
30
31 BEGIN {
32     print "file                   text-size  data-size  rodata-size";
33     text_total = 0;
34     data_total = 0;
35     rodata_total = 0;
36
37     text_size = 0;
38     data_size = 0;
39     rodata_size = 0;
40
41     name = "";
42     filter = ENVIRON["FILTER"];
43     if (!filter)
44       filter = ".*";
45     else
46       printf "Filter: %s\n", filter;
47 }
48
49 /elf32|elf64/ {
50   output();
51   if ($1 ~ filter)
52     {
53       name = $1; text_size = data_size = rodata_size = 0;
54       sub(/^[^-]*_a-/, "", name);
55     }
56   else
57     name = "";
58 }
59
60 /\.text/ { text_size += hex2int($3); }
61 /\.data/ { data_size += hex2int($3); }
62 /\.rodata/ { rodata_size += hex2int($3);}
63
64 END {
65   output();
66   printf "%25s %6d   %6d   %6d\n", "TOTAL", text_total, data_total, rodata_total;
67 }