Commit 62fb568f authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] detect uninitialised per-cpu storage

So poor old Dave spent days hunting down memory corruption because the
`kstat' per-cpu storage is not initialised (it needs to be, it's a workaround
for ancient gcc's).

The same problem had me hunting for a day too.

This patch, based on an initial version from Rusty will
parse System.map at final link and will fail the build if
any per-cpu symbols are found to be not in the percpu section.
parent 9cb761fc
......@@ -299,6 +299,8 @@ define cmd_vmlinux__
endef
# set -e makes the rule exit immediately on error
# Final awk script makes sure per-cpu vars are in per-cpu section, as
# old gcc (eg egcs 2.92.11) ignores section attribute if uninitialized.
define rule_vmlinux__
set -e
......@@ -312,11 +314,22 @@ define rule_vmlinux__
echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
endef
define rule_vmlinux
define rule_vmlinux_no_percpu
$(rule_vmlinux__)
$(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
endef
ifdef CONFIG_SMP
define rule_vmlinux
$(rule_vmlinux_no_percpu)
$(AWK) -f scripts/per-cpu-check.awk < System.map
endef
else
define rule_vmlinux
$(rule_vmlinux_no_percpu)
endef
endif
LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s
# Generate section listing all symbols and add it into vmlinux
......
/ __per_cpu_start$$/ {
IN_PER_CPU=1
}
/ __per_cpu_end$$/ {
IN_PER_CPU=0
}
/__per_cpu$$/ && ! / __ksymtab_/ {
if (!IN_PER_CPU) {
print $$3 " not in per-cpu section" > "/dev/stderr";
FOUND=1;
}
}
END {
exit FOUND;
}
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