Skip to contentSkip to conversation

export symbol report: export-symbol usage report generator.

PATCH In review Ram Pai 1 participant 1 message Apr 22, 2006 Kbuild

lore
Share & tools
lore

Ram Pai

author
#0 lore raw

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

 Makefile                 |   16 ++++-
 scripts/Makefile.modpost |    7 ++
 scripts/export_report.pl |  148 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 170 insertions(+), 1 deletion(-)
scripts/Makefile.modpost +7 -0
Index: linux-2.6.17-rc1/scripts/Makefile.modpost
===================================================================
@@ -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
Index: linux-2.6.17-rc1/Makefile
===================================================================
@@ -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)