summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorDavid Mosberger <davidm@tiger.hpl.hp.com>2004-01-15 00:39:13 -0800
committerDavid Mosberger <davidm@tiger.hpl.hp.com>2004-01-15 00:39:13 -0800
commit65e199f960e02f3475ffb450f7ec9c94338fcb68 (patch)
tree7044ef3d912778821dde8ac2bc2a0dde70e76ee4 /arch
parentc1e95d8b664b167d9f74b4fa2570941cf90cf32f (diff)
ia64: Replace unwcheck shell-script with a Python script which works
correctly even on 32-bit hosts. As an added bonus, it's faster, too. Run "unwcheck" by default, but for now, don't let unwcheck errors cause the kernel build to fail.
Diffstat (limited to 'arch')
-rw-r--r--arch/ia64/Makefile10
-rwxr-xr-xarch/ia64/scripts/unwcheck.py64
2 files changed, 70 insertions, 4 deletions
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 724240324530..eed40027bb3d 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -9,6 +9,7 @@
#
NM := $(CROSS_COMPILE)nm -B
+READELF := $(CROSS_COMPILE)readelf
export AWK
@@ -71,15 +72,15 @@ boot := arch/ia64/hp/sim/boot
.PHONY: boot compressed check
-all: compressed
+all: compressed unwcheck
compressed: vmlinux.gz
vmlinux.gz: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $@
-check: vmlinux
- arch/ia64/scripts/unwcheck.sh $<
+unwcheck: vmlinux
+ -$(Q)READELF=$(READELF) $(srctree)/arch/ia64/scripts/unwcheck.py $<
archclean:
$(Q)$(MAKE) $(clean)=$(boot)
@@ -88,7 +89,7 @@ CLEAN_FILES += include/asm-ia64/.offsets.h.stamp include/asm-ia64/offsets.h vmli
prepare: include/asm-ia64/offsets.h
-arch/ia64/kernel/asm-offsets.s: include/asm include/linux/version.h
+arch/ia64/kernel/asm-offsets.s: include/asm include/linux/version.h include/config/MARKER
include/asm-ia64/offsets.h: arch/ia64/kernel/asm-offsets.s
$(call filechk,gen-asm-offsets)
@@ -108,4 +109,5 @@ boot: lib/lib.a vmlinux
define archhelp
echo '* compressed - Build compressed kernel image'
echo ' boot - Build vmlinux and bootloader for Ski simulator'
+ echo '* unwcheck - Check vmlinux for invalid unwind info'
endef
diff --git a/arch/ia64/scripts/unwcheck.py b/arch/ia64/scripts/unwcheck.py
new file mode 100755
index 000000000000..c27849889e19
--- /dev/null
+++ b/arch/ia64/scripts/unwcheck.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# Usage: unwcheck.py FILE
+#
+# This script checks the unwind info of each function in file FILE
+# and verifies that the sum of the region-lengths matches the total
+# length of the function.
+#
+# Based on a shell/awk script originally written by Harish Patil,
+# which was converted to Perl by Matthew Chapman, which was converted
+# to Python by David Mosberger.
+#
+import os
+import re
+import sys
+
+if len(sys.argv) != 2:
+ print "Usage: %s FILE" % sys.argv[0]
+ sys.exit(2)
+
+readelf = os.getenv("READELF", "readelf")
+
+start_pattern = re.compile("<([^>]*)>: \[0x([0-9a-f]+)-0x([0-9a-f]+)\]")
+rlen_pattern = re.compile(".*rlen=([0-9]+)")
+
+def check_func (func, slots, rlen_sum):
+ if slots != rlen_sum:
+ global num_errors
+ num_errors += 1
+ if not func: func = "[%#x-%#x]" % (start, end)
+ print "ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum)
+ return
+
+num_funcs = 0
+num_errors = 0
+func = False
+slots = 0
+rlen_sum = 0
+for line in os.popen("%s -u %s" % (readelf, sys.argv[1])):
+ m = start_pattern.match(line)
+ if m:
+ check_func(func, slots, rlen_sum)
+
+ func = m.group(1)
+ start = long(m.group(2), 16)
+ end = long(m.group(3), 16)
+ slots = 3 * (end - start) / 16
+ rlen_sum = 0L
+ num_funcs += 1
+ else:
+ m = rlen_pattern.match(line)
+ if m:
+ rlen_sum += long(m.group(1))
+check_func(func, slots, rlen_sum)
+
+if num_errors == 0:
+ print "No errors detected in %u functions." % num_funcs
+else:
+ if num_errors > 1:
+ err="errors"
+ else:
+ err="error"
+ print "%u %s detected in %u functions." % (num_errors, err, num_funcs)
+ sys.exit(1)