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 || \
865 (echo Inconsistent kallsyms data; \
866 echo This is a bug - please report about it; \
867 echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround; \
868 rm .tmp_kallsyms* ; /bin/false )
869endef
870
871# Update vmlinux version before link
872# Use + in front of this rule to silent warning about make -j1
873# First command is ':' to allow us to use + in front of this rule
874cmd_ksym_ld = $(cmd_vmlinux__)
875define rule_ksym_ld
876 :
877 +$(call cmd,vmlinux_version)
878 $(call cmd,vmlinux__)
879 $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
880endef
881
882# Generate .S file with all kernel symbols
883quiet_cmd_kallsyms = KSYM $@
884 cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \
885 $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@
886 742
887.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE 743vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
888 $(call if_changed_dep,as_o_S)
889 744
890.tmp_kallsyms%.S: .tmp_vmlinux% $(KALLSYMS) 745# Final link of vmlinux
891 $(call cmd,kallsyms) 746 cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
747quiet_cmd_link-vmlinux = LINK $@
892 748
893# .tmp_vmlinux1 must be complete except kallsyms, so update vmlinux version 749# Include targets which we want to
894.tmp_vmlinux1: $(vmlinux-lds) $(vmlinux-all) FORCE 750# execute if the rest of the kernel build went well.
895 $(call if_changed_rule,ksym_ld) 751vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
896
897.tmp_vmlinux2: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms1.o FORCE
898 $(call if_changed,vmlinux__)
899
900.tmp_vmlinux3: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms2.o FORCE
901 $(call if_changed,vmlinux__)
902
903# Needs to visit scripts/ before $(KALLSYMS) can be used.
904$(KALLSYMS): scripts ;
905
906# Generate some data for debugging strange kallsyms problems
907debug_kallsyms: .tmp_map$(last_kallsyms)
908
909.tmp_map%: .tmp_vmlinux% FORCE
910 ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@
911
912.tmp_map3: .tmp_map2
913
914.tmp_map2: .tmp_map1
915
916endif # ifdef CONFIG_KALLSYMS
917
918# Do modpost on a prelinked vmlinux. The finally linked vmlinux has
919# relevant sections renamed as per the linker script.
920quiet_cmd_vmlinux-modpost = LD $@
921 cmd_vmlinux-modpost = $(LD) $(LDFLAGS) -r -o $@ \
922 $(vmlinux-init) --start-group $(vmlinux-main) --end-group \
923 $(filter-out $(vmlinux-init) $(vmlinux-main) FORCE ,$^)
924define rule_vmlinux-modpost
925 :
926 +$(call cmd,vmlinux-modpost)
927 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
928 $(Q)echo 'cmd_$@ := $(cmd_vmlinux-modpost)' > $(dot-target).cmd
929endef
930
931# vmlinux image - including updated kernel symbols
932vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o $(kallsyms.o) FORCE
933ifdef CONFIG_HEADERS_CHECK 752ifdef CONFIG_HEADERS_CHECK
934 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 753 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
935endif 754endif
@@ -939,22 +758,11 @@ endif
939ifdef CONFIG_BUILD_DOCSRC 758ifdef CONFIG_BUILD_DOCSRC
940 $(Q)$(MAKE) $(build)=Documentation 759 $(Q)$(MAKE) $(build)=Documentation
941endif 760endif
942 $(call vmlinux-modpost) 761 +$(call if_changed,link-vmlinux)
943 $(call if_changed_rule,vmlinux__)
944 $(Q)rm -f .old_version
945
946# build vmlinux.o first to catch section mismatch errors early
947ifdef CONFIG_KALLSYMS
948.tmp_vmlinux1: vmlinux.o
949endif
950
951modpost-init := $(filter-out init/built-in.o, $(vmlinux-init))
952vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE
953 $(call if_changed_rule,vmlinux-modpost)
954 762
955# The actual objects are generated when descending, 763# The actual objects are generated when descending,
956# make sure no implicit rule kicks in 764# make sure no implicit rule kicks in
957$(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ; 765$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
958 766
959# Handle descending into subdirectories listed in $(vmlinux-dirs) 767# Handle descending into subdirectories listed in $(vmlinux-dirs)
960# Preset locale variables to speed up the build process. Limit locale 768# Preset locale variables to speed up the build process. Limit locale
@@ -1181,8 +989,6 @@ endif # CONFIG_MODULES
1181 989
1182# Directories & files removed with 'make clean' 990# Directories & files removed with 'make clean'
1183CLEAN_DIRS += $(MODVERDIR) 991CLEAN_DIRS += $(MODVERDIR)
1184CLEAN_FILES += vmlinux System.map \
1185 .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
1186 992
1187# Directories & files removed with 'make mrproper' 993# Directories & files removed with 'make mrproper'
1188MRPROPER_DIRS += include/config usr/include include/generated \ 994MRPROPER_DIRS += include/config usr/include include/generated \
@@ -1428,6 +1234,7 @@ scripts: ;
1428endif # KBUILD_EXTMOD 1234endif # KBUILD_EXTMOD
1429 1235
1430clean: $(clean-dirs) 1236clean: $(clean-dirs)
1237 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1431 $(call cmd,rmdirs) 1238 $(call cmd,rmdirs)
1432 $(call cmd,rmfiles) 1239 $(call cmd,rmfiles)
1433 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ 1240 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
@@ -1568,14 +1375,6 @@ quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1568cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ 1375cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
1569 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) 1376 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*)
1570 1377
1571a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
1572 $(KBUILD_AFLAGS_KERNEL) \
1573 $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \
1574 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1575
1576quiet_cmd_as_o_S = AS $@
1577cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
1578
1579# read all saved command lines 1378# read all saved command lines
1580 1379
1581targets := $(wildcard $(sort $(targets))) 1380targets := $(wildcard $(sort $(targets)))
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 76017c25a9e6..764e37a9dbb3 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -219,8 +219,8 @@ endif
219 219
220KBUILD_AFLAGS += $(cflags-y) 220KBUILD_AFLAGS += $(cflags-y)
221KBUILD_CFLAGS += $(cflags-y) 221KBUILD_CFLAGS += $(cflags-y)
222KBUILD_CPPFLAGS += -D"VMLINUX_LOAD_ADDRESS=$(load-y)" 222KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y)
223KBUILD_CPPFLAGS += -D"DATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)" 223KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
224 224
225LDFLAGS += -m $(ld-emul) 225LDFLAGS += -m $(ld-emul)
226 226
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 55c0661e2b5d..097091059aaa 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -121,15 +121,8 @@ LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
121 121
122LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) 122LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
123 123
124CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) 124# Used by link-vmlinux.sh which has special support for um link
125define cmd_vmlinux__ 125export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
126 $(CC) $(CFLAGS_vmlinux) -o $@ \
127 -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
128 -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
129 -lutil \
130 $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \
131 FORCE ,$^) ; rm -f linux
132endef
133 126
134# When cleaning we don't include .config, so we don't include 127# When cleaning we don't include .config, so we don't include
135# TT or skas makefiles and don't clean skas_ptregs.h. 128# TT or skas makefiles and don't clean skas_ptregs.h.
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
new file mode 100644
index 000000000000..cd9c6c6bb4c9
--- /dev/null
+++ b/scripts/link-vmlinux.sh
@@ -0,0 +1,221 @@
1#!/bin/sh
2#
3# link vmlinux
4#
5# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and
6# $(KBUILD_VMLINUX_MAIN). Most are built-in.o files from top-level directories
7# in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
8# Ordering when linking is important, and $(KBUILD_VMLINUX_INIT) must be first.
9#
10# vmlinux
11# ^
12# |
13# +-< $(KBUILD_VMLINUX_INIT)
14# | +--< init/version.o + more
15# |
16# +--< $(KBUILD_VMLINUX_MAIN)
17# | +--< drivers/built-in.o mm/built-in.o + more
18# |
19# +-< ${kallsymso} (see description in KALLSYMS section)
20#
21# vmlinux version (uname -v) cannot be updated during normal
22# descending-into-subdirs phase since we do not yet know if we need to
23# update vmlinux.
24# Therefore this step is delayed until just before final link of vmlinux.
25#
26# System.map is generated to document addresses of all kernel symbols
27
28# Error out on error
29set -e
30
31# Nice output in kbuild format
32# Will be supressed by "make -s"
33info()
34{
35 if [ "${quiet}" != "silent_" ]; then
36 printf " %-7s %s\n" ${1} ${2}
37 fi
38}
39
40# Link of vmlinux.o used for section mismatch analysis
41# ${1} output file
42modpost_link()
43{
44 ${LD} ${LDFLAGS} -r -o ${1} ${KBUILD_VMLINUX_INIT} \
45 --start-group ${KBUILD_VMLINUX_MAIN} --end-group
46}
47
48# Link of vmlinux
49# ${1} - optional extra .o files
50# ${2} - output file
51vmlinux_link()
52{
53 local lds="${objtree}/${KBUILD_LDS}"
54
55 if [ "${SRCARCH}" != "um" ]; then
56 ${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \
57 -T ${lds} ${KBUILD_VMLINUX_INIT} \
58 --start-group ${KBUILD_VMLINUX_MAIN} --end-group ${1}
59 else
60 ${CC} ${CFLAGS_vmlinux} -o ${2} \
61 -Wl,-T,${lds} ${KBUILD_VMLINUX_INIT} \
62 -Wl,--start-group \
63 ${KBUILD_VMLINUX_MAIN} \
64 -Wl,--end-group \
65 -lutil ${1}
66 rm -f linux
67 fi
68}
69
70
71# Create ${2} .o file with all symbols from the ${1} object file
72kallsyms()
73{
74 info KSYM ${2}
75 local kallsymopt;
76
77 if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then
78 kallsymopt=--all-symbols
79 fi
80
81 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
82 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
83
84 ${NM} -n ${1} | \
85 scripts/kallsyms ${kallsymopt} | \
86 ${CC} ${aflags} -c -o ${2} -x assembler-with-cpp -
87}
88
89# Create map file with all symbols from ${1}
90# See mksymap for additional details
91mksysmap()
92{
93 ${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2}
94}
95
96sortextable()
97{
98 ${objtree}/scripts/sortextable ${1}
99}
100
101# Delete output files in case of error
102trap cleanup SIGHUP SIGINT SIGQUIT SIGTERM ERR
103cleanup()
104{
105 rm -f .old_version
106 rm -f .tmp_System.map
107 rm -f .tmp_kallsyms*
108 rm -f .tmp_version
109 rm -f .tmp_vmlinux*
110 rm -f System.map
111 rm -f vmlinux
112 rm -f vmlinux.o
113}
114
115#
116#
117# Use "make V=1" to debug this script
118case "${KBUILD_VERBOSE}" in
119*1*)
120 set -x
121 ;;
122esac
123
124if [ "$1" = "clean" ]; then
125 cleanup
126 exit 0
127fi
128
129# We need access to CONFIG_ symbols
130. ./.config
131
132#link vmlinux.o
133info LD vmlinux.o
134modpost_link vmlinux.o
135
136# modpost vmlinux.o to check for section mismatches
137${MAKE} -f "${srctree}/scripts/Makefile.modpost" vmlinux.o
138
139# Update version
140info GEN .version
141if [ ! -r .version ]; then
142 rm -f .version;
143 echo 1 >.version;
144else
145 mv .version .old_version;
146 expr 0$(cat .old_version) + 1 >.version;
147fi;
148
149# final build of init/
150${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
151
152kallsymso=""
153kallsyms_vmlinux=""
154if [ -n "${CONFIG_KALLSYMS}" ]; then
155
156 # kallsyms support
157 # Generate section listing all symbols and add it into vmlinux
158 # It's a three step process:
159 # 1) Link .tmp_vmlinux1 so it has all symbols and sections,
160 # but __kallsyms is empty.
161 # Running kallsyms on that gives us .tmp_kallsyms1.o with
162 # the right size
163 # 2) Link .tmp_vmlinux2 so it now has a __kallsyms section of
164 # the right size, but due to the added section, some
165 # addresses have shifted.
166 # From here, we generate a correct .tmp_kallsyms2.o
167 # 2a) We may use an extra pass as this has been necessary to
168 # woraround some alignment related bugs.
169 # KALLSYMS_EXTRA_PASS=1 is used to trigger this.
170 # 3) The correct ${kallsymso} is linked into the final vmlinux.
171 #
172 # a) Verify that the System.map from vmlinux matches the map from
173 # ${kallsymso}.
174
175 kallsymso=.tmp_kallsyms2.o
176 kallsyms_vmlinux=.tmp_vmlinux2
177
178 # step 1
179 vmlinux_link "" .tmp_vmlinux1
180 kallsyms .tmp_vmlinux1 .tmp_kallsyms1.o
181
182 # step 2
183 vmlinux_link .tmp_kallsyms1.o .tmp_vmlinux2
184 kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o
185
186 # step 2a
187 if [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
188 kallsymso=.tmp_kallsyms3.o
189 kallsyms_vmlinux=.tmp_vmlinux3
190
191 vmlinux_link .tmp_kallsyms2.o .tmp_vmlinux3
192
193 kallsyms .tmp_vmlinux3 .tmp_kallsyms3.o
194 fi
195fi
196
197info LD vmlinux
198vmlinux_link "${kallsymso}" vmlinux
199
200if [ -n "${CONFIG_BUILDTIME_EXTABLE_SORT}" ]; then
201 info SORTEX vmlinux
202 sortextable vmlinux
203fi
204
205info SYSMAP System.map
206mksysmap vmlinux System.map
207
208# step a (see comment above)
209if [ -n "${CONFIG_KALLSYMS}" ]; then
210 mksysmap ${kallsyms_vmlinux} .tmp_System.map
211
212 if ! cmp -s System.map .tmp_System.map; then
213 echo Inconsistent kallsyms data
214 echo echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround
215 cleanup
216 exit 1
217 fi
218fi
219
220# We made a new kernel - delete old version file
221rm -f .old_version