[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#392592: proposed patches



Here's a couple patches that fix this bug.

The first is a patch to linux-kbuild-2.6. It adds support for
including arch-specific files. Most of it is the addition of the
arch/ia64/scripts files.

The second is a patch to linux-2.6 that checks to see if there is an
arch-specific scripts dir. If so, it symlinks this dir back to the
linux-kbuild tree.

Bastian: Please let me know if this method is acceptable to you. If it
         is not, what changes are required?

diff -urN linux-kbuild-2.6-2.6.18.orig/src/Makefile linux-kbuild-2.6-2.6.18/src/Makefile
--- linux-kbuild-2.6-2.6.18.orig/src/Makefile	2006-11-22 03:05:12.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/src/Makefile	2006-11-22 01:13:41.552095256 -0700
@@ -1,3 +1,6 @@
+ARCH = $(shell dpkg-architecture | grep ^DEB_BUILD_ARCH= | cut -d= -f2)
+-include arch-inc/$(ARCH).inc
+
 PROGS = \
 	bin2c \
 	conmakehash \
diff -urN linux-kbuild-2.6-2.6.18.orig/src/Makefile.inc linux-kbuild-2.6-2.6.18/src/Makefile.inc
--- linux-kbuild-2.6-2.6.18.orig/src/Makefile.inc	2006-11-22 03:05:12.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/src/Makefile.inc	2006-11-22 02:46:16.179023153 -0700
@@ -26,8 +26,16 @@
 	  echo " install -D '$(top_srcdir)/scripts/$(OUTDIR)/$$p' '$(prefix)/scripts/$(OUTDIR)/$$p'"; \
 	  install -D -m755 "$(top_srcdir)/scripts/$(OUTDIR)/$$p" "$(prefix)/scripts/$(OUTDIR)/$$p"; \
 	done
+	@list='$(ARCHSCRIPTS)'; for p in $$list; do \
+	  echo " install -D '$(top_srcdir)/arch/$(ARCH)/scripts/(OUTDIR)/$$p' '$(prefix)/arch/$(ARCH)/scripts/$(OUTDIR)/$$p'"; \
+	  install -D -m755 "$(top_srcdir)/arch/$(ARCH)/scripts/$(OUTDIR)/$$p" "$(prefix)/arch/$(ARCH)/scripts/$(OUTDIR)/$$p"; \
+	done
 	@list='$(DATA)'; for p in $$list; do \
 	  echo " install -D '$(top_srcdir)/scripts/$(OUTDIR)/$$p' '$(prefix)/scripts/$(OUTDIR)/$$p'"; \
 	  install -D -m644 "$(top_srcdir)/scripts/$(OUTDIR)/$$p" "$(prefix)/scripts/$(OUTDIR)/$$p"; \
 	done
+	@list='$(ARCHDATA)'; for p in $$list; do \
+	  echo " install -D '$(top_srcdir)/arch/$(ARCH)/scripts/$(OUTDIR)/$$p' '$(prefix)/arch/$(ARCH)/scripts/$(OUTDIR)/$$p'"; \
+	  install -D -m644 "$(top_srcdir)/arch/$(ARCH)/scripts/$(OUTDIR)/$$p" "$(prefix)/arch/$(ARCH)/scripts/$(OUTDIR)/$$p"; \
+	done
 
diff -urN linux-kbuild-2.6-2.6.18.orig/src/arch/ia64/Makefile linux-kbuild-2.6-2.6.18/src/arch/ia64/Makefile
--- linux-kbuild-2.6-2.6.18.orig/src/arch/ia64/Makefile	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/src/arch/ia64/Makefile	2006-11-22 01:03:31.074764575 -0700
@@ -0,0 +1,8 @@
+OUTDIR = arch/ia64
+VPATH = $(top_srcdir)/scripts/arch/ia64
+
+include ../../Makefile.inc
diff -urN linux-kbuild-2.6-2.6.18.orig/src/arch-inc/ia64.inc linux-kbuild-2.6-2.6.18/src/arch-inc/ia64.inc
--- linux-kbuild-2.6-2.6.18.orig/src/arch-inc/ia64.inc	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/src/arch-inc/ia64.inc	2006-11-22 03:09:19.084101378 -0700
@@ -0,0 +1,12 @@
+ARCHSCRIPTS = \
+	check-gas \
+	toolchain-flags \
+	unwcheck.py
+
+ARCHDATA = \
+	check-gas-asm.S \
+	check-model.c \
+	check-segrel.S \
+	check-segrel.lds \
+	check-serialize.S \
+	check-text-align.S
diff -urN linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-gas linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-gas
--- linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-gas	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-gas	2006-09-19 21:42:06.000000000 -0600
@@ -0,0 +1,15 @@
+#!/bin/sh
+dir=$(dirname $0)
+CC=$1
+OBJDUMP=$2
+tmp=${TMPDIR:-/tmp}
+out=$tmp/out$$.o
+$CC -c $dir/check-gas-asm.S -o $out
+res=$($OBJDUMP -r --section .data $out | fgrep 00004 | tr -s ' ' |cut -f3 -d' ')
+rm -f $out
+if [ $res != ".text" ]; then
+	echo buggy
+else
+	echo good
+fi
+exit 0
diff -urN linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-gas-asm.S linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-gas-asm.S
--- linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-gas-asm.S	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-gas-asm.S	2006-09-19 21:42:06.000000000 -0600
@@ -0,0 +1,2 @@
+[1:]	nop 0
+	.xdata4 ".data", 0, 1b-.
diff -urN linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-model.c linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-model.c
--- linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-model.c	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-model.c	2006-09-19 21:42:06.000000000 -0600
@@ -0,0 +1 @@
+int __attribute__ ((__model__ (__small__))) x;
diff -urN linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-segrel.S linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-segrel.S
--- linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-segrel.S	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-segrel.S	2006-09-19 21:42:06.000000000 -0600
@@ -0,0 +1,4 @@
+	.rodata
+	data4 @segrel(start)
+	.data
+start:
diff -urN linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-segrel.lds linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-segrel.lds
--- linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-segrel.lds	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-segrel.lds	2006-09-19 21:42:06.000000000 -0600
@@ -0,0 +1,11 @@
+SECTIONS {
+	. = SIZEOF_HEADERS;
+	.rodata : { *(.rodata) } :ro
+	. = 0xa0000;
+	.data : { *(.data) } :dat
+	/DISCARD/ : { *(*) }
+}
+PHDRS {
+  ro PT_LOAD FILEHDR PHDRS;
+  dat PT_LOAD;
+}
diff -urN linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-serialize.S linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-serialize.S
--- linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-serialize.S	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-serialize.S	2006-09-19 21:42:06.000000000 -0600
@@ -0,0 +1,2 @@
+	.serialize.data
+	.serialize.instruction
diff -urN linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-text-align.S linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-text-align.S
--- linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/check-text-align.S	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/arch/ia64/scripts/check-text-align.S	2006-09-19 21:42:06.000000000 -0600
@@ -0,0 +1,6 @@
+	.proc foo
+	.prologue
+foo:	.save rp, r2
+	nop 0
+	.align 64
+	.endp foo
diff -urN linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/toolchain-flags linux-kbuild-2.6-2.6.18/arch/ia64/scripts/toolchain-flags
--- linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/toolchain-flags	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/arch/ia64/scripts/toolchain-flags	2006-09-19 21:42:06.000000000 -0600
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Check whether linker can handle cross-segment @segrel():
+#
+CPPFLAGS=""
+CC=$1
+OBJDUMP=$2
+READELF=$3
+dir=$(dirname $0)
+tmp=${TMPDIR:-/tmp}
+out=$tmp/out$$
+
+# Check whether cross-segment segment-relative relocs work fine.  We need
+# that for building the gate DSO:
+
+$CC -nostdlib -static -Wl,-T$dir/check-segrel.lds $dir/check-segrel.S -o $out
+res=$($OBJDUMP --full --section .rodata $out | fgrep 000 | cut -f3 -d' ')
+rm -f $out
+if [ $res != 00000a00 ]; then
+    CPPFLAGS="$CPPFLAGS -DHAVE_BUGGY_SEGREL"
+    cat >&2 <<EOF
+warning: your linker cannot handle cross-segment segment-relative relocations.
+         please upgrade to a newer version (it is safe to use this linker, but
+         the kernel will be bigger than strictly necessary).
+EOF
+fi
+
+# Check whether .align inside a function works as expected.
+
+$CC -c $dir/check-text-align.S -o $out
+$READELF -u $out | fgrep -q 'prologue(rlen=12)'
+res=$?
+rm -f $out
+if [ $res -eq 0 ]; then
+    CPPFLAGS="$CPPFLAGS -DHAVE_WORKING_TEXT_ALIGN"
+fi
+
+if ! $CC -c $dir/check-model.c -o $out 2>&1 | grep  __model__ | grep -q attrib
+then
+    CPPFLAGS="$CPPFLAGS -DHAVE_MODEL_SMALL_ATTRIBUTE"
+fi
+rm -f $out
+
+# Check whether assembler supports .serialize.{data,instruction} directive.
+
+$CC -c $dir/check-serialize.S -o $out 2>/dev/null
+res=$?
+rm -f $out
+if [ $res -eq 0 ]; then
+    CPPFLAGS="$CPPFLAGS -DHAVE_SERIALIZE_DIRECTIVE"
+fi
+
+echo $CPPFLAGS
diff -urN linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/unwcheck.py linux-kbuild-2.6-2.6.18/arch/ia64/scripts/unwcheck.py
--- linux-kbuild-2.6-2.6.18.orig/arch/ia64/scripts/unwcheck.py	1969-12-31 17:00:00.000000000 -0700
+++ linux-kbuild-2.6-2.6.18/arch/ia64/scripts/unwcheck.py	2006-09-19 21:42:06.000000000 -0600
@@ -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)

--- linux-2.6-2.6.18.orig/debian/rules.real	2006-11-06 15:14:41.000000000 -0700
+++ linux-2.6-2.6.18/debian/rules.real	2006-11-22 02:37:02.000000000 -0700
@@ -312,7 +312,12 @@
 	mkdir -p "${PACKAGE_DIR}/lib/modules/${REAL_VERSION}"
 	ln -s "/usr/src/${PACKAGE_NAME}" "${PACKAGE_DIR}/lib/modules/${REAL_VERSION}/build"
 
+	## arch-specific scripts should be provided by linux-kbuild
 	ln -s "../${PACKAGE_NAME_KBUILD}/scripts" "${DIR}"
+	if [ -d ${CURDIR}/${SOURCE_DIR}/arch/${KERNEL_ARCH}/scripts ]; then \
+		rm -rf ${DIR}/arch/${KERNEL_ARCH}/scripts; \
+		ln -s --target-directory="${DIR}/arch/${KERNEL_ARCH}" "../../../${PACKAGE_NAME_KBUILD}/arch/${KERNEL_ARCH}/scripts"; \
+	fi
 
 	$(MAKE) -f debian/rules.real install-base
 

-- 
dann frazier



Reply to: