The configuration of the Linux kernel eventually defines what the preprocessor directives for the C compiler are. The output from the preprocessed sources should be close to what you are looking for, although there also might be dead code that is optimised out by the compiler.
The gcc
compiler can be told to generate the preprocessed output to stdout using -E
(and then stop):
-E Stop after the preprocessing stage; do not run the compiler
proper. The output is in the form of preprocessed source code,
which is sent to the standard output.
For the whole kernel it might be more easy to incorporate the --save-temps
compiler flag:
-save-temps
-save-temps=cwd
Store the usual "temporary" intermediate files permanently; place
them in the current directory and name them based on the source
file. Thus, compiling foo.c with -c -save-temps would produce
files foo.i and foo.s, as well as foo.o. This creates a
preprocessed foo.i output file even though the compiler now
normally uses an integrated preprocessor.
When used in combination with the -x command line option,
-save-temps is sensible enough to avoid over writing an input
source file with the same extension as an intermediate file. The
corresponding intermediate file may be obtained by renaming the
source file before using -save-temps.