summaryrefslogtreecommitdiff
path: root/toolchain/uClibc/uClibc-0.9.29-load-got-pointer-at-the-beginning-of-init-and-fini.patch
diff options
context:
space:
mode:
Diffstat (limited to 'toolchain/uClibc/uClibc-0.9.29-load-got-pointer-at-the-beginning-of-init-and-fini.patch')
-rw-r--r--toolchain/uClibc/uClibc-0.9.29-load-got-pointer-at-the-beginning-of-init-and-fini.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/toolchain/uClibc/uClibc-0.9.29-load-got-pointer-at-the-beginning-of-init-and-fini.patch b/toolchain/uClibc/uClibc-0.9.29-load-got-pointer-at-the-beginning-of-init-and-fini.patch
new file mode 100644
index 000000000..27aa5a59c
--- /dev/null
+++ b/toolchain/uClibc/uClibc-0.9.29-load-got-pointer-at-the-beginning-of-init-and-fini.patch
@@ -0,0 +1,68 @@
+From: Haavard Skinnemoen <hskinnemoen@atmel.com>
+Date: Wed, 19 Sep 2007 10:03:35 +0200
+Subject: [Avr-gnu-toolchain] [uClibc PATCH] Load GOT pointer at the
+ beginning of .init and .fini
+
+I don't know why this seems to have worked before, but the .init and
+.fini sections typically consist of a bunch of mcalls using r6 as the
+base pointer. This can cause "interesting" behaviour when r6 hasn't
+been initialized to point to the GOT.
+
+Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
+---
+ libc/sysdeps/linux/avr32/crti.S | 15 ++++++++++++---
+ libc/sysdeps/linux/avr32/crtn.S | 4 ++--
+ 2 files changed, 14 insertions(+), 5 deletions(-)
+
+diff --git a/libc/sysdeps/linux/avr32/crti.S b/libc/sysdeps/linux/avr32/crti.S
+index 3e132d0..660f47c 100644
+--- a/libc/sysdeps/linux/avr32/crti.S
++++ b/libc/sysdeps/linux/avr32/crti.S
+@@ -4,14 +4,23 @@
+ .global _init
+ .type _init, @function
+ _init:
+- /* Use a four-byte instruction to avoid NOPs */
+- stm --sp, r0-r7,lr
++ stm --sp, r6, lr
++ lddpc r6, 2f
++1: rsub r6, pc
++ rjmp 3f
+ .align 2
++2: .long 1b - _GLOBAL_OFFSET_TABLE_
++3:
+
+ .section .fini
+ .align 2
+ .global _fini
+ .type _fini, @function
+ _fini:
+- stm --sp, r0-r7,lr
++ stm --sp, r6, lr
++ lddpc r6, 2f
++1: rsub r6, pc
++ rjmp 3f
+ .align 2
++2: .long 1b - _GLOBAL_OFFSET_TABLE_
++3:
+diff --git a/libc/sysdeps/linux/avr32/crtn.S b/libc/sysdeps/linux/avr32/crtn.S
+index 577adcc..f7d1040 100644
+--- a/libc/sysdeps/linux/avr32/crtn.S
++++ b/libc/sysdeps/linux/avr32/crtn.S
+@@ -3,12 +3,12 @@
+ .align 2
+ .global _init
+ .type _init, @function
+- ldm sp++, r0-r7,pc
++ ldm sp++, r6, pc
+ .size _init, . - _init
+
+ .section .fini
+ .align 2
+ .global _fini
+ .type _fini, @function
+- ldm sp++, r0-r7,pc
++ ldm sp++, r6, pc
+ .size _fini, . - _fini
+--
+1.5.3.1