#!/usr/bin/env python3 import struct import sys import os if len(sys.argv) < 2: print('Usage: ' + os.path.basename(sys.argv[0]) + ' input_file') exit() with open(sys.argv[1], 'r+b') as f: f.seek(0) hdr = f.read(16) if hdr[0] != 0x7f or hdr[1] != ord('E') or hdr[2] != ord('L') or hdr[3] != ord('F'): raise Exception('Not an elf file') if hdr[4] == 1: # 32 bit code f.seek(28) offset = struct.unpack('