public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] s390: tls pointer extraction in __libc_start_main
Date: Mon, 06 Oct 2008 18:17:00 -0000	[thread overview]
Message-ID: <1223316873.5245.2.camel@localhost> (raw)

Greetings,
a glibc compiled with the latest gcc crashes in __libc_start_main.
The cause is that the compiler has decided to extract the tls pointer
in __libc_start_main() from the access registers a0/a1 into a general
register before the tls pointer has been set up by the call to
__pthread_initialize_minimal(). 

The least invasive fix is to clobber the access registers before the
first use in THREAD_SET_STACK_GUARD(). This makes the compiler to
do the tls pointer extraction after __pthread_initialize_minimal().

-- 
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.
--

2008-10-06  Martin Schwidefsky  <schwidefsky@de.ibm.com>

	* sysdeps/s390/tls.h (THREAD_SET_STACK_GUARD): Add empty inline
	assembly with a clobber list for access registers a0 and a1.

diff -urpN libc/nptl/sysdeps/s390/tls.h libc-s390/nptl/sysdeps/s390/tls.h
--- libc/nptl/sysdeps/s390/tls.h	2007-08-07 13:09:01.000000000 +0200
+++ libc-s390/nptl/sysdeps/s390/tls.h	2008-10-06 19:55:46.000000000 +0200
@@ -161,7 +161,12 @@ typedef struct
 
 /* Set the stack guard field in TCB head.  */
 #define THREAD_SET_STACK_GUARD(value) \
-  THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+  do 									      \
+   {									      \
+     __asm __volatile ("" : : : "a0", "a1");				      \
+     THREAD_SETMEM (THREAD_SELF, header.stack_guard, value);		      \
+   }									      \
+  while (0)
 #define THREAD_COPY_STACK_GUARD(descr) \
   ((descr)->header.stack_guard						      \
    = THREAD_GETMEM (THREAD_SELF, header.stack_guard))


             reply	other threads:[~2008-10-06 18:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-06 18:17 Martin Schwidefsky [this message]
2008-10-22 21:45 ` Ulrich Drepper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1223316873.5245.2.camel@localhost \
    --to=schwidefsky@de.ibm.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).