From b208a19331ee52445b48f0e3418437832dadd843 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 26 Feb 2025 16:13:02 -0700 Subject: I guess CMake uses .o now instead of .obj? --- build-aux/lint-bin | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'build-aux/lint-bin') diff --git a/build-aux/lint-bin b/build-aux/lint-bin index 2fe8e4b..85f9015 100755 --- a/build-aux/lint-bin +++ b/build-aux/lint-bin @@ -5,6 +5,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later set -euE -o pipefail +shopt -s extglob # Output is a series of lines in the format "symbol location size # source". Whitespace may seem silly. @@ -38,10 +39,10 @@ lint_globals() { # resolve `..` components source="$(realpath --canonicalize-missing --no-symlinks -- "$source")" ;; - CMakeFiles/*.dir/*.obj) + CMakeFiles/*.dir/*.@(obj|o)) # CMakeFiles/sbc_harnes_objs.dir/... source="${source#CMakeFiles/*.dir/}" - source="${source%.obj}" + source="${source%.@(obj|o)}" source="${source//__/..}" source="$(realpath --canonicalize-missing --no-symlinks --relative-to="$topdir" -- "$source")" ;; -- cgit v1.2.3-2-g168b From f3ee711bbd8526e0df8bb5f2ea28fc90a41a58f3 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 26 Feb 2025 16:02:06 -0700 Subject: Integrate lint-bin into `make lint` --- build-aux/lint-bin | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'build-aux/lint-bin') diff --git a/build-aux/lint-bin b/build-aux/lint-bin index 85f9015..7584714 100755 --- a/build-aux/lint-bin +++ b/build-aux/lint-bin @@ -7,6 +7,20 @@ set -euE -o pipefail shopt -s extglob +# There are several exisi files we can use: +# +# Binaries: +# - ${elf} : firmware image with debug symbols and relocationd data +# - ${elf%.elf}.bin : raw firmware image +# - ${elf%.elf}.hex : .bin as Intel HEX +# - ${elf%.elf}.uf2 : .bin as USB Flashing Format (UF2) +# +# Textual info: +# - ${elf%.elf}.dis : `objdump --section-headers ${elf}; objdump --disassemble ${elf}; picotool coprodis --quiet ${elf}` +# - ${elf}.map : `ld --print-map` info + +# Input is `ld --print-map` format. +# # Output is a series of lines in the format "symbol location size # source". Whitespace may seem silly. objdump_globals() { @@ -57,8 +71,13 @@ lint_globals() { } main() { - echo 'Global variables:' - lint_globals 'build/rp2040-Release/cmd/sbc_harness/sbc_harness.elf.map' | sed 's/^/ /' + local elf + for elf in "$@"; do + { + echo 'Global variables:' + lint_globals "${elf}.map" | sed 's/^/ /' + } > "${elf%.elf}.lint.globals" + done } main "$@" -- cgit v1.2.3-2-g168b From 9d38a89701d45ebc28e73b06f4283d460c151c73 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 26 Feb 2025 16:16:38 -0700 Subject: lint-bin: Ignore removed symbols --- build-aux/lint-bin | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'build-aux/lint-bin') diff --git a/build-aux/lint-bin b/build-aux/lint-bin index 7584714..d16a25d 100755 --- a/build-aux/lint-bin +++ b/build-aux/lint-bin @@ -45,7 +45,9 @@ lint_globals() { cd "$rel_base" total=0 while read -r symbol addr size source; do - : "$addr" + if (( addr == 0 )); then + continue + fi case "$source" in /*) # libg.a(whatever.o) -> libg.a -- cgit v1.2.3-2-g168b From 8a231f17a865fbae5b4548f0aba80554b3c39d72 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 26 Feb 2025 16:16:50 -0700 Subject: lint-bin: Also show sizes in decimal --- build-aux/lint-bin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'build-aux/lint-bin') diff --git a/build-aux/lint-bin b/build-aux/lint-bin index d16a25d..ffc2a12 100755 --- a/build-aux/lint-bin +++ b/build-aux/lint-bin @@ -63,10 +63,10 @@ lint_globals() { source="$(realpath --canonicalize-missing --no-symlinks --relative-to="$topdir" -- "$source")" ;; esac - printf '%s %s 0x%04x\n' "$source" "$symbol" "$size" + printf "%s %s 0x%04x (%'d)\n" "$source" "$symbol" "$size" "$size" total=$((total + size)) done - printf '~ Total 0x%04x\n' "$total" + printf "~ Total 0x%04x (%'d)\n" "$total" "$total" } | LC_COLLATE=C sort } | column -t -- cgit v1.2.3-2-g168b