1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-13 03:19:53 +03:00
opentx/radio/util/elf-size-compare.awk
Max Paperno f4f07d3c0c [build] Add comprehensive firmware size reporting scripts for ARM MCUs. (#4218)
* [build] Add comprehensive firmware size reporting scripts for ARM MCUs.

* [build] Add firmware size reports to commit-tests.sh.

* [build] Set permissions on new scripts.

* [build] Add -Wno-error option to commit-tests.sh.

* [build] Revert firmware size report to using `arm-none-eabi-size` if bash not found (eg. on Windows).

* [git] Add .gitattributes to force line endings on UNIX shell scripts.
2017-01-12 21:32:36 +01:00

70 lines
1.5 KiB
Awk
Executable file

#!/usr/bin/awk -nf
#
# Parses the output of elf-size-report.awk and calculates segment memory usage deltas between the analyzed elf files.
#
# License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
# Copyright (c)2016 Maxim Paperno
# Copyright (c)2017 OpenTX
#
BEGIN {
in_ttls = 0;
elf_cnt = 0;
sec_cnt = 0;
}
{
if ($1 == "----" && NF > 5 && $5 ~ /\.elf$/) {
fname[elf_cnt] = $5;
}
else if (tolower($1) ~ /totals/) {
in_ttls = 1;
elf_cnt++;
}
else if (in_ttls && NF != 5) {
in_ttls = 0;
}
else if (in_ttls) {
if (elf_cnt == 1)
a[++sec_cnt] = $1;
d[elf_cnt][$1]["total"] = $2;
}
}
END {
printf("\n---- Comparing results of %d files ----\n\n", elf_cnt);
PROCINFO["sorted_in"] = "@ind_num_asc"
for (j in d) {
if (length(fname[j-1]))
printf("file %d: %s\n", j, fname[j-1])
}
printf("\n%-8s ", "Section");
for (j in d) {
printf("%8s ", "file " j);
if (j > 1)
printf("(%7s) ", "\xCE\x94 vs f1");
if (j > 2)
printf("(%7s) ", "\xCE\x94 vs f" j-1);
}
printf("\n");
for (i in a) {
n = a[i];
printf("%8s ", n);
for (j in d) {
printf("%8.2f ", d[j][n]["total"]);
if (j > 1)
printDelta(d[j][n]["total"] - d[1][n]["total"]);
if (j > 2)
printDelta(d[j][n]["total"] - d[j-1][n]["total"]);
}
printf("\n");
}
printf("\n");
}
function printDelta(dlta) {
if (dlta)
printf("(%+7.2f) ", dlta);
else
printf("(%7s) ", "--.--");
}