From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UgajC-0006r2-6X for qemu-devel@nongnu.org; Sun, 26 May 2013 09:11:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ugaj2-0001Ch-1Q for qemu-devel@nongnu.org; Sun, 26 May 2013 09:11:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ugaj1-0001Cd-Pa for qemu-devel@nongnu.org; Sun, 26 May 2013 09:11:03 -0400 Date: Sun, 26 May 2013 16:11:21 +0300 From: "Michael S. Tsirkin" Message-ID: <20130526131121.GB6865@redhat.com> References: <20130522105034.GA5643@redhat.com> <519CA33E.9010109@redhat.com> <20130522110922.GC5643@redhat.com> <519CA80F.4090502@redhat.com> <20130522113510.GA7707@redhat.com> <20130526073540.GA32691@redhat.com> <20130526123142.GA6865@redhat.com> <51A2048B.1060305@weilnetz.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51A2048B.1060305@weilnetz.de> Subject: Re: [Qemu-devel] [PATCH] makefile: detect corrupted elf files List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Peter Maydell , Anthony Liguori , Markus Armbruster , qemu-devel@nongnu.org, Luiz Capitulino , Blue Swirl , Paolo Bonzini On Sun, May 26, 2013 at 02:48:11PM +0200, Stefan Weil wrote: > Am 26.05.2013 14:31, schrieb Michael S. Tsirkin: > > On Sun, May 26, 2013 at 10:12:21AM +0100, Peter Maydell wrote: > >> On 26 May 2013 08:35, Michael S. Tsirkin wrote: > >>> On Sat, May 25, 2013 at 05:32:24PM +0000, Blue Swirl wrote: > >>>> Another way to handle this would be to enhance GCC and linker to use > >>>> atomic operations when producing or combining object files. The tools > >>>> could also print a SHA of the object which the next user should > >>>> verify. Even better, the object files should include a robust checksum > >>>> to ensure integrity. > >>> I think we can make the makefile more robust. It can create a temporary > >>> file in same directory and rename when ready. This will prevent > >>> corrupted files from appearing in the first place. > >> I definitely think individual project makefiles are the wrong place > >> to fix this. If create-as-temp-and-rename is useful functionality > >> it needs to go in the compiler so that everybody benefits. > > This will not help users on existing systems. > > Also it's not just compiler. We'd have to do it in linker, > > asm, ... lots of work. > > You are wellcome to implement this in compiler/linker/etc if you like > > but we will still want to handle it in our makefile as well. > > > >> Or you > >> could write yourself a cc wrapper that did the renaming and use > >> configure's --cc= flag. > >> > >> thanks > >> -- PMM > > We also run lots of scripts in our makefiles. Would you like > > to also change each of them individually? Add wrapper scripts for e.g. > > python? What's the benefit as compared to just fixing it all in one > > place in the makefile? > > > GNU make automatically removes .o files which were built > because of a Makefile rule if that rule returns an error, so > OOM or compiler crashes should not result in corrupted .o > files. Not if make itself is killed. > The same applies to other kinds of files built by > make. Another problem is power failures and other cases of sudden reboot. > > If there are corrupted files, we have to look whether the > Makefile rules for those files are correct (or exist at all). > Are there other Open Source projects which try to detect > corrupted elf files? I know none. > > Regards > Stefan W. > It saves me time, at least. I can keep it out of tree if it rubs others the wrong way for some reason, it's no big deal. If I have some spare time I might code up the more generic thing with create then rename for all files, if I do we can discuss that. -- MST