From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25070 invoked by alias); 6 Oct 2008 18:17:31 -0000 Received: (qmail 25054 invoked by uid 22791); 6 Oct 2008 18:17:30 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate5.de.ibm.com (HELO mtagate5.de.ibm.com) (195.212.29.154) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 06 Oct 2008 18:16:47 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate5.de.ibm.com (8.13.8/8.13.8) with ESMTP id m96IFgLj498126 for ; Mon, 6 Oct 2008 18:15:42 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id m96IFffa3961006 for ; Mon, 6 Oct 2008 20:15:42 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m96IFcB6011645 for ; Mon, 6 Oct 2008 20:15:38 +0200 Received: from [9.152.198.52] (dyn-9-152-198-52.boeblingen.de.ibm.com [9.152.198.52]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m96IFclN011635 for ; Mon, 6 Oct 2008 20:15:38 +0200 Subject: [PATCH] s390: tls pointer extraction in __libc_start_main From: Martin Schwidefsky Reply-To: schwidefsky@de.ibm.com To: Glibc hackers Content-Type: text/plain Date: Mon, 06 Oct 2008 18:17:00 -0000 Message-Id: <1223316873.5245.2.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 7bit Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00001.txt.bz2 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 * 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))