Commit f0a59f6c authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Fix kallsyms build

After reverting my nice but totally broken idea about accelerating
the linking steps, make the three-stage .tmp_kallsyms.o generation
/ addition work again.

Yeah, that means that we now link vmlinux three times when
CONFIG_KALLSYMS is set, and that's annoying.
parent b60b198f
...@@ -285,8 +285,8 @@ export MODLIB ...@@ -285,8 +285,8 @@ export MODLIB
vmlinux-objs := $(HEAD) $(init-y) $(core-y) $(libs-y) $(drivers-y) $(net-y) vmlinux-objs := $(HEAD) $(init-y) $(core-y) $(libs-y) $(drivers-y) $(net-y)
quiet_cmd_link_vmlinux = LD $@ quiet_cmd_vmlinux__ = LD $@
define cmd_link_vmlinux define cmd_vmlinux__
$(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(HEAD) $(init-y) \ $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) $(HEAD) $(init-y) \
--start-group \ --start-group \
$(core-y) \ $(core-y) \
...@@ -294,20 +294,26 @@ define cmd_link_vmlinux ...@@ -294,20 +294,26 @@ define cmd_link_vmlinux
$(drivers-y) \ $(drivers-y) \
$(net-y) \ $(net-y) \
--end-group \ --end-group \
$(filter $(kallsyms.o),$^) \ $(filter .tmp_kallsyms%,$^) \
-o $@ -o $@
endef endef
# set -e makes the rule exit immediately on error # set -e makes the rule exit immediately on error
define rule_vmlinux define rule_vmlinux__
set -e set -e
echo ' Generating build number' $(if $(filter .tmp_kallsyms%,$^),,
. scripts/mkversion > .tmp_version echo ' Generating build number'
mv -f .tmp_version .version . scripts/mkversion > .tmp_version
+$(call descend,init,) mv -f .tmp_version .version
$(call cmd,link_vmlinux) +$(call descend,init,)
echo 'cmd_$@ := $(cmd_link_vmlinux)' > $(@D)/.$(@F).cmd )
$(call cmd,vmlinux__)
echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
endef
define rule_vmlinux
$(rule_vmlinux__)
$(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
endef endef
...@@ -315,44 +321,33 @@ LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s ...@@ -315,44 +321,33 @@ LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s
# Generate section listing all symbols and add it into vmlinux # Generate section listing all symbols and add it into vmlinux
# It's a three stage process: # It's a three stage process:
# o .tmp_vmlinux has all symbols and sections, but __kallsyms is # o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
# empty # empty
# Running kallsyms on that gives as .tmp_kallsyms1.o with # Running kallsyms on that gives as .tmp_kallsyms1.o with
# the right size # the right size
# o .tmp_vmlinux1 now has a __kallsyms section of the right size, # o .tmp_vmlinux2 now has a __kallsyms section of the right size,
# but due to the added section, some addresses have shifted # but due to the added section, some addresses have shifted
# From here, we generate a correct .tmp_kallsyms.o # From here, we generate a correct .tmp_kallsyms2.o
# o The correct .tmp_kallsyms.o is linked into the final vmlinux # o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
# below.
ifdef CONFIG_KALLSYMS ifdef CONFIG_KALLSYMS
kallsyms.o := .tmp_kallsyms.o kallsyms.o := .tmp_kallsyms2.o
quiet_cmd_kallsyms = KSYM $@ quiet_cmd_kallsyms = KSYM $@
cmd_kallsyms = $(KALLSYMS) $< > $@ cmd_kallsyms = $(KALLSYMS) $< > $@
cmd_kallsyms = \
$(KALLSYMS) $< > .tmp_kallsyms1.o; \ .tmp_kallsyms1.o: .tmp_vmlinux1
$(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) .tmp_vmlinux .tmp_kallsyms1.o \
-o .tmp_vmlinux1; \
$(KALLSYMS) .tmp_vmlinux1 > $@; \
rm -f .tmp_kallsyms1.o .tmp_vmlinux1
.tmp_kallsyms.o: .tmp_vmlinux
$(call cmd,kallsyms) $(call cmd,kallsyms)
# After generating .tmp_vmlinux just like vmlinux, decrement the version .tmp_kallsyms2.o: .tmp_vmlinux2
# number again, so the final vmlinux gets the same one. $(call cmd,kallsyms)
# Ignore return value of 'expr'.
define rule_.tmp_vmlinux .tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE
$(rule_vmlinux) $(call if_changed_rule,vmlinux__)
if expr 0`cat .version` - 1 > .tmp_version; then true; fi
mv -f .tmp_version .version
endef
.tmp_vmlinux: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE .tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/vmlinux.lds.s FORCE
$(call if_changed_rule,.tmp_vmlinux) $(call if_changed_rule,vmlinux__)
endif endif
...@@ -393,17 +388,17 @@ targets += arch/$(ARCH)/vmlinux.lds.s ...@@ -393,17 +388,17 @@ targets += arch/$(ARCH)/vmlinux.lds.s
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
%.s: %.c FORCE %.s: %.c FORCE
+@$(call descend,$(@D),$(@F)) +@$(call descend,$(@D),$@)
%.i: %.c FORCE %.i: %.c FORCE
+@$(call descend,$(@D),$(@F)) +@$(call descend,$(@D),$@)
%.o: %.c FORCE %.o: %.c FORCE
+@$(call descend,$(@D),$(@F)) +@$(call descend,$(@D),$@)
%.lst: %.c FORCE %.lst: %.c FORCE
+@$(call descend,$(@D),$(@F)) +@$(call descend,$(@D),$@)
%.s: %.S FORCE %.s: %.S FORCE
+@$(call descend,$(@D),$(@F)) +@$(call descend,$(@D),$@)
%.o: %.S FORCE %.o: %.S FORCE
+@$(call descend,$(@D),$(@F)) +@$(call descend,$(@D),$@)
# FIXME: The asm symlink changes when $(ARCH) changes. That's # FIXME: The asm symlink changes when $(ARCH) changes. That's
# hard to detect, but I suppose "make mrproper" is a good idea # hard to detect, but I suppose "make mrproper" is a good idea
......
...@@ -9,7 +9,7 @@ CC=$4 ...@@ -9,7 +9,7 @@ CC=$4
# So "sudo make install" won't change the "compiled by <user>" # So "sudo make install" won't change the "compiled by <user>"
# do "compiled by root" # do "compiled by root"
if [ -r $TARGET -a ! -O ../include/linux/autoconf.h ]; then if [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then
echo ' (not modified)' echo ' (not modified)'
exit 0 exit 0
fi fi
...@@ -17,11 +17,11 @@ fi ...@@ -17,11 +17,11 @@ fi
# Do not expand names # Do not expand names
set -f set -f
if [ -r ../.version ]; then if [ -r .version ]; then
VERSION=`cat ../.version` VERSION=`cat .version`
else else
VERSION=0 VERSION=0
echo 0 > ../.version echo 0 > .version
fi fi
...@@ -76,4 +76,4 @@ else ...@@ -76,4 +76,4 @@ else
echo ' (updated)' echo ' (updated)'
mv -f .tmpcompile $TARGET mv -f .tmpcompile $TARGET
fi fi
rm -f .tmpver.1 .tmpver.2 #rm -f .tmpver.1 .tmpver.2
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment