Re: binutils woes

From: Russell King
Date: Thu Jul 01 2004 - 17:16:49 EST


On Thu, Jul 01, 2004 at 08:52:55PM +0100, Russell King wrote:
> Therefore, unless anyone has any objections, I shall be cooking up
> a patch which adds an extra pass to any final object link for the
> kernel build system.

Ok, I decided that touching the rules used for the boot loader(s) was
probably going to be too fraught, so here's one which just checks the
final link for the main kernel image.

Essentially, we run 'nm' against the object, and look for any line
which matches the pattern '^ *U '. With this, a failing output looks
like:

LD init/built-in.o
LD .tmp_vmlinux1
ldchk: .tmp_vmlinux1: final image has undefined symbols:
SIZEOF_MACHINE_DESC
make[1]: *** [.tmp_vmlinux1] Error 1
make: *** [vmlinux] Error 2

and successful output:

LD init/built-in.o
LD .tmp_vmlinux1
KSYM .tmp_kallsyms1.S
AS .tmp_kallsyms1.o
LD .tmp_vmlinux2
KSYM .tmp_kallsyms2.S
AS .tmp_kallsyms2.o
LD vmlinux


===== Makefile 1.500 vs edited =====
--- 1.500/Makefile Tue Jun 29 15:44:49 2004
+++ edited/Makefile Thu Jul 1 23:10:04 2004
@@ -533,6 +533,8 @@
endef

# set -e makes the rule exit immediately on error
+# Note: Ensure that there are no undefined symbols in the final
+# linked image. Not doing this can lead to silent link failures.

define rule_vmlinux__
+set -e; \
@@ -545,6 +547,12 @@
$(if $($(quiet)cmd_vmlinux__), \
echo ' $($(quiet)cmd_vmlinux__)' &&) \
$(cmd_vmlinux__); \
+ if $(NM) $@ | grep -q '^ *U '; then \
+ echo 'ldchk: $@: final image has undefined symbols:'; \
+ $(NM) $@ | sed 's/^ *U \(.*\)/ \1/p;d'; \
+ $(RM) -f $@; \
+ exit 1; \
+ fi; \
echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
endef



--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/