aboutsummaryrefslogtreecommitdiff
path: root/scripts/do_symsize.sh
diff options
context:
space:
mode:
authorDavid Timber <mieabby@gmail.com>2021-11-06 19:07:41 +0800
committerDavid Timber <mieabby@gmail.com>2021-11-06 19:07:41 +0800
commitd19a792e58eba8f13d9c7a0160cc5f1402e7f117 (patch)
tree20a6fab9a3600e15220b4211f6567141326ad590 /scripts/do_symsize.sh
parent7829a29ee65e21b8a234670f9edba31a9a432853 (diff)
Add more callbacks for fork() event, doc progress
* Add fork.prepare(), fork.parent() and fork.child() to match with pthread_atfork(), which makes more sense * Code documentation progress
Diffstat (limited to 'scripts/do_symsize.sh')
-rwxr-xr-xscripts/do_symsize.sh26
1 files changed, 23 insertions, 3 deletions
diff --git a/scripts/do_symsize.sh b/scripts/do_symsize.sh
index 154fb00..990c0ba 100755
--- a/scripts/do_symsize.sh
+++ b/scripts/do_symsize.sh
@@ -1,25 +1,44 @@
#!/bin/bash
+## \file
+# \brief Generate the text files of the symbol size table from the readelf
+# output. The values are separated by white spaces. Only 3 fields are
+# extracted in order: the size of symbol in decimal, the type of the symbol
+# and the name of the symbol. The text files can be imported into spreadsheet
+# or document files to make the tables a printable form.
+
+# The input prefix
ELF_PREFIX='./builds/proone.bin/readelf'
+# The output prefix
OUT_PREFIX='./builds/proone.bin/symsize'
+# The number of threads on the host
NPROC=$(nproc)
+# The number of concurrent processes
NB_PROC=0
-#
-# \param 1: input file
-# \param 2: output file
+##
+# \brief Call the script that actually does the job
+# \param 1 input file
+# \param 2 output file
call_extsymsize () {
./scripts/extsymsize.sh < "$1" | sort -nr > "$2"
}
+# Process each readelf output file
for f in "$ELF_PREFIX".*; do
+ # Extract the arch from the file name
+ # The script assumes that the "middle name" is the name of the arch
suffix=$(echo "$f" | egrep -o '(\.\w+\.\w+)$')
if [ $? -ne 0 ]; then
echo "$f: invalid suffix" >&2
exit 1
fi
+ # Die on error: while running \c extsymsize.sh or in the process of
+ # launching it
set -e
out="$OUT_PREFIX""$suffix"
+ # Limit the number of processses running concurrently to the number of
+ # threads on the host.
if [ $NB_PROC -lt $NPROC ]; then
call_extsymsize "$f" "$out" &
let 'NB_PROC += 1'
@@ -30,6 +49,7 @@ for f in "$ELF_PREFIX".*; do
set +e
done
+# Reap processes
for (( i = 0; i < NB_PROC; i += 1 )); do
wait
done