From ef46c278697020671bf97647af22f896b823f715 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 13 Nov 2023 10:40:36 -0600 Subject: [PATCH] Add scripts/probes directory with script to measure GLOBALS() size, and move findglobals and showasm into it. --- scripts/probes/GLOBALS | 8 ++++++++ scripts/{findglobals.sh => probes/findglobals} | 3 ++- scripts/{ => probes}/showasm | 0 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 scripts/probes/GLOBALS rename scripts/{findglobals.sh => probes/findglobals} (86%) rename scripts/{ => probes}/showasm (100%) diff --git a/scripts/probes/GLOBALS b/scripts/probes/GLOBALS new file mode 100755 index 00000000..0ec57627 --- /dev/null +++ b/scripts/probes/GLOBALS @@ -0,0 +1,8 @@ +#!/bin/bash + +# Show bytes used by each command's GLOBALS() block, based on last build +{ + echo -e '#include "toys.h"\nint main(void) {' + sed -n 's/^\tstruct \(.*\)_data .*/printf("%d \1\\n", (int)sizeof(struct \1_data));/p' generated/globals.h + echo '}' +} | "${CROSS_COMPILE}"cc -xc - && ./a.out | sort -n diff --git a/scripts/findglobals.sh b/scripts/probes/findglobals similarity index 86% rename from scripts/findglobals.sh rename to scripts/probes/findglobals index 2bb94d69..c4855dec 100755 --- a/scripts/findglobals.sh +++ b/scripts/probes/findglobals @@ -3,4 +3,5 @@ # Quick and dirty check to see if anybody's leaked global variables. # We should have this, toy_list, toybuf, and toys. -nm --size-sort generated/unstripped/toybox | grep '[0-9A-Fa-f]* [BCDGRS]' #| cut -d ' ' -f 3 +nm --size-sort generated/unstripped/toybox | grep '[0-9A-Fa-f]* [BCDGRS]' | \ + grep -v GLIBC diff --git a/scripts/showasm b/scripts/probes/showasm similarity index 100% rename from scripts/showasm rename to scripts/probes/showasm -- 2.39.2