WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [patch 1/5] add libelf: an ELF binary parser library.

To: Emmanuel Ackaouy <ack@xxxxxxxxxxxxx>
Subject: [Xen-devel] Re: [patch 1/5] add libelf: an ELF binary parser library.
From: Gerd Hoffmann <kraxel@xxxxxxx>
Date: Wed, 24 Jan 2007 09:34:02 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 24 Jan 2007 00:33:55 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <425431495d656c4e48ec8110b7dd80b7@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20070123145344.754866428@xxxxxxx> <20070123145408.909708619@xxxxxxx> <425431495d656c4e48ec8110b7dd80b7@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.9 (X11/20060911)
Emmanuel Ackaouy wrote:
> Hi Gerd,
> 
> I have to say I'm not a big fan of sticking a 32bit and 64bit version
> of each structure in a union and then checking at all levels of the
> function call stack which one to reference (via elf_xval() for example).
> 
> Wouldn't it be cleaner to just have 2 different version of each elf
> data structure and function? elf32_xxx and elf64_xxx . And go down
> one path or the other at the start of your function call stack?

No.

> I'm not
> usually a fan of multiple compilation, but due to the layout of 32
> and 64bit elf structures, this is one case where it makes sense
> to me.

It doesn't.  I did it both ways.  Not compiling twice is better.

It is much more flexible and makes reusing the code much easier.  You
can simply add your own functions without hassle.

Look at the libelf-use-readnotes.diff patch and the print_numeric_note()
function it adds to readnotes.c as an simple example.  How do you do
that when compiling twice?  Your options are:

 (1) push that into the library which is compiled twice anyway.
 (2) split it out into a separate source which you can compile twice.
 (3) write two versions of the function, one for 32 and one for 64 bit.

None of these options looks good to me.

> Also, do we actually have a need to look at elf files with a different
> ELFDATA (byte ordering) ?

Yes.  I think it is very handy if readnotes works on ppc kernels too.
Also some IA64 guys seem to work on mixed-endian support (there where
some messages on the list some weeks ago), for this it is required too.

cheers,
  Gerd

-- 
Gerd Hoffmann <kraxel@xxxxxxx>

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel