Revert xstrip.py

modified:   stub/scripts/xstrip.py
This commit is contained in:
John Reiser 2017-03-25 17:50:06 -07:00
parent a807b88694
commit 5840190ed5

View File

@ -27,11 +27,6 @@
# <markus@oberhumer.com> <ezerotven+github@gmail.com>
#
from __future__ import print_function
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
import getopt, os, re, string, struct, sys
@ -52,18 +47,16 @@ def strip_with_dump(dump_fn, eh, idata):
lines = open(dump_fn, "rb").readlines()
for l in lines:
l = re.sub(r"\s+", " ", l.strip())
# eprint("l=", l, "\n")
f = l.split(" ")
# eprint("f=", f, "len(f)=", len(f), "\n")
if len(f) >= 8:
if f[7].startswith("CONTENTS"):
sh_offset = int("0x" + f[5], 16)
sh_size = int("0x" + f[2], 16)
if sh_offset + sh_size > new_len:
new_len = sh_offset + sh_size
# eprint("sh_offset=", sh_offset, "sh_size=", sh_size, "f=", f, "\n")
##print sh_offset, sh_size, f
if new_len > len(eh):
# eprint("dump_fn=", dump_fn, "new_len=", new_len, "\n")
##print dump_fn, new_len
return eh, idata[:new_len-len(eh)]
return eh, idata