From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf5fH-0005Pl-Vd for qemu-devel@nongnu.org; Wed, 22 May 2013 05:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uf5fH-000190-0Q for qemu-devel@nongnu.org; Wed, 22 May 2013 05:48:59 -0400 Received: from mail-wg0-x232.google.com ([2a00:1450:400c:c00::232]:61457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf5fG-00018m-QK for qemu-devel@nongnu.org; Wed, 22 May 2013 05:48:58 -0400 Received: by mail-wg0-f50.google.com with SMTP id k13so1034476wgh.29 for ; Wed, 22 May 2013 02:48:58 -0700 (PDT) Date: Wed, 22 May 2013 11:48:54 +0200 From: Stefan Hajnoczi Message-ID: <20130522094854.GD30148@stefanha-thinkpad.redhat.com> References: <20130521214645.GA8863@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130521214645.GA8863@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: "Michael S. Tsirkin" Cc: Blue Swirl , Paolo Bonzini , Anthony Liguori , qemu-devel@nongnu.org, Luiz Capitulino 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