diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:55:52 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 17:55:52 +0000 |
commit | f7a951d79bc895eb2171c2570add9f4899794a10 (patch) | |
tree | cc0c7147f472fecbc93add134f5c0e5c1bb72529 /testsuite/scripts/smaller-than.sh | |
parent | Initial commit. (diff) | |
download | dwz-4fb184be49430f1d777ce99c270ed80a487aa8a0.tar.xz dwz-4fb184be49430f1d777ce99c270ed80a487aa8a0.zip |
Adding upstream version 0.15.upstream/0.15upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testsuite/scripts/smaller-than.sh')
-rwxr-xr-x | testsuite/scripts/smaller-than.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/testsuite/scripts/smaller-than.sh b/testsuite/scripts/smaller-than.sh new file mode 100755 index 0000000..3b452dc --- /dev/null +++ b/testsuite/scripts/smaller-than.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +f1=$1 +f2=$2 + +section_size () +{ + local f="$1" + local section="$2" + + local s + s=$(readelf -S -W $f \ + | grep "\.debug_$section" \ + | sed 's/.*\.debug_//' \ + | awk '{print $5}') + + if [ "$s" = "" ]; then + echo 0 + return + fi + + # Convert hex to decimal. + s=$(printf "%d" $((16#$s))) + + echo $s +} + +size () +{ + local f="$1" + + local total=0 + local section + for section in info abbrev str macro types; do + total=$(($total + $(section_size $f $section))) + done + + echo $total +} + +s1=$(size $f1) +s2=$(size $f2) + +if [ $s1 -ge $s2 ]; then + exit 1 +fi + +exit 0 |