Fix ar9x compile/boot (#7102)
[opentx.git] / radio / util / elf-size-compare.awk
blobbe2487cf045c225488fdc24258d696f0f808e096
1 #!/usr/bin/awk -nf
3 # Parses the output of elf-size-report.awk and calculates segment memory usage deltas between the analyzed elf files.
5 # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
6 # Copyright (c)2016 Maxim Paperno
7 # Copyright (c)2017 OpenTX
11 BEGIN {
12 in_ttls = 0;
13 elf_cnt = 0;
14 sec_cnt = 0;
17 if ($1 == "----" && NF > 5 && $5 ~ /\.elf$/) {
18 fname[elf_cnt] = $5;
20 else if (tolower($1) ~ /totals/) {
21 in_ttls = 1;
22 elf_cnt++;
24 else if (in_ttls && NF != 5) {
25 in_ttls = 0;
27 else if (in_ttls) {
28 if (elf_cnt == 1)
29 a[++sec_cnt] = $1;
30 d[elf_cnt][$1]["total"] = $2;
33 END {
34 printf("\n---- Comparing results of %d files ----\n\n", elf_cnt);
35 PROCINFO["sorted_in"] = "@ind_num_asc"
36 for (j in d) {
37 if (length(fname[j-1]))
38 printf("file %d: %s\n", j, fname[j-1])
40 printf("\n%-8s ", "Section");
41 for (j in d) {
42 printf("%8s ", "file " j);
43 if (j > 1)
44 printf("(%7s) ", "\xCE\x94 vs f1");
45 if (j > 2)
46 printf("(%7s) ", "\xCE\x94 vs f" j-1);
48 printf("\n");
49 for (i in a) {
50 n = a[i];
51 printf("%8s ", n);
52 for (j in d) {
53 printf("%8.2f ", d[j][n]["total"]);
54 if (j > 1)
55 printDelta(d[j][n]["total"] - d[1][n]["total"]);
56 if (j > 2)
57 printDelta(d[j][n]["total"] - d[j-1][n]["total"]);
59 printf("\n");
61 printf("\n");
64 function printDelta(dlta) {
65 if (dlta)
66 printf("(%+7.2f) ", dlta);
67 else
68 printf("(%7s) ", "--.--");