From 734e6e5fd394cf923081b63a632753c97a3f3a5f Mon Sep 17 00:00:00 2001
From: Nicolas Thill <nico@openwrt.org>
Date: Sun, 2 May 2010 00:59:04 +0000
Subject: [PATCH] target/uml: add patches for 2.6.32

SVN-Revision: 21290
---
 .../001-gcc4_unit_at_a_time_i386_fix.patch    | 11 ++++
 .../002-gcc4_unfortify_source.patch           | 21 ++++++++
 .../patches-2.6.32/003-fix_text_section.patch | 38 ++++++++++++++
 .../006-uml_libc_link_errors.patch            | 50 +++++++++++++++++++
 .../901-lib_zlib_deflate_visible.patch        | 14 ++++++
 5 files changed, 134 insertions(+)
 create mode 100644 target/linux/uml/patches-2.6.32/001-gcc4_unit_at_a_time_i386_fix.patch
 create mode 100644 target/linux/uml/patches-2.6.32/002-gcc4_unfortify_source.patch
 create mode 100644 target/linux/uml/patches-2.6.32/003-fix_text_section.patch
 create mode 100644 target/linux/uml/patches-2.6.32/006-uml_libc_link_errors.patch
 create mode 100644 target/linux/uml/patches-2.6.32/901-lib_zlib_deflate_visible.patch

diff --git a/target/linux/uml/patches-2.6.32/001-gcc4_unit_at_a_time_i386_fix.patch b/target/linux/uml/patches-2.6.32/001-gcc4_unit_at_a_time_i386_fix.patch
new file mode 100644
index 0000000000..442c0ec76e
--- /dev/null
+++ b/target/linux/uml/patches-2.6.32/001-gcc4_unit_at_a_time_i386_fix.patch
@@ -0,0 +1,11 @@
+--- a/arch/um/Makefile-i386
++++ b/arch/um/Makefile-i386
+@@ -35,7 +35,7 @@ cflags-y += -ffreestanding
+ # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
+ # a lot more stack due to the lack of sharing of stacklots.  Also, gcc
+ # 4.3.0 needs -funit-at-a-time for extern inline functions.
+-KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then \
++KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0403 ] ; then \
+ 			echo $(call cc-option,-fno-unit-at-a-time); \
+ 			else echo $(call cc-option,-funit-at-a-time); fi ;)
+ 
diff --git a/target/linux/uml/patches-2.6.32/002-gcc4_unfortify_source.patch b/target/linux/uml/patches-2.6.32/002-gcc4_unfortify_source.patch
new file mode 100644
index 0000000000..2be33d02a3
--- /dev/null
+++ b/target/linux/uml/patches-2.6.32/002-gcc4_unfortify_source.patch
@@ -0,0 +1,21 @@
+--- a/arch/um/Makefile-i386
++++ b/arch/um/Makefile-i386
+@@ -39,4 +39,8 @@ KBUILD_CFLAGS += $(shell if [ $(call cc-
+ 			echo $(call cc-option,-fno-unit-at-a-time); \
+ 			else echo $(call cc-option,-funit-at-a-time); fi ;)
+ 
++# disable compile-time buffer checks, enabled by default on Ubuntu 8.10 
++# and later
++KBUILD_CFLAGS += $(call cc-option,-U_FORTIFY_SOURCE)
++
+ KBUILD_CFLAGS += $(cflags-y)
+--- a/arch/um/Makefile-x86_64
++++ b/arch/um/Makefile-x86_64
+@@ -24,3 +24,7 @@ LINK-y += -m64
+ 
+ # Do unit-at-a-time unconditionally on x86_64, following the host
+ KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
++
++# disable compile-time buffer checks, enabled by default on Ubuntu 8.10 
++# and later
++KBUILD_CFLAGS += $(call cc-option,-U_FORTIFY_SOURCE)
diff --git a/target/linux/uml/patches-2.6.32/003-fix_text_section.patch b/target/linux/uml/patches-2.6.32/003-fix_text_section.patch
new file mode 100644
index 0000000000..210435eb3e
--- /dev/null
+++ b/target/linux/uml/patches-2.6.32/003-fix_text_section.patch
@@ -0,0 +1,38 @@
+um: remove PAGE_SIZE alignment in linker script causing kernel segfault.
+
+The linker script cleanup that I did in commit 
+5d150a97f9391f5bcd7ba0d59d7a11c3de3cea80 accidentally introduced an 
+ALIGN(PAGE_SIZE) when converting to use INIT_TEXT_SECTION; Richard 
+Weinberger reported that this causes the kernel to segfault with 
+CONFIG_STATIC_LINK=y.
+
+I'm not certain why this extra alignment is a problem, but it seems likely 
+it is because previously
+
+__init_begin = _stext = _text = _sinittext 
+
+and with the extra ALIGN(PAGE_SIZE), _sinittext becomes different from the 
+rest.  So there is likely a bug here where something is assuming that 
+_sinittext is the same as one of those other symbols.  But reverting the 
+accidental change fixes the regression, so it seems worth committing that 
+now.
+
+Signed-off-by: Tim Abbott <tabbott@ksplice.com>
+Reported-by: richard -rw- weinberger <richard.weinberger@gmail.com>
+Cc: Jeff Dike <jdike@addtoit.com>
+Cc: user-mode-linux-devel@lists.sourceforge.net
+---
+ arch/um/kernel/uml.lds.S |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+--- a/arch/um/kernel/uml.lds.S
++++ b/arch/um/kernel/uml.lds.S
+@@ -22,7 +22,7 @@ SECTIONS
+   _text = .;
+   _stext = .;
+   __init_begin = .;
+-  INIT_TEXT_SECTION(PAGE_SIZE)
++  INIT_TEXT_SECTION(0)
+   . = ALIGN(PAGE_SIZE);
+ 
+   .text      :
diff --git a/target/linux/uml/patches-2.6.32/006-uml_libc_link_errors.patch b/target/linux/uml/patches-2.6.32/006-uml_libc_link_errors.patch
new file mode 100644
index 0000000000..2adfe03621
--- /dev/null
+++ b/target/linux/uml/patches-2.6.32/006-uml_libc_link_errors.patch
@@ -0,0 +1,50 @@
+--- a/arch/um/kernel/dyn.lds.S
++++ b/arch/um/kernel/dyn.lds.S
+@@ -50,8 +50,21 @@ SECTIONS
+   .rela.got       : { *(.rela.got) }
+   .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
+   .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
+-  .rel.plt        : { *(.rel.plt) }
+-  .rela.plt       : { *(.rela.plt) }
++  /* Deal with multilib libc */
++  .rel.plt        :
++  {
++    *(.rel.plt)
++    PROVIDE_HIDDEN (__rel_iplt_start = .);
++    *(.rel.iplt)
++    PROVIDE_HIDDEN (__rel_iplt_end = .);
++  }
++  .rela.plt       :
++  {
++    *(.rela.plt)
++    PROVIDE_HIDDEN (__rela_iplt_start = .);
++    *(.rela.iplt)
++    PROVIDE_HIDDEN (__rela_iplt_end = .);
++  }
+   .init           : {
+     KEEP (*(.init))
+   } =0x90909090
+--- a/arch/um/kernel/uml.lds.S
++++ b/arch/um/kernel/uml.lds.S
+@@ -35,6 +35,21 @@ SECTIONS
+     *(.gnu.warning)
+     *(.gnu.linkonce.t*)
+   }
++  /* Deal with multilib libc */
++  .rel.plt        :
++  {
++    *(.rel.plt)
++    PROVIDE_HIDDEN (__rel_iplt_start = .);
++    *(.rel.iplt)
++    PROVIDE_HIDDEN (__rel_iplt_end = .);
++  }
++  .rela.plt       :
++  {
++    *(.rela.plt)
++    PROVIDE_HIDDEN (__rela_iplt_start = .);
++    *(.rela.iplt)
++    PROVIDE_HIDDEN (__rela_iplt_end = .);
++  }
+ 
+   . = ALIGN(PAGE_SIZE);
+   .syscall_stub : {
diff --git a/target/linux/uml/patches-2.6.32/901-lib_zlib_deflate_visible.patch b/target/linux/uml/patches-2.6.32/901-lib_zlib_deflate_visible.patch
new file mode 100644
index 0000000000..116d76fcfa
--- /dev/null
+++ b/target/linux/uml/patches-2.6.32/901-lib_zlib_deflate_visible.patch
@@ -0,0 +1,14 @@
+make ZLIB_DEFLATE visible, so that we can choose whether we want it built-in
+or as a module
+
+--- a/lib/Kconfig
++++ b/lib/Kconfig
+@@ -95,7 +95,7 @@ config ZLIB_INFLATE
+ 	tristate
+ 
+ config ZLIB_DEFLATE
+-	tristate
++	tristate "Zlib compression"
+ 
+ config LZO_COMPRESS
+ 	tristate
-- 
GitLab