1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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
|