aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-28 13:32:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-28 13:32:28 -0400
commit1347a2cebcb4cd6ca94eda0ebc8c5c6825bc4544 (patch)
tree495eb1b7071a0890c1fa58c12139ebd6305e0e82
parent90324cc1b11a211e37eabd8cb863e1a1561d6b1d (diff)
parentf7fc237e330deaaea4ba6726b603d4058d1e6b38 (diff)
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kbuild updates from Michal Marek. Fixed up nontrivial merge conflict in Makefile as per Stephen Rothwell and linux-next (and trivial arch/sparc/Makefile changes due to removed sparc32 logic). * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: mips: Fix KBUILD_CPPFLAGS definition kbuild: fix ia64 link kbuild: document KBUILD_LDS, KBUILD_VMLINUX_{INIT,MAIN} and LDFLAGS_vmlinux kbuild: link of vmlinux moved to a script kbuild: refactor final link of sparc32 kbuild: drop unused KBUILD_VMLINUX_OBJS from top-level Makefile kbuild: Makefile: remove unnecessary check for m68knommu ARCH
-rw-r--r--Documentation/kbuild/kbuild.txt19
-rw-r--r--Makefile231
-rw-r--r--arch/mips/Makefile4
-rw-r--r--arch/um/Makefile11
-rw-r--r--scripts/link-vmlinux.sh221
5 files changed, 259 insertions, 227 deletions
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 68e32bb6bd80..6466704d47b5 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -50,6 +50,10 @@ LDFLAGS_MODULE
50-------------------------------------------------- 50--------------------------------------------------
51Additional options used for $(LD) when linking modules. 51Additional options used for $(LD) when linking modules.
52 52
53LDFLAGS_vmlinux
54--------------------------------------------------
55Additional options passed to final link of vmlinux.
56
53KBUILD_VERBOSE 57KBUILD_VERBOSE
54-------------------------------------------------- 58--------------------------------------------------
55Set the kbuild verbosity. Can be assigned same values as "V=...". 59Set the kbuild verbosity. Can be assigned same values as "V=...".
@@ -214,3 +218,18 @@ KBUILD_BUILD_USER, KBUILD_BUILD_HOST
214These two variables allow to override the user@host string displayed during 218These two variables allow to override the user@host string displayed during
215boot and in /proc/version. The default value is the output of the commands 219boot and in /proc/version. The default value is the output of the commands
216whoami and host, respectively. 220whoami and host, respectively.
221
222KBUILD_LDS
223--------------------------------------------------
224The linker script with full path. Assigned by the top-level Makefile.
225
226KBUILD_VMLINUX_INIT
227--------------------------------------------------
228All object files for the init (first) part of vmlinux.
229Files specified with KBUILD_VMLINUX_INIT are linked first.
230
231KBUILD_VMLINUX_MAIN
232--------------------------------------------------
233All object files for the main part of vmlinux.
234KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN together specify
235all the object files used to link vmlinux.
diff --git a/Makefile b/Makefile
index b62c1e09444a..dda21c3efc7b 100644
--- a/Makefile
+++ b/Makefile
@@ -231,10 +231,6 @@ endif
231# Where to locate arch specific headers 231# Where to locate arch specific headers
232hdr-arch := $(SRCARCH) 232hdr-arch := $(SRCARCH)
233 233
234ifeq ($(ARCH),m68knommu)
235 hdr-arch := m68k
236endif
237
238KCONFIG_CONFIG ?= .config 234KCONFIG_CONFIG ?= .config
239export KCONFIG_CONFIG 235export KCONFIG_CONFIG
240 236
@@ -341,7 +337,6 @@ AWK = awk
341GENKSYMS = scripts/genksyms/genksyms 337GENKSYMS = scripts/genksyms/genksyms
342INSTALLKERNEL := installkernel 338INSTALLKERNEL := installkernel
343DEPMOD = /sbin/depmod 339DEPMOD = /sbin/depmod
344KALLSYMS = scripts/kallsyms
345PERL = perl 340PERL = perl
346CHECK = sparse 341CHECK = sparse
347 342
@@ -739,197 +734,21 @@ libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
739libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) 734libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
740libs-y := $(libs-y1) $(libs-y2) 735libs-y := $(libs-y1) $(libs-y2)
741 736
742# Build vmlinux 737# Externally visible symbols (used by link-vmlinux.sh)
743# --------------------------------------------------------------------------- 738export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
744# vmlinux is built from the objects selected by $(vmlinux-init) and 739export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y)
745# $(vmlinux-main). Most are built-in.o files from top-level directories 740export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
746# in the kernel tree, others are specified in arch/$(ARCH)/Makefile. 741export LDFLAGS_vmlinux
747# Ordering when linking is important, and $(vmlinux-init) must be first.
748#
749# vmlinux
750# ^
751# |
752# +-< $(vmlinux-init)
753# | +--< init/version.o + more
754# |
755# +--< $(vmlinux-main)
756# | +--< driver/built-in.o mm/built-in.o + more
757# |
758# +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
759#
760# vmlinux version (uname -v) cannot be updated during normal
761# descending-into-subdirs phase since we do not yet know if we need to
762# update vmlinux.
763# Therefore this step is delayed until just before final link of vmlinux -
764# except in the kallsyms case where it is done just before adding the
765# symbols to the kernel.
766#
767# System.map is generated to document addresses of all kernel symbols
768
769vmlinux-init := $(head-y) $(init-y)
770vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y)
771vmlinux-all := $(vmlinux-init) $(vmlinux-main)
772vmlinux-lds := arch/$(SRCARCH)/kernel/vmlinux.lds
773export KBUILD_VMLINUX_OBJS := $(vmlinux-all)
774
775# Rule to link vmlinux - also used during CONFIG_KALLSYMS
776# May be overridden by arch/$(ARCH)/Makefile
777quiet_cmd_vmlinux__ ?= LD $@
778 cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@ \
779 -T $(vmlinux-lds) $(vmlinux-init) \
780 --start-group $(vmlinux-main) --end-group \
781 $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o FORCE ,$^)
782
783# Generate new vmlinux version
784quiet_cmd_vmlinux_version = GEN .version
785 cmd_vmlinux_version = set -e; \
786 if [ ! -r .version ]; then \
787 rm -f .version; \
788 echo 1 >.version; \
789 else \
790 mv .version .old_version; \
791 expr 0$$(cat .old_version) + 1 >.version; \
792 fi; \
793 $(MAKE) $(build)=init
794
795# Generate System.map
796quiet_cmd_sysmap = SYSMAP
797 cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
798
799# Sort exception table at build time
800quiet_cmd_sortextable = SORTEX
801 cmd_sortextable = $(objtree)/scripts/sortextable
802
803# Link of vmlinux
804# If CONFIG_KALLSYMS is set .version is already updated
805# Generate System.map and verify that the content is consistent
806# Use + in front of the vmlinux_version rule to silent warning with make -j2
807# First command is ':' to allow us to use + in front of the rule
808define rule_vmlinux__
809 :
810 $(if $(CONFIG_KALLSYMS),,+$(call cmd,vmlinux_version))
811
812 $(call cmd,vmlinux__)
813 $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
814
815 $(if $(CONFIG_BUILDTIME_EXTABLE_SORT), \
816 $(Q)$(if $($(quiet)cmd_sortextable), \
817 echo ' $($(quiet)cmd_sortextable) vmlinux' &&) \
818 $(cmd_sortextable) vmlinux)
819
820
821 $(Q)$(if $($(quiet)cmd_sysmap), \
822 echo ' $($(quiet)cmd_sysmap) System.map' &&) \
823 $(cmd_sysmap) $@ System.map; \
824 if [ $$? -ne 0 ]; then \
825 rm -f $@; \
826 /bin/false; \
827 fi;
828 $(verify_kallsyms)
829endef
830
831
832ifdef CONFIG_KALLSYMS
833# Generate section listing all symbols and add it into vmlinux $(kallsyms.o)
834# It's a three stage process:
835# o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
836# empty
837# Running kallsyms on that gives us .tmp_kallsyms1.o with
838# the right size - vmlinux version (uname -v) is updated during this step
839# o .tmp_vmlinux2 now has a __kallsyms section of the right size,
840# but due to the added section, some addresses have shifted.
841# From here, we generate a correct .tmp_kallsyms2.o
842# o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
843# o Verify that the System.map from vmlinux matches the map from
844# .tmp_vmlinux2, just in case we did not generate kallsyms correctly.
845# o If 'make KALLSYMS_EXTRA_PASS=1" was used, do an extra pass using
846# .tmp_vmlinux3 and .tmp_kallsyms3.o. This is only meant as a
847# temporary bypass to allow the kernel to be built while the
848# maintainers work out what went wrong with kallsyms.
849
850last_kallsyms := 2
851
852ifdef KALLSYMS_EXTRA_PASS
853ifneq ($(KALLSYMS_EXTRA_PASS),0)
854last_kallsyms := 3
855endif
856endif
857
858kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
859
860define verify_kallsyms
861 $(Q)$(if $($(quiet)cmd_sysmap), \
862 echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \
863 $(cmd_sysmap) .tmp_vmlinux$(last_kallsyms) .tmp_System.map
864 $(Q)cmp -s System.map .tmp_System.map ||