Skip to content

Instantly share code, notes, and snippets.

@chris-se
Created February 6, 2016 23:11
Show Gist options
  • Save chris-se/178b71c67a110f7c2dae to your computer and use it in GitHub Desktop.
Save chris-se/178b71c67a110f7c2dae to your computer and use it in GitHub Desktop.
Index: lib/stackgap.c
===================================================================
RCS file: /cvs/dietlibc/lib/stackgap.c,v
retrieving revision 1.30
diff -u -p -r1.30 stackgap.c
--- lib/stackgap.c 26 Jan 2016 15:08:00 -0000 1.30
+++ lib/stackgap.c 6 Feb 2016 23:10:28 -0000
@@ -127,12 +127,19 @@ void __setup_tls(tcbhead_t* mainthread)
#elif defined(__alpha__) || defined(__s390__)
__builtin_set_thread_pointer(mainthread);
-#elif defined(__ia64__) || defined(__powerpc__)
+#elif defined(__ia64__) || defined(__powerpc64__)
register tcbhead_t* __thread_self __asm__("r13");
__thread_self=mainthread;
+#elif defined(__powerpc__)
+ /* __thread_self=mainthread is optimized out by gcc 5 with -Os
+ * on PPC */
+ register tcbhead_t* __thread_self __asm__("r2");
+ __asm__ volatile ("addi %0,%1,0" : "=r"(__thread_self) : "r"(mainthread));
#elif defined(__sparc__)
register tcbhead_t* __thread_self __asm("%g7");
__thread_self=mainthread;
+#elif defined(__mips__)
+ set_thread_area((char*)(void *)mainthread);
#elif defined(__arm__)
extern void __arm_set_tls(void*);
__arm_set_tls(mainthread);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment