diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-28 13:32:28 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-28 13:32:28 -0400 |
| commit | 1347a2cebcb4cd6ca94eda0ebc8c5c6825bc4544 (patch) | |
| tree | 495eb1b7071a0890c1fa58c12139ebd6305e0e82 | |
| parent | 90324cc1b11a211e37eabd8cb863e1a1561d6b1d (diff) | |
| parent | f7fc237e330deaaea4ba6726b603d4058d1e6b38 (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.txt | 19 | ||||
| -rw-r--r-- | Makefile | 231 | ||||
| -rw-r--r-- | arch/mips/Makefile | 4 | ||||
| -rw-r--r-- | arch/um/Makefile | 11 | ||||
| -rw-r--r-- | scripts/link-vmlinux.sh | 221 |
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 | -------------------------------------------------- |
| 51 | Additional options used for $(LD) when linking modules. | 51 | Additional options used for $(LD) when linking modules. |
| 52 | 52 | ||
| 53 | LDFLAGS_vmlinux | ||
| 54 | -------------------------------------------------- | ||
| 55 | Additional options passed to final link of vmlinux. | ||
| 56 | |||
| 53 | KBUILD_VERBOSE | 57 | KBUILD_VERBOSE |
| 54 | -------------------------------------------------- | 58 | -------------------------------------------------- |
| 55 | Set the kbuild verbosity. Can be assigned same values as "V=...". | 59 | Set the kbuild verbosity. Can be assigned same values as "V=...". |
| @@ -214,3 +218,18 @@ KBUILD_BUILD_USER, KBUILD_BUILD_HOST | |||
| 214 | These two variables allow to override the user@host string displayed during | 218 | These two variables allow to override the user@host string displayed during |
| 215 | boot and in /proc/version. The default value is the output of the commands | 219 | boot and in /proc/version. The default value is the output of the commands |
| 216 | whoami and host, respectively. | 220 | whoami and host, respectively. |
| 221 | |||
| 222 | KBUILD_LDS | ||
| 223 | -------------------------------------------------- | ||
| 224 | The linker script with full path. Assigned by the top-level Makefile. | ||
| 225 | |||
| 226 | KBUILD_VMLINUX_INIT | ||
| 227 | -------------------------------------------------- | ||
| 228 | All object files for the init (first) part of vmlinux. | ||
| 229 | Files specified with KBUILD_VMLINUX_INIT are linked first. | ||
| 230 | |||
| 231 | KBUILD_VMLINUX_MAIN | ||
| 232 | -------------------------------------------------- | ||
| 233 | All object files for the main part of vmlinux. | ||
| 234 | KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN together specify | ||
| 235 | all the object files used to link vmlinux. | ||
| @@ -231,10 +231,6 @@ endif | |||
| 231 | # Where to locate arch specific headers | 231 | # Where to locate arch specific headers |
| 232 | hdr-arch := $(SRCARCH) | 232 | hdr-arch := $(SRCARCH) |
| 233 | 233 | ||
| 234 | ifeq ($(ARCH),m68knommu) | ||
| 235 | hdr-arch := m68k | ||
| 236 | endif | ||
| 237 | |||
| 238 | KCONFIG_CONFIG ?= .config | 234 | KCONFIG_CONFIG ?= .config |
| 239 | export KCONFIG_CONFIG | 235 | export KCONFIG_CONFIG |
| 240 | 236 | ||
| @@ -341,7 +337,6 @@ AWK = awk | |||
| 341 | GENKSYMS = scripts/genksyms/genksyms | 337 | GENKSYMS = scripts/genksyms/genksyms |
| 342 | INSTALLKERNEL := installkernel | 338 | INSTALLKERNEL := installkernel |
| 343 | DEPMOD = /sbin/depmod | 339 | DEPMOD = /sbin/depmod |
| 344 | KALLSYMS = scripts/kallsyms | ||
| 345 | PERL = perl | 340 | PERL = perl |
| 346 | CHECK = sparse | 341 | CHECK = sparse |
| 347 | 342 | ||
| @@ -739,197 +734,21 @@ libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) | |||
| 739 | libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) | 734 | libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) |
| 740 | libs-y := $(libs-y1) $(libs-y2) | 735 | libs-y := $(libs-y1) $(libs-y2) |
| 741 | 736 | ||
| 742 | # Build vmlinux | 737 | # Externally visible symbols (used by link-vmlinux.sh) |
| 743 | # --------------------------------------------------------------------------- | 738 | export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) |
| 744 | # vmlinux is built from the objects selected by $(vmlinux-init) and | 739 | export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y) |
| 745 | # $(vmlinux-main). Most are built-in.o files from top-level directories | 740 | export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds |
| 746 | # in the kernel tree, others are specified in arch/$(ARCH)/Makefile. | 741 | export 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 | |||
| 769 | vmlinux-init := $(head-y) $(init-y) | ||
| 770 | vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) | ||
| 771 | vmlinux-all := $(vmlinux-init) $(vmlinux-main) | ||
| 772 | vmlinux-lds := arch/$(SRCARCH)/kernel/vmlinux.lds | ||
| 773 | export KBUILD_VMLINUX_OBJS := $(vmlinux-all) | ||
| 774 | |||
| 775 | # Rule to link vmlinux - also used during CONFIG_KALLSYMS | ||
| 776 | # May be overridden by arch/$(ARCH)/Makefile | ||
| 777 | quiet_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 | ||
| 784 | quiet_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 | ||
| 796 | quiet_cmd_sysmap = SYSMAP | ||
| 797 | cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap | ||
| 798 | |||
| 799 | # Sort exception table at build time | ||
| 800 | quiet_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 | ||
| 808 | define 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) | ||
| 829 | endef | ||
| 830 | |||
| 831 | |||
| 832 | ifdef 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 | |||
| 850 | last_kallsyms := 2 | ||
| 851 | |||
| 852 | ifdef KALLSYMS_EXTRA_PASS | ||
| 853 | ifneq ($(KALLSYMS_EXTRA_PASS),0) | ||
| 854 | last_kallsyms := 3 | ||
| 855 | endif | ||
| 856 | endif | ||
| 857 | |||
| 858 | kallsyms.o := .tmp_kallsyms$(last_kallsyms).o | ||
| 859 | |||
| 860 | define 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 || | ||
