Module Name: src Committed By: matt Date: Tue Dec 3 00:19:56 UTC 2013
Modified Files: src/libexec/ld.elf_so/arch/arm: rtld_start.S Log Message: Don't use GOT relocations. Use PC relative for the GOT and GOTOFF for _DYNAMIC. Make thumb friendly. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/libexec/ld.elf_so/arch/arm/rtld_start.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/libexec/ld.elf_so/arch/arm/rtld_start.S diff -u src/libexec/ld.elf_so/arch/arm/rtld_start.S:1.11 src/libexec/ld.elf_so/arch/arm/rtld_start.S:1.12 --- src/libexec/ld.elf_so/arch/arm/rtld_start.S:1.11 Mon Aug 13 02:53:25 2012 +++ src/libexec/ld.elf_so/arch/arm/rtld_start.S Tue Dec 3 00:19:56 2013 @@ -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 */ - - ldr sl, .L2 - ldr r5, .L2+4 - ldr r0, .L2+8 -.L1: - add sl, pc, sl - ldr r5, [sl, r5] - ldr r0, [sl, r0] + movs r4, r0 /* save ps_strings */ - 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 @@ _rtld_bind_start: 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)