summaryrefslogblamecommitdiffstats
path: root/linux/symbols.mk
blob: ffdad116be05f80f18a446cd61ad056e6794e913 (plain) (tree)
1
2
3

                                                     
                                                                                                                                                 


























                                                                                                   
                                                                                                                                                           









                                                                                                            
                                                                                                                                             



                                                                                
                                                                            
                                             
                                                                                                                                





                                                                                                             
                                                                                                                                                                 





                                                                  


                                                                                                                                                          









                                                                                            
# See LICENSE file for copyright and license details.

LINUX_SYMBOL_TABLES != sed -n 's/^.*LINUX_SYMBOL_PRINTER_\([A-Z0-9_]\{1,\}\)\([^A-Za-z0-9_].*\)*\$$\$$\$$.*\$$\$$\$$.*$$/\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"'\([^A-Za-z0-9_].*\)*\$$\$$\$$$(s)*\(.*\)$(s)*\$$\$$\$$.*$$/\2/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"'\([^A-Za-z0-9_].*\)*\/\*$(s)*\(.*\)$(s)*\$$\$$\$$.*\$$\$$\$$.*$$/\2/p')"; \
		printf '\n'; \
		util/make-sym-extractor "$$tablename" "$$how" < "$$tablefile"; \
	done > $@.tmp
	set -e; \
	pattern='$(s)\{1,\}LINUX_SYMBOL_PRINTER_\([A-Z0-9_]\{1,\}\)$(s)*'; \
	funcprefix='extract_linux_symbol_'; \
	sed -n 's/^$(s)*$(h)$(s)*define'"$$pattern$$pattern"'\(\/.*\)\{0,1\}$$/$(h)define '$$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_]\{1,\}\)\([^A-Za-z0-9_].*[^$$]\|[^A-Za-z0-9_$$]\)\$$\$$$(s)*SYMBOLS(\(.*\))$(s)*\$$\$$[^$$].*$$/\1 \3/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)\{1,\}PHONIES$(s)*\$$\$$\$$/,/\$$\$$\$$$(s)*END$(s)\{1,\}PHONIES$(s)*\$$\$$\$$/p' < linux/syscalls.h \
	            | sed -n 's/^$(s)*LINUX_SYMBOL_PRINTER_\([A-Z0-9_]\{1,\}\)\([^A-Za-z0-9_].*\)*$$/\1/p')"; \
	sed -n 's/^extract_symbol_\([^)]*\)(.*)$(s)*\/\*$(s)*\([0-9]\{1,\}\)$(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 $@