Strip Linux kernel sources according to .config

Is there an effective way (maybe abuse of the gcc preprocessor?) To get a set of shared kernel sources where all the code that is not needed according to .config is missing?

+5
source share
2 answers

Well, some steps to the solution.

First, you can use compiler commands with

make KBUILD_VERBOSE=1 | tee build.log
grep '^  gcc' build.log

Currently, I select only one gcc command line for further steps. For example, the kernel / kmod.c assembly looks like this:

gcc <LIST OF MANY OPTIONS> -c -o kernel/kmod.o kernel/kmod.c

-c, -o ... -E, . -fdirectives-only -undef , GNU. -nostdinc, c, make .

, , . , grep, : grep -v '#include' kernel/kmod.c. : autoconf.h Makefile. , , #ifdef CONFIG_... .

#define autoconf.h grep -v '^#'.

:

grep -v '#include' kernel/kmod.c | gcc -E -fdirectives-only -undef <ORIGINAL KERNEL BUILD GCC OPTIONS WITHOUT -c AND -o ...> - |grep -v '^#'

/kmod.c, , kmod.o.

: ? , , ?

+2

atime, , . , , , .

0

All Articles