[CRIU] Re: [PATCH 04/13] make: Generate offsets from linked files only

Cyrill Gorcunov gorcunov at openvz.org
Wed Apr 18 05:34:38 EDT 2012


On Wed, Apr 18, 2012 at 12:18:34PM +0400, Pavel Emelyanov wrote:
> On 04/18/2012 01:55 AM, Cyrill Gorcunov wrote:
> > Instead of generating offsets from early compiled
> > object files (one day the offsets obtained from
> > there might be changed during linkage stage) better
> > to get them from a final stage where all object
> > files involved are linked into complete binary blob.
> > 
> > That happened that at early stage we indeed were using
> > only single file per parasite and restorer but at present
> > there a couple of file involved (and will be more in
> > future) so we need a safe approach.
> > 
> > Also note the symbols being exported are prefixed as
> > "__export_". This is easier approach for now. Putting
> > such symbols into separate section requires a way
> > more efforts to handle.
> > 
> > Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> > ---
> >  Makefile           |    6 ++++--
> >  cr-restore.c       |    4 ++--
> >  gen-offsets.sh     |    4 ++--
> >  include/parasite.h |    6 +++---
> >  include/restorer.h |    4 ++--
> >  parasite.c         |   16 ++++++++--------
> >  pie.lds.S          |    3 ---
> >  restorer.c         |    4 ++--
> >  8 files changed, 23 insertions(+), 24 deletions(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index aa2f801..0a6df29 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -89,7 +89,8 @@ parasite-util-net.o: util-net.c
> >  
> >  $(HEAD-BIN): $(PIE-LDS) $(OBJS-BLOB) parasite-util-net.o
> >  	$(E) "  GEN     " $@
> > -	$(Q) $(LD) -T $(PIE-LDS) $(OBJS-BLOB) parasite-util-net.o -o $@
> > +	$(Q) $(LD) --oformat=binary -T $(PIE-LDS) $(OBJS-BLOB) parasite-util-net.o -o $@
> > +	$(Q) $(LD) --oformat=elf64-x86-64 -T $(PIE-LDS) $(OBJS-BLOB) parasite-util-net.o -o $@.o
> 
> Why do we need the .bin file then? AFAIS the .bin.o is only used next, what do I miss?

.bin.o will also have Elf headers, thus to find offsets of functions in object
file we will need to parse Elf headers itself (since `nm "symbol" x.o' will
show us virtual address but not real offset in object file).

	Cyrill


More information about the CRIU mailing list