Skip to content

giannitedesco/pyelf

Repository files navigation

=======================================================================
pyelf: Python wrapper for libelf
Copyright (c) 2010 Gianni Tedesco <gianni@scaramanga.co.uk>
Released under the terms of the GNU GPL version 3 (see: COPYING)
=======================================================================

Python wrapper for libelf library: http://www.mr511.de/software/
For now it only supports read-only access to the various ELF headers but plans
are to support ELF file writing as well as access to ar and COFF files too.
Some of the more tedious parts of the wrapper code are auto-generated by a
simplistic interface-definition language implemented in python. An example
readelf clone is included as a demo. An example output is shown below:

Opening ./scaraOS/kernel.elf
ELF Header:
  Magic:    7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                        ELF32
  Data:                         2's complement, little endian
  Version:                      1
  OS/ABI:                       UNIX - System V
  ABI Version:                  0
  Type:                         EXEC (Executable file)
  Machine:                      Intel 80386

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 ,,,
  [ 1] .text             PROGBITS        c0100000 0000a0 0056ff ,,,
  [ 2] .rodata           PROGBITS        c0105700 0057a0 0004a4 ,,,
  [ 3] .rodata.str1.1    PROGBITS        c0105ba4 005c44 001156 ,,,
  [ 4] .data             PROGBITS        c0107000 0070a0 000254 ,,,
  [ 5] .bss              NOBITS          c0107258 0072f4 000d6c ,,,
  [ 6] .initcall.init    PROGBITS        c0108000 0072f4 000018 ,,,
  [ 7] .text.init        PROGBITS        c0108018 00730c 00114d ,,,
  [ 8] .debug_line       PROGBITS        00000000 008459 00373f ,,,
  [ 9] .debug_info       PROGBITS        00000000 00bb98 014f51 ,,,
  [10] .debug_abbrev     PROGBITS        00000000 020ae9 004eba ,,,
  [11] .debug_aranges    PROGBITS        00000000 0259a8 000638 ,,,
  [12] .debug_loc        PROGBITS        00000000 025fe0 0065e3 ,,,
  [13] .debug_pubnames   PROGBITS        00000000 02c5c3 000ced ,,,
  [14] .debug_ranges     PROGBITS        00000000 02d2b0 000f78 ,,,
  [15] .debug_str        PROGBITS        00000000 02e228 0023d8 ,,,
  [16] .debug_frame      PROGBITS        00000000 030600 001b1c ,,,
  [17] .shstrtab         STRTAB          00000000 03211c 0000d3 ,,,
  [18] .symtab           SYMTAB          00000000 032510 001ba0 ,,,
  [19] .strtab           STRTAB          00000000 0340b0 00125b ,,,
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers: 3
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  ... <elf.phdr object at 0xb78421a0>
  ... <elf.phdr object at 0xb7842160>
  ... <elf.phdr object at 0xb7842260>

About

Python wrapper for libelf

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published