From 3850723af0f79ba4c5bcf701bd227b06340be6bb Mon Sep 17 00:00:00 2001
From: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Date: Mon, 19 Mar 2007 18:02:16 +0000
Subject: Joseph S. Myers writes: On PowerPC, r13 is used for a small data
 pointer and needs to be set up from _SDA_BASE_ (defined by the linker) at
 startup.

This is needed for the GCC testcase gcc.target/powerpc/980827-1.c to work.
This patch fixes that testcase (verified for both static and dynamic
linking).
---
 libc/sysdeps/linux/powerpc/crt1.S | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'libc')

diff --git a/libc/sysdeps/linux/powerpc/crt1.S b/libc/sysdeps/linux/powerpc/crt1.S
index 7928a7ed3..8798849b3 100644
--- a/libc/sysdeps/linux/powerpc/crt1.S
+++ b/libc/sysdeps/linux/powerpc/crt1.S
@@ -57,6 +57,13 @@ _start:
 	bl	_GLOBAL_OFFSET_TABLE_-4@local
 	mflr	r31
 # endif
+#endif
+	/* Set up the small data pointer in r13.  */
+#ifdef __PIC__
+	lwz	r13,_SDA_BASE_@got(r31)
+#else
+	lis	r13,_SDA_BASE_@ha
+	addi	r13,r13,_SDA_BASE_@l
 #endif
 	/* Set up an initial stack frame, and clear the LR.  */
 	li	r0,0
-- 
cgit v1.2.3