diff options
author | Mattias Andrée <maandree@kth.se> | 2023-12-03 19:23:35 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-12-03 19:23:35 +0100 |
commit | c131f122778c62f920a99bbf854ced4a37ee8b03 (patch) | |
tree | 14c933f98f4d64dffb0a594bc40dd5121c6c5a8e /linux/symbols.mk | |
download | libsyscalls-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 '')
-rw-r--r-- | linux/symbols.mk | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/linux/symbols.mk b/linux/symbols.mk new file mode 100644 index 0000000..f045222 --- /dev/null +++ b/linux/symbols.mk @@ -0,0 +1,73 @@ +LINUX_SYMBOL_TABLES != sed -n 's/^.*LINUX_SYMBOL_PRINTER_\([A-Z0-9_]\+\)\b.*\$$\$$\$$.*\$$\$$\$$.*$$/\1/p' < linux/syscalls.h + +LINUX_SYMBOL_TABLE_FILES != printf 'linux-src/symbols-$(LINUX_VERSION)/%s\n' $(LINUX_SYMBOL_TABLES) + +LINUX_SYMBOL_TABLE_DEPS =\ + $(LINUX_SOURCE)\ + linux/symbols.mk\ + linux/syscalls.h\ + util/getdefs\ + util/getenum + +LINUX_SYMBOL_EXTRACTOR_DEPS =\ + $(LINUX_SYMBOL_TABLE_FILES)\ + linux/symbols.mk\ + linux/syscalls.h\ + util/make-enum\ + util/make-mask\ + util/make-multiextractor\ + util/make-sym-extractor + + +libsyscalls_get_syscall_display_info.o: generated/linux-symbol-extractors.h linux/symbols.c +libsyscalls_get_syscall_display_info.lo: generated/linux-symbol-extractors.h linux/symbols.c + + +$(LINUX_SYMBOL_TABLE_FILES): $(LINUX_SYMBOL_TABLE_DEPS) + mkdir -p -- linux-src/symbols-$(LINUX_VERSION) + table="$$(printf '%s\n' "$@" | tr / '\n' | sed -n '$$p')" && \ + command="$$(sed -n 's/^.*LINUX_SYMBOL_PRINTER_'"$$table"'\b.*\$$\$$\$$\s*\(.*\)\s*\$$\$$\$$.*$$/\1/p' < linux/syscalls.h)" && \ + test -n "$$command" && \ + printf '%s\n' "$$command" && \ + (cd -- linux-src/linux-$(LINUX_VERSION) && env PATH="../../util:$${PATH}" sh -e -c "$$command") > $@ + +generated/linux-symbol-extractors.h: $(LINUX_SYMBOL_EXTRACTOR_DEPS) + mkdir -p -- generated + set -e; \ + for tablefile in $(LINUX_SYMBOL_TABLE_FILES); do \ + tablename="$$(printf '%s\n' "$$tablefile" | cut -d / -f 3)"; \ + how="$$(sed -n < linux/syscalls.h \ + 's/^.*LINUX_SYMBOL_PRINTER_'"$$tablename"'\b.*\/\*\s*\(.*\)\s*\$$\$$\$$.*\$$\$$\$$.*$$/\1/p')"; \ + printf '\n'; \ + util/make-sym-extractor "$$tablename" "$$how" < "$$tablefile"; \ + done > $@.tmp + set -e; \ + pattern='\s\+LINUX_SYMBOL_PRINTER_\([A-Z0-9_]\+\)\s*'; \ + funcprefix='extract_linux_symbol_'; \ + sed -n 's/^\s*\x23\s*define'"$$pattern$$pattern"'\(\/.*\)\?$$/\x23define '$$funcprefix'\1 '$$funcprefix'\2/p' \ + < linux/syscalls.h | tr '[A-Z]' '[a-z]' > $@ + storage_and_rettype="$$(sed '/^$$/d' < $@.tmp | sed 1q | sed 's/\*/\\\*/g' | sed 's/[^\*]$$/& /')"; \ + sed -n 's/^extract_symbol_.*/'"$${storage_and_rettype}"'&;/p' < $@.tmp | cat - $@.tmp >> $@ + -rm -f -- $@.tmp + set -e; \ + sed 's/, */ /g' < linux/syscalls.h \ + | sed -n 's/^.*LINUX_SYMBOL_PRINTER_\([A-Z0-9_]\+\)\b.*[^$$]\$$\$$\s*SYMBOLS(\(.*\))\s*\$$\$$[^$$].*$$/\1 \2/p' \ + | while read line; do \ + printf '\n'; \ + util/make-multiextractor $$line; \ + done >> $@ + printf '\n\43define LIST_LINUX_EXTRACTORS(X, D)\\\n' >> $@ + set -e; \ + phonies="$$(sed -n '/\$$\$$\$$\s*BEGIN\s\+PHONIES\s*\$$\$$\$$/,/\$$\$$\$$\s*END\s\+PHONIES\s*\$$\$$\$$/p' < linux/syscalls.h \ + | sed -n 's/^\s*LINUX_SYMBOL_PRINTER_\([A-Z0-9_]\+\)\b.*$$/\1/p')"; \ + sed -n 's/^extract_symbol_\([^)]*\)(.*)\s*\/\*\s*\([0-9]\+\)\s*\*\/\s*$$/\1 \2/p' < $@ \ + | while read name n; do \ + if ! printf '%s\n' "$$phonies" | grep -i \^"$$name"\$$ > /dev/null; then \ + printf '\tX(LINUX_SYMBOL_PRINTER_%s, extract_symbol_%s, %i) D\\\n' \ + "$$(printf '%s\n' "$$name" | tr '[a-z]' '[A-Z]')" \ + "$$name" \ + "$$n"; \ + fi; \ + done \ + | sed '$$s/ \D\\$$//' >> $@ + sed 's/extract_symbol/extract_linux_symbol/g' < $@ > $@.tmp && mv -- $@.tmp $@ |