diff options
-rwxr-xr-x | pyelfdump.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/pyelfdump.py b/pyelfdump.py new file mode 100755 index 00000000000..9e52413e588 --- /dev/null +++ b/pyelfdump.py @@ -0,0 +1,33 @@ +#! /usr/bin/env python3 + +import sys +import elftools.elf.elffile + +def first_tag(dynamic, type): + try: + return next(dynamic.iter_tags(type)) + except StopIteration: + return None + +def test(): + with open(sys.argv[1], 'rb') as f: + elffile = elftools.elf.elffile.ELFFile(f) + dynamic = elffile.get_section_by_name(".dynamic") + #print(dynamic['sh_type'] == 'SHT_NOBITS': + print(dynamic['sh_type']) + value = first_tag(dynamic, "DT_SONAME") + if value: value.soname + + value = first_tag(dynamic, "DT_RPATH") + if value: value.rpath + + value = first_tag(dynamic, "DT_RUNPATH") + if value: value.runpath + + for value in dynamic.iter_tags("DT_NEEDED"): + value.needed + +test() + +#import timeit +#print(timeit.timeit("test()", number=1000, globals=globals()) / 1000) |