summaryrefslogtreecommitdiffstats
path: root/util/make-multiextractor
blob: 18285deaa21221ed9d3bdcc9de1fb3d737cbae0e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
# See LICENSE file for copyright and license details.

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'