Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/csu/powerpc When loading r13 and r2 with _SDA_BASE_ and ...



details:   https://anonhg.NetBSD.org/src/rev/4051ceb77122
branches:  trunk
changeset: 762733:4051ceb77122
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Feb 26 17:11:23 2011 +0000

description:
When loading r13 and r2 with _SDA_BASE_ and _SDA2_BASE, do so in a PIC
manner.  With this change, simple programs can now run with MKPIE=yes

diffstat:

 lib/csu/powerpc/crt0.c |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (40 lines):

diff -r f2f275aa07c1 -r 4051ceb77122 lib/csu/powerpc/crt0.c
--- a/lib/csu/powerpc/crt0.c    Sat Feb 26 16:28:10 2011 +0000
+++ b/lib/csu/powerpc/crt0.c    Sat Feb 26 17:11:23 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crt0.c,v 1.27 2011/02/22 05:45:07 joerg Exp $ */
+/* $NetBSD: crt0.c,v 1.28 2011/02/26 17:11:23 matt Exp $ */
 
 /*
  * Copyright (c) 1997 Jason R. Thorpe.
@@ -63,11 +63,17 @@
         * Initialize the Small Data Area registers.
         * _SDA_BASE is defined in the SVR4 ABI for PPC.
         * _SDA2_BASE is defined in the E[mbedded] ABI for PPC.
+        *
+        * Do the initialization in a PIC manner.
         */
-       __asm(  "lis %r13,rtld_SDA_BASE_@ha;"
-               "addi %r13,%r13,rtld_SDA_BASE_@l;"
-               "lis %r2,rtld_SDA2_BASE_@ha;"
-               "addi %r2,%r2,rtld_SDA2_BASE_@l" );
+       __asm(
+               "bcl 20,31,1f;"
+               "1: mflr 11;"
+               "addis 13,11,rtld_SDA_BASE_-1b@ha;"
+               "addi 13,13,rtld_SDA_BASE_-1b@l;"
+               "addis 2,11,rtld_SDA2_BASE_-1b@ha;"
+               "addi 2,2,rtld_SDA2_BASE_-1b@l"
+           ::: "lr" );
 
        if ((namep = argv[0]) != NULL) {        /* NULL ptr if argc = 0 */
                if ((__progname = _strrchr(namep, '/')) == NULL)
@@ -101,7 +107,7 @@
  * NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
  */
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.27 2011/02/22 05:45:07 joerg Exp $");
+__RCSID("$NetBSD: crt0.c,v 1.28 2011/02/26 17:11:23 matt Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "common.c"



Home | Main Index | Thread Index | Old Index