From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf5q3-0001Dt-5a for qemu-devel@nongnu.org; Wed, 22 May 2013 06:00:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uf5ps-00052n-V8 for qemu-devel@nongnu.org; Wed, 22 May 2013 06:00:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf5ps-00052Y-O1 for qemu-devel@nongnu.org; Wed, 22 May 2013 05:59:56 -0400 Date: Wed, 22 May 2013 13:00:16 +0300 From: "Michael S. Tsirkin" Message-ID: <20130522100016.GC24931@redhat.com> References: <20130521214645.GA8863@redhat.com> <20130522094854.GD30148@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130522094854.GD30148@stefanha-thinkpad.redhat.com> Subject: Re: [Qemu-devel] [PATCH] makefile: detect corrupted elf files List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Blue Swirl , Paolo Bonzini , Anthony Liguori , qemu-devel@nongnu.org, Luiz Capitulino On Wed, May 22, 2013 at 11:48:54AM +0200, Stefan Hajnoczi wrote: > On Wed, May 22, 2013 at 12:46:45AM +0300, Michael S. Tsirkin wrote: > > Once in a while make gets killed and doesn't > > clean up partial object files after it. > > Result is nasty errors from link. > > This hack checks object is well formed before linking, > > and rebuilds it if not. > > > > Signed-off-by: Michael S. Tsirkin > > --- > > > > Is below useful for others? > > > > Makefile.target | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/Makefile.target b/Makefile.target > > index ce4391f..4dddee5 100644 > > --- a/Makefile.target > > +++ b/Makefile.target > > @@ -191,3 +191,10 @@ endif > > > > GENERATED_HEADERS += config-target.h > > Makefile: $(GENERATED_HEADERS) > > + > > +.SECONDEXPANSION: > > + > > +.PHONY: CORRUPTBINARY > > + > > +$(all-obj-y): % : $$(if $$(shell size %), , CORRUPTBINARY) > > How does size(1) establish the validity of the ELF file? > Is it possible > to sneak past a truncated file (which I think is the only type of > corruption you're trying to protect against)? > > Stefan It just parses the header, so of course it is. But it does seem to catch the common failure scenarios for me. -- MST