++ed by:

1 PAUSE user

Thomas Dorner
and 1 contributors


Parse::Readelf - handle readelf's output with a class


  use Parse::Readelf;

  my $readelf_data = new Parse::Readelf($executable);
  $readelf_data->print_structure_layout($re_identifier, 1);


Parse::Readelf parses (some of) the output of readelf and stores its interesting details in some objects to ease access.

At the moment only a very limited access to the structure layout of data types and variables is supported.


Normally an object of this class is constructed with the file name of an object file to be parsed. Upon construction the file is analysed and all relevant information about its debug info section is stored inside of the object or one of its subobjects. This information can be accessed afterwards using a bunch of getter methods, see "METHODS" for details.

This is BETA software, use at your own risk.

at the moment only information regarding the binary arrangement of variables (Structure Layout) is supported (and that is regularly used at my company, so the worst bugs should by found by now). Other data is ignored for now.

Currently only output for Dwarf version 2 is supported. Please contact the author for other versions and provide some example readelf outputs.


Nothing is exported by default as it's normally not needed to modify the following variable:

This module exports nothing directly, it should be accessed via its methods only.


is a list of the types that can be printed in a structure layout. Its elements are basically the tag identifieres from readelf's output without the prefix DW_TAG_.

new - get readelf's output into an object

    $readelf_data = new Parse::Readelf($file_name);


    $readelf_data1 = new Parse::Readelf('program');
    $readelf_data2 = new Parse::Readelf('module.o');


    $file_name          name of executable or object file


    This method parses the output of several C<readelf> commands and
    stores its interesting details internally to be accessed later by
    getter methods described below.


    The method returns the blessed Parse::Readelf object or an
    exception in case of an error.
    $readelf_data->print_structure_layout($re_name [, $print_location]);


    $readelf_data->print_structure_layout('_t$', 1);


    $re_name            reg. exp. matching name of variable or data type
    $print_location     optional flag to print location with every definition


    This method prints the structure layout of one or more variables
    or data types that match the regular expression for their name.
    If the optional parameter $print_location is true, each line also
    contains source location information, if availablble.




Did I mentioned that this is Beta code?

Only Dwarf version 2 is supported. Please contact the author for other versions and provide some example readelf outputs.

This has only be tested in a Unix like environment, namely Linux and Solaris.


Parse::Readelf::Debug::Info, Parse::Readelf::Debug::Line and the readelf man page


Thomas Dorner, <dorner (AT) cpan.org>


Copyright (C) 2007-2013 by Thomas Dorner

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.1 or, at your option, any later version of Perl 5 you may have available.