[PATCH] libdwelf: New function dwelf_elf_begin.

Mark Wielaard mark@klomp.org
Fri Nov 9 17:25:00 GMT 2018


On Sun, Nov 04, 2018 at 05:37:42PM +0100, Mark Wielaard wrote:
> On Mon, 2018-10-22 at 01:47 +0200, Mark Wielaard wrote:
> > It currently wraps __libdw_open_file which makes error handling
> > slight tricky and needs duplicating the file handle.
> 
> Which introduced some confusion that could cause the file descriptor to
> leak. The attached updated patch adds a variant to the
> __libdw_open_file function that doesn't try to play tricks with the
> given file descriptor which is easier to wrap for dwelf_elf_begin.

> From 940515f0ba9641b9ac38d721aaac87fd898bb1fd Mon Sep 17 00:00:00 2001
> From: Mark Wielaard <mark@klomp.org>
> Date: Sun, 21 Oct 2018 23:41:32 +0200
> Subject: [PATCH] libdwelf: New function dwelf_elf_begin.
> 
> This introduces a new function dwelf_elf_begin which creates a (read-only)
> ELF handle from a possibly compressed file handle or a file that start
> with a linux kernel header. This can be used in eu-readelf to (re)open a
> (pure) ELF.
> 
> eu-readelf uses libdwfl to relocate addresses in the original file in
> case it is ET_REL. But to show the "raw" data it might need to (re)open
> the file. Which could fail if the file was compressed. And produced an
> obscure error message: "cannot create EBL handle".
> 
> This rewrites __libdw_open_file a little so that the given file handle
> will never be closed (whether on success or failure) and introduces a
> new internal function __libdw_open_elf that dwelf_elf_begin wraps.

I pushed this variant to master now.

Cheers,

Mark



More information about the Elfutils-devel mailing list