mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Updated brandelf.py.
This commit is contained in:
parent
6e5153cd07
commit
36e9c27e9c
|
@ -47,15 +47,31 @@ def do_file(fn):
|
||||||
fp.seek(0, 0)
|
fp.seek(0, 0)
|
||||||
e_ident = fp.read(16)
|
e_ident = fp.read(16)
|
||||||
fp.seek(0, 0)
|
fp.seek(0, 0)
|
||||||
if e_ident[:7] != "\x7f\x45\x4c\x46\x01\x01\x01":
|
if e_ident[:4] != "\x7f\x45\x4c\x46":
|
||||||
raise Exception, "%s is not ELF" % fn
|
raise Exception, "%s is not %s" % (fn, "ELF")
|
||||||
if opts.bfdname == "elf32-i386" and opts.elfosabi == "freebsd":
|
if opts.bfdname == "elf32-i386" and opts.elfosabi == "freebsd":
|
||||||
|
if e_ident[4:7] != "\x01\x01\x01":
|
||||||
|
raise Exception, "%s is not %s" % (fn, opts.bfdname)
|
||||||
fp.seek(7, 0)
|
fp.seek(7, 0)
|
||||||
fp.write("\x09")
|
fp.write("\x09")
|
||||||
|
elif opts.bfdname == "elf32-i386" and opts.elfosabi == "linux":
|
||||||
|
if e_ident[4:7] != "\x01\x01\x01":
|
||||||
|
raise Exception, "%s is not %s" % (fn, opts.bfdname)
|
||||||
|
fp.seek(8, 0)
|
||||||
|
fp.write("Linux\x00\x00\x00")
|
||||||
elif opts.bfdname == "elf32-i386" and opts.elfosabi == "openbsd":
|
elif opts.bfdname == "elf32-i386" and opts.elfosabi == "openbsd":
|
||||||
|
if e_ident[4:7] != "\x01\x01\x01":
|
||||||
|
raise Exception, "%s is not %s" % (fn, opts.bfdname)
|
||||||
fp.seek(7, 0)
|
fp.seek(7, 0)
|
||||||
fp.write("\x0c")
|
fp.write("\x0c")
|
||||||
elif opts.bfdname == "elf32-i386" and opts.elfosabi == "linux":
|
elif opts.bfdname == "elf32-powerpc" and opts.elfosabi == "linux":
|
||||||
|
if e_ident[4:7] != "\x01\x02\x01":
|
||||||
|
raise Exception, "%s is not %s" % (fn, opts.bfdname)
|
||||||
|
fp.seek(8, 0)
|
||||||
|
fp.write("Linux\x00\x00\x00")
|
||||||
|
elif opts.bfdname == "elf64-x86_64" and opts.elfosabi == "linux":
|
||||||
|
if e_ident[4:7] != "\x02\x01\x01":
|
||||||
|
raise Exception, "%s is not %s" % (fn, opts.bfdname)
|
||||||
fp.seek(8, 0)
|
fp.seek(8, 0)
|
||||||
fp.write("Linux\x00\x00\x00")
|
fp.write("Linux\x00\x00\x00")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user