Skip to content
/ pyelf Public

Higher level interface to libelf (build on top of pylibelf

License

Notifications You must be signed in to change notification settings

d1m0/pyelf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyelf

Higher level interface to libelf (build on top of pylibelf). Currently its read only. Brief example of using it:

from pyelf import *

# This is how you open an elf file:

e = Elf('/bin/ls')

# You can look at the fields/functions defined by any
# object with dir. E.g. this:

print dir(e)

# Will print:
# ['arhdr', 'ehdr', 'section', 'sections', 'shstrndx', 'syms'] 
# You can iterate through sections:

for s in e.sections():
  print s

# And you can access both the underlying pylibelf attributes for each object, as well as some convenience attributes that pyelf adds. For example, you can get the section using the sh_name field of the section header:

for s in e.sections():
  print s.shdr.sh_name

# All the fields present in pylibelf (which have the same name as the structure members in elf.h) are present. pyelf also adds some more convenient fields. For example you can access the string name of a section:

for s in e.sections():
  print s.shdr.name

# Furthermore you can iterate through data in a sections, symbols, relocations etc..

# Also you can go through archives
ar = Ar("/usr/lib/libelf.a", 64)

for elf in ar.elfs():
  print elf.arhdr.ar_name, elf.arhdr.ar_size

About

Higher level interface to libelf (build on top of pylibelf

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages