qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] makefile: detect corrupted elf files


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PATCH] makefile: detect corrupted elf files
Date: Wed, 22 May 2013 13:00:16 +0300

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 <address@hidden>
> > ---
> > 
> > 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]