summaryrefslogtreecommitdiffstats
path: root/util/make-multiextractor
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-12-03 19:23:35 +0100
committerMattias Andrée <maandree@kth.se>2023-12-03 19:23:35 +0100
commitc131f122778c62f920a99bbf854ced4a37ee8b03 (patch)
tree14c933f98f4d64dffb0a594bc40dd5121c6c5a8e /util/make-multiextractor
downloadlibsyscalls-c131f122778c62f920a99bbf854ced4a37ee8b03.tar.gz
libsyscalls-c131f122778c62f920a99bbf854ced4a37ee8b03.tar.bz2
libsyscalls-c131f122778c62f920a99bbf854ced4a37ee8b03.tar.xz
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rwxr-xr-xutil/make-multiextractor25
1 files changed, 25 insertions, 0 deletions
diff --git a/util/make-multiextractor b/util/make-multiextractor
new file mode 100755
index 0000000..487162e
--- /dev/null
+++ b/util/make-multiextractor
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+set -e
+
+test $# -ge 3
+
+lowercase () { printf '%s\n' "$*" | tr '[A-Z]' '[a-z]'; }
+
+symbols="$(lowercase "$1")"
+shift 1
+
+printf 'static const char *\n'
+printf 'extract_symbol_%s(struct libsyscalls_symbol_printer_data *data, ' "$symbols"
+printf 'unsigned long long int *valuep, char *fallback_out) /* %i */\n' $#
+printf '{\n'
+printf ' switch (data->nr) {\n'
+i=0
+for use; do
+printf ' case %i:\n' $(( i++ ))
+printf ' return extract_symbol_%s(data, valuep, fallback_out);\n' "$(lowercase "$use")"
+done
+printf ' default:\n'
+printf ' abort();\n'
+printf ' }\n'
+printf '}\n'