From: Niels Möller Date: Wed, 12 Nov 2003 16:19:03 +0000 (+0100) Subject: New function for decoding hex values, with a X-Git-Tag: nettle_1.8_release_20040110~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7aef469f273b725d5e19efac874f6921113a550b;p=thirdparty%2Fnettle.git New function for decoding hex values, with a new function hex2int. Also implemented calculation of total storage, removed the dependence on the .comment section, and use the $FILTER environment variable as a regexp for restricting the object files that are considered. Rev: src/nettle/ChangeLog:1.214 Rev: src/nettle/list-obj-sizes.awk:1.2 --- diff --git a/ChangeLog b/ChangeLog index 222cdf9b..5de7306c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-11-12 Niels Möller + + * list-obj-sizes.awk: New function for decoding hex values, with a + new function hex2int. Also implemented calculation of total + storage, removed the dependence on the .comment section, and use + the $FILTER environment variable as a regexp for restricting the + object files that are considered. + 2003-09-21 Niels Möller * testsuite/rsa-encrypt-test.c (test_main): Don't use gmp_printf, diff --git a/list-obj-sizes.awk b/list-obj-sizes.awk index b9093a27..98d97e9e 100755 --- a/list-obj-sizes.awk +++ b/list-obj-sizes.awk @@ -1,25 +1,52 @@ -#! /usr/bin/gawk -f +#! /usr/bin/awk -f # Run this filter on the output of # # objdump -h libnettle.a +function hex2int (hex) { + n = 0; + hex = tolower(hex); + for (i = 1; i<=length(hex); i++) + { + n = n * 16 + index("0123456789abcdef", substr(hex,i,1)) - 1; + } + + return n; +} + BEGIN { print "file text-size data-size rodata-size"; text_total = 0; data_total = 0; rodata_total = 0; + name = ""; + filter = ENVIRON["FILTER"]; + if (!filter) + filter = ".*"; + else + printf "Filter: %s\n", filter; } -/elf32/ { name = $1; text_size = data_size = rodata_size = 0; } -/\.text/ { text_size = $3 } -/\.data/ { data_size = $3; } -/\.rodata/ { rodata_size = $3; } -/\.comment/ { - printf "%15s %s %s %s\n", name, text_size, data_size, rodata_size; +/elf32/ { + if (name) + { + printf "%25s %6x %6x %6x\n", name, text_size, data_size, rodata_size; + text_total += text_size; + data_total += data_size; + rodata_total += rodata_size; + } + if ($1 ~ filter) + { + name = $1; text_size = data_size = rodata_size = 0; + } + else + name = "" } +/\.text/ { text_size = hex2int($3) } +/\.data/ { data_size = hex2int($3); } +/\.rodata/ { rodata_size = hex2int($3); } END { - printf "%15s %s %s %s\n", "TOTAL", text_total, data_total, rodata_total; + printf "%25s %6x %6x %6x\n", "TOTAL", text_total, data_total, rodata_total; } -