Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HWyaq-0007yh-T6 for qemu-devel@nongnu.org; Thu, 29 Mar 2007 13:39:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HWyap-0007xl-LD for qemu-devel@nongnu.org; Thu, 29 Mar 2007 13:39:24 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HWyap-0007xf-D5 for qemu-devel@nongnu.org; Thu, 29 Mar 2007 12:39:23 -0500 Received: from 147.175.241.83.in-addr.dgcsystems.net ([83.241.175.147] helo=tmnt04.transmode.se) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HWyYD-0001oE-58 for qemu-devel@nongnu.org; Thu, 29 Mar 2007 13:36:41 -0400 From: "Joakim Tjernlund" Date: Thu, 29 Mar 2007 19:14:26 +0200 Message-ID: <000901c77225$b48bb680$020120ac@Jocke> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit In-Reply-To: <200703291253.17092.rob@landley.net> Subject: [Qemu-devel] RE: Powerpc crt1.S change faulty Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 'Rob Landley' Cc: uclibc@uclibc.org, qemu-devel@nongnu.org > -----Original Message----- > From: Rob Landley [mailto:rob@landley.net] > Sent: den 29 mars 2007 18:53 > To: joakim.tjernlund@transmode.se > Cc: uclibc@uclibc.org; qemu-devel@nongnu.org > Subject: Re: Powerpc crt1.S change faulty > > On Thursday 29 March 2007 4:05 am, Joakim Tjernlund wrote: > > Hi Rob > > > > I saw your change to powerpc crt1.S and I don't agree with it. > > mr r8,r3 copies r3 to r8 > > r8 needs to maps to rtld_fini in __uClibc_main and that maps to > > _dl_fini. Basically you have broken dynamic apps. > > Sigh. Ok. > > What does the comment mean, then? Well, the comment made somewhat sense when committing it :) http://uclibc.org/cgi-bin/viewcvs.cgi/trunk/uClibc/libc/sysdeps/linux/powerpc/crt1.S?rev=12893&r1=10629&r2=12893 Basically linux on PPC does not clear registers before handing over to userspace, 2.4 linux did but that was just an accident. After a long chat with Paulus on IRC, we found that there was an exception: r3 is the return value from the exec call and that is zero from an successful exec so uClibc could use that. So the problem is that QEMU don't clear r3 before handing over to the app. I guess you could add in uClibc_main something like #ifndef SHARED rtld_fini = NULL; #endif To workaround this problem until QEMU has a fix. Jocke > > > For static apps NULL must be passed in r8 and currenly > > crt1.S relies on the kernel to zero r3(since r3 holds > > the return value of exec) before handing over user space. > > If this no longer is true we are in deep sh*** > > > > Can you check if r3 is zero in your kernel? what kernel version > > are you using? Are you using QEMU? > > Yup. I'm using qemu-ppc, and without this change a > statically linked "hello > world" segfaults on exit (but not on _exit()). Lemme forward > this message to > the qemu list. The only explanation is that r8 is already zero but r3 isn't. > > For reference, the change is: > http://uclibc.org/cgi-bin/viewcvs.cgi?rev=18270&view=rev > > > Jocke > > Rob > -- > Vista: Windows Millenium Second Edition > > >