xstrip.py: *.bindump was unused; clear e_shnum, e_shstrndx
modified: stub/scripts/xstrip.py modified: stub/Makefile modified: stub/amd64-darwin.dylib-entry.h modified: stub/amd64-darwin.macho-entry.h modified: stub/amd64-linux.elf-entry.h modified: stub/amd64-linux.kernel.vmlinux.h modified: stub/amd64-linux.shlib-init.h modified: stub/amd64-win64.pep.h modified: stub/arm.v4a-linux.elf-entry.h modified: stub/arm.v4a-wince.pe.h modified: stub/arm.v4t-wince.pe.h modified: stub/arm.v5a-darwin.macho-entry.h modified: stub/arm.v5a-linux.elf-entry.h modified: stub/arm.v5a-linux.kernel.vmlinux.h modified: stub/arm.v5a-linux.kernel.vmlinuz.h modified: stub/arm.v5a-linux.shlib-init.h modified: stub/arm.v5t-linux.shlib-init.h modified: stub/arm64-darwin.macho-entry.h modified: stub/arm64-linux.elf-entry.h modified: stub/arm64-linux.shlib-init.h modified: stub/armeb.v4a-linux.elf-entry.h modified: stub/armeb.v5a-linux.kernel.vmlinux.h modified: stub/i086-dos16.com.h modified: stub/i086-dos16.exe.h modified: stub/i086-dos16.sys.h modified: stub/i386-bsd.elf-entry.h modified: stub/i386-bsd.elf.execve-entry.h modified: stub/i386-darwin.dylib-entry.h modified: stub/i386-darwin.macho-entry.h modified: stub/i386-dos32.djgpp2.h modified: stub/i386-dos32.tmt.h modified: stub/i386-dos32.watcom.le.h modified: stub/i386-linux.elf-entry.h modified: stub/i386-linux.elf.execve-entry.h modified: stub/i386-linux.elf.interp-entry.h modified: stub/i386-linux.elf.shell-entry.h modified: stub/i386-linux.kernel.vmlinux.h modified: stub/i386-linux.kernel.vmlinuz.h modified: stub/i386-linux.shlib-init.h modified: stub/i386-netbsd.elf-entry.h modified: stub/i386-win32.pe.h modified: stub/m68k-atari.tos.h modified: stub/mips.r3000-linux.elf-entry.h modified: stub/mipsel.r3000-linux.elf-entry.h modified: stub/mipsel.r3000-ps1.h modified: stub/powerpc-darwin.dylib-entry.h modified: stub/powerpc-darwin.macho-entry.h modified: stub/powerpc-linux.elf-entry.h modified: stub/powerpc-linux.kernel.vmlinux.h modified: stub/powerpc64le-darwin.dylib-entry.h modified: stub/powerpc64le-darwin.macho-entry.h modified: stub/powerpc64le-linux.elf-entry.h modified: stub/powerpc64le-linux.kernel.vmlinux.h
This commit is contained in:
@@ -72,8 +72,7 @@ def strip_with_dump(dump_fn, eh, idata):
|
||||
# // FIXME - this is only a first stub version
|
||||
# ************************************************************************/
|
||||
|
||||
def create_bindump(bindump_fn, dump_fn):
|
||||
data = ""
|
||||
def check_dump(dump_fn):
|
||||
lines = open(dump_fn, "rb").readlines()
|
||||
lines = map(lambda l: re.sub(r"\s+", " ", l.strip()).strip(), lines)
|
||||
lines = filter(None, lines)
|
||||
@@ -132,10 +131,6 @@ def create_bindump(bindump_fn, dump_fn):
|
||||
if f[0] == "OFFSET": continue
|
||||
assert len(f) == 3, (l, f)
|
||||
pass
|
||||
fp = open(bindump_fn, "wb")
|
||||
fp.write(data)
|
||||
fp.write(struct.pack("<I", len(data) + 4))
|
||||
fp.close()
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
@@ -150,7 +145,6 @@ def do_file(fn):
|
||||
fp = open(fn, "r+b")
|
||||
fp.seek(0, 0)
|
||||
idata = fp.read()
|
||||
fp.seek(0, 0)
|
||||
if idata[:4] != "\x7f\x45\x4c\x46":
|
||||
raise Exception, "%s is not %s" % (fn, "ELF")
|
||||
if idata[4:7] == "\x01\x01\x01":
|
||||
@@ -193,7 +187,9 @@ def do_file(fn):
|
||||
odata = idata[:pos]
|
||||
|
||||
if eh and odata and not opts.dry_run:
|
||||
fp.write(eh)
|
||||
fp.seek(0, 0)
|
||||
fp.write(eh[:-4]) # all but e_shnum, e_shstrndx
|
||||
fp.write(struct.pack("I", 0)) # clear e_shnum, e_shstrndx
|
||||
fp.write(odata)
|
||||
fp.truncate()
|
||||
fp.close()
|
||||
@@ -204,7 +200,7 @@ def main(argv):
|
||||
except AssertionError: pass
|
||||
else: raise Exception("fatal error - assertions not enabled")
|
||||
shortopts, longopts = "qv", [
|
||||
"create-bindump=", "dry-run", "quiet", "verbose", "with-dump="
|
||||
"dry-run", "quiet", "verbose", "with-dump="
|
||||
]
|
||||
xopts, args = getopt.gnu_getopt(argv[1:], shortopts, longopts)
|
||||
for opt, optarg in xopts:
|
||||
@@ -212,7 +208,6 @@ def main(argv):
|
||||
elif opt in ["-q", "--quiet"]: opts.verbose = opts.verbose - 1
|
||||
elif opt in ["-v", "--verbose"]: opts.verbose = opts.verbose + 1
|
||||
elif opt in ["--dry-run"]: opts.dry_run = opts.dry_run + 1
|
||||
elif opt in ["--create-bindump"]: opts.bindump = optarg
|
||||
elif opt in ["--with-dump"]: opts.with_dump = optarg
|
||||
else: assert 0, ("getopt problem:", opt, optarg, xopts, args)
|
||||
if not args:
|
||||
@@ -222,9 +217,7 @@ def main(argv):
|
||||
# process arguments
|
||||
for arg in args:
|
||||
do_file(arg)
|
||||
if opts.bindump:
|
||||
assert opts.with_dump, "need --with-dump"
|
||||
create_bindump(opts.bindump, opts.with_dump)
|
||||
check_dump(opts.with_dump);
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user