Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so/arch/arm Don't use GOT relocations. Use P...
details: https://anonhg.NetBSD.org/src/rev/8ad295e9d558
branches: trunk
changeset: 325067:8ad295e9d558
user: matt <matt%NetBSD.org@localhost>
date: Tue Dec 03 00:19:56 2013 +0000
description:
Don't use GOT relocations. Use PC relative for the GOT and GOTOFF for
_DYNAMIC. Make thumb friendly.
diffstat:
libexec/ld.elf_so/arch/arm/rtld_start.S | 68 ++++++++++++++------------------
1 files changed, 30 insertions(+), 38 deletions(-)
diffs (104 lines):
diff -r 0bce36bd5db1 -r 8ad295e9d558 libexec/ld.elf_so/arch/arm/rtld_start.S
--- a/libexec/ld.elf_so/arch/arm/rtld_start.S Mon Dec 02 23:06:35 2013 +0000
+++ b/libexec/ld.elf_so/arch/arm/rtld_start.S Tue Dec 03 00:19:56 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld_start.S,v 1.11 2012/08/13 02:53:25 matt Exp $ */
+/* $NetBSD: rtld_start.S,v 1.12 2013/12/03 00:19:56 matt Exp $ */
/*-
* Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@@ -31,55 +31,51 @@
#include <machine/asm.h>
-RCSID("$NetBSD: rtld_start.S,v 1.11 2012/08/13 02:53:25 matt Exp $")
+RCSID("$NetBSD: rtld_start.S,v 1.12 2013/12/03 00:19:56 matt Exp $")
- .text
- .align 0
- .globl _rtld_start
- .type _rtld_start,%function
-_rtld_start:
+ENTRY_NP(_rtld_start)
sub sp, sp, #8 /* make room for obj_main & exit proc */
- mov r4, r0 /* save ps_strings */
+ movs r4, r0 /* save ps_strings */
- ldr sl, .L2
- ldr r5, .L2+4
- ldr r0, .L2+8
-.L1:
- add sl, pc, sl
- ldr r5, [sl, r5]
- ldr r0, [sl, r0]
-
- sub r1, sl, r5 /* relocbase */
- add r0, r1, r0 /* &_DYNAMIC */
+ ldr r6, .Lgot
+ ldr r5, .Ldynamic
+ add r6, r6, pc /* r6 = &GOT[0]; pc = &LPIC1; */
+ adds r0, r6, r5 /* arg0 = &_DYNAMIC */
+.LPIC1:
+ ldr r5, [r6] /* GOT[0] = &_DYNAMIC */
+ subs r5, r0, r5 /* relocbase = GOT[0] - &_DYNAMIC */
+ movs r1, r5 /* arg1 = relocabase */
bl _rtld_relocate_nonplt_self
- sub r1, sl, r5 /* relocbase */
+ movs r1, r5 /* relocbase */
mov r0, sp /* sp */
bl _rtld /* call the shared loader */
- mov r3, r0 /* save entry point */
+ movs r3, r0 /* save entry point */
+#ifdef __thumb__
+ ldr r2, [sp, #0] /* pop r2 = cleanup */
+ ldr r1, [sp, #4] /* pop r1 = obj_main */
+ add sp, sp, #8
+#else
ldr r2, [sp], #4 /* pop r2 = cleanup */
ldr r1, [sp], #4 /* pop r1 = obj_main */
- mov r0, r4 /* restore ps_strings */
-#ifdef _ARM_ARCH_4T
- bx r3 /* jump to the entry point */
-#else
- mov pc, r3 /* jump to the entry point */
#endif
-.L2:
- .word _GLOBAL_OFFSET_TABLE_ - (.L1+8)
- .word _GLOBAL_OFFSET_TABLE_(GOT)
- .word _DYNAMIC(GOT)
+ movs r0, r4 /* restore ps_strings */
+ RETr(r3)
.align 0
- .globl _rtld_bind_start
- .type _rtld_bind_start,%function
+.Lgot:
+ .word _GLOBAL_OFFSET_TABLE_ - .LPIC1
+.Ldynamic:
+ .word _DYNAMIC(GOTOFF)
+END(_rtld_start)
+
/*
* stack[0] = RA
* ip = &GOT[n+3]
* lr = &GOT[2]
*/
-_rtld_bind_start:
+ARM_ENTRY_NP(_rtld_bind_start)
stmdb sp!,{r0-r4,sl,fp} /* 8 byte aligned (lr already saved) */
sub r1, ip, lr /* r1 = 4 * (n + 1) */
@@ -95,9 +91,5 @@
mov ip, r0 /* save new address */
ldmia sp!,{r0-r4,sl,fp,lr} /* restore the stack */
-#ifdef _ARM_ARCH_4T
- bx ip /* jump to the new address */
-#else
- mov pc, ip /* jump to the new address */
-#endif
-
+ RETr(ip) /* jump to the new address */
+END(_rtld_bind_start)
Home |
Main Index |
Thread Index |
Old Index