Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: fix building bzImage with CONFIG_TRIM_UNUSED_KSYMS enabled

When building a specific target such as bzImage, modules aren't normally
built. However if CONFIG_TRIM_UNUSED_KSYMS is enabled, no built modules
means none of the exported symbols are used and therefore they will all
be trimmed away from the final kernel. A subsequent "make modules" will
fail because modpost cannot find the needed symbols for those modules in
the kernel binary.

Let's make sure modules are also built whenever CONFIG_TRIM_UNUSED_KSYMS
is enabled and that the kernel binary is properly rebuilt accordingly.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Nicolas Pitre and committed by
Linus Torvalds
86556392 8dc0f265

+8 -1
+8 -1
Makefile
··· 607 607 include/config/auto.conf: ; 608 608 endif # $(dot-config) 609 609 610 + # For the kernel to actually contain only the needed exported symbols, 611 + # we have to build modules as well to determine what those symbols are. 612 + # (this can be evaluated only once include/config/auto.conf has been included) 613 + ifdef CONFIG_TRIM_UNUSED_KSYMS 614 + KBUILD_MODULES := 1 615 + endif 616 + 610 617 # The all: target is the default when no target is given on the 611 618 # command line. 612 619 # This allow a user to issue only 'make' to build a kernel including modules ··· 951 944 endif 952 945 ifdef CONFIG_TRIM_UNUSED_KSYMS 953 946 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ 954 - "$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile vmlinux_prereq" 947 + "$(MAKE) -f $(srctree)/Makefile vmlinux" 955 948 endif 956 949 957 950 # standalone target for easier testing