export symbol report: export-symbol usage report generator.
PATCH 2/3 export symbol report: export-symbol usage report generator.
The following patch provides the ability to generate a report of
(1) All the exported symbols and their in-kernel-module usage count
(2) For each module, lists the modules and their exported symbols, on which it depends.
The report generation is integrated in the build process. 'make exportcheck' prints out the report.
'make exportcheck EXPORTFILE=Documentation/export_report.txt'
generates the report in the file Documentation/export_report.txt
NOTE: the same report can also be generated by executing
perl scripts/export_report
Signed-off-by Ram Pai <[email protected]>
Makefile | 16 ++++- scripts/Makefile.modpost | 7 ++ scripts/export_report.pl | 148 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+), 1 deletion(-)
scripts/Makefile.modpost +7 -0
@@ -60,9 +60,16 @@ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(filter-out FORCE,$^) +quiet_cmd_importfile = IMPORT_EXTRACT + cmd_importfile = perl $(objtree)/scripts/export_report.pl \ + -k $(kernelsymfile) \ + $(if $(KBUILD_EXPORT_REPORT:1=),-o $(KBUILD_EXPORT_REPORT),) \ + -f $(patsubst %.o,%.mod.c,$(filter-out vmlinux FORCE, $^)) + PHONY += __modpost __modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE $(call cmd,modpost) + $(if $(KBUILD_EXPORT_REPORT), $(call cmd,importfile)) # Declare generated files as targets for modpost $(symverfile): __modpost ;
scripts/export_report.pl new file +148 -0
148 lines not on this page · raw message
Makefile +15 -1
@@ -207,7 +207,7 @@ # in addition to whatever we do anyway. # Just "make" or "make all" shall build modules as well -ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) +ifneq ($(filter all _all modules exportcheck,$(MAKECMDGOALS)),) KBUILD_MODULES := 1 endif
@@ -1029,6 +1029,8 @@ @echo ' cscope - Generate cscope index' @echo ' kernelrelease - Output the release version string' @echo ' kernelversion - Output the version stored in Makefile' + @echo ' exportcheck [EXPORTFILE=file] - Export symbol usage analysis ' + @echo ' on compiled kernel' @echo '' @echo 'Static analysers' @echo ' checkstack - Generate a list of stack hogs'
@@ -1259,6 +1261,18 @@ namespacecheck: $(PERL) $(srctree)/scripts/namespace.pl +ifeq ($(MAKECMDGOALS), exportcheck) + KBUILD_EXPORT_REPORT := 1 + ifdef EXPORTFILE + ifeq ("$(origin EXPORTFILE)", "command line") + KBUILD_EXPORT_REPORT = $(EXPORTFILE) + endif + endif + export KBUILD_EXPORT_REPORT +endif +PHONY += exportcheck +exportcheck: vmlinux modules + endif #ifeq ($(config-targets),1) endif #ifeq ($(mixed-targets),1)