More python3
modified: scripts/brandelf.py modified: scripts/gpp_inc.py modified: src/arch/i086/cleanasm.py
This commit is contained in:
parent
59d5d25a77
commit
8ab47ba8a4
@ -54,32 +54,32 @@ def do_file(fn):
|
||||
|
||||
def write(s):
|
||||
if not opts.dry_run:
|
||||
fp.write(s)
|
||||
fp.write(s.encode())
|
||||
|
||||
def brand_arm(s):
|
||||
if e_ident[4:7] != s:
|
||||
if e_ident[4:7] != s.encode():
|
||||
raise Exception("%s is not %s" % (fn, opts.bfdname))
|
||||
write("\x61") # ELFOSABI_ARM
|
||||
def brand_freebsd(s):
|
||||
if e_ident[4:7] != s:
|
||||
if e_ident[4:7] != s.encode():
|
||||
raise Exception("%s is not %s" % (fn, opts.bfdname))
|
||||
write("\x09")
|
||||
def brand_linux(s):
|
||||
if e_ident[4:7] != s:
|
||||
if e_ident[4:7] != s.encode():
|
||||
raise Exception("%s is not %s" % (fn, opts.bfdname))
|
||||
##write("\x00Linux\x00\x00\x00")
|
||||
write("\x00" * 9)
|
||||
def brand_netbsd(s):
|
||||
if e_ident[4:7] != s:
|
||||
if e_ident[4:7] != s.encode():
|
||||
raise Exception("%s is not %s" % (fn, opts.bfdname))
|
||||
write("\x02")
|
||||
def brand_openbsd(s):
|
||||
if e_ident[4:7] != s:
|
||||
if e_ident[4:7] != s.encode():
|
||||
raise Exception("%s is not %s" % (fn, opts.bfdname))
|
||||
write("\x0c")
|
||||
|
||||
if opts.bfdname[:3] == "elf":
|
||||
if e_ident[:4] != "\x7f\x45\x4c\x46":
|
||||
if e_ident[:4] != "\x7f\x45\x4c\x46".encode():
|
||||
raise Exception("%s is not %s" % (fn, "ELF"))
|
||||
fp.seek(7, 0)
|
||||
if opts.bfdname == "elf32-bigarm" and opts.elfosabi == "arm":
|
||||
|
||||
@ -83,7 +83,7 @@ def parse_comment(state, l, comment):
|
||||
|
||||
|
||||
def handle_inc_c(state, l, ofp):
|
||||
m = re.search(r"^\s*\#\s*include\s+([\"\<])(.+?)([\"\>])(.*)$", l)
|
||||
m = re.search(r"^\s*\#\s*include\s+([\"\<])(.+?)([\"\>])(.*)$", l.decode())
|
||||
if not m:
|
||||
return l
|
||||
q1, inc, q2, comment = m.groups()
|
||||
@ -93,7 +93,7 @@ def handle_inc_c(state, l, ofp):
|
||||
elif q1 == '"' and q2 == '"':
|
||||
dirs = [state[1]] + opts.includes
|
||||
else:
|
||||
raise Exception("syntax error: include line " + l)
|
||||
raise Exception("syntax error: include line " + l.decode())
|
||||
for dir in dirs:
|
||||
fn = os.path.join(dir, inc)
|
||||
if os.path.isfile(fn):
|
||||
@ -130,13 +130,13 @@ def handle_file(ifn, ofp, parent_state=None):
|
||||
ifp = open(ifn, "rb")
|
||||
for l in ifp.readlines():
|
||||
state[2] += 1 # line counter
|
||||
l = l.rstrip("\n")
|
||||
l = l.rstrip("\n".encode())
|
||||
if opts.mode == "c":
|
||||
l = handle_inc_c(state, l, ofp)
|
||||
elif opts.mode == "nasm":
|
||||
l = handle_inc_nasm(state, l, ofp)
|
||||
if l is not None:
|
||||
ofp.write(l + "\n")
|
||||
ofp.write(l + "\n".encode())
|
||||
|
||||
|
||||
def main(argv):
|
||||
@ -179,12 +179,12 @@ def main(argv):
|
||||
os.unlink(fn)
|
||||
if files_mmd:
|
||||
fp = open(fn, "wb")
|
||||
fp.write("%s : \\\n" % opts.target_mmd)
|
||||
fp.write(("%s : \\\n" % opts.target_mmd).encode())
|
||||
for i, f in enumerate(files_mmd):
|
||||
if i < len(files_mmd) - 1:
|
||||
fp.write(" %s \\\n" % f)
|
||||
fp.write((" %s \\\n" % f).encode())
|
||||
else:
|
||||
fp.write(" %s\n" % f)
|
||||
fp.write((" %s\n" % f).encode())
|
||||
fp.close()
|
||||
|
||||
|
||||
|
||||
@ -99,11 +99,11 @@ def main(argv):
|
||||
k, v = m.group(1).strip(), [0, 0, None, 0]
|
||||
assert k and v, (inst, args)
|
||||
v[2] = k # new name
|
||||
if labels.has_key(k):
|
||||
if k in labels:
|
||||
assert labels[k][:2] == v[:2]
|
||||
return k, v
|
||||
def add_label(k, v):
|
||||
if labels.has_key(k):
|
||||
if k in labels:
|
||||
assert labels[k][:2] == v[:2]
|
||||
else:
|
||||
labels[k] = v
|
||||
@ -449,7 +449,7 @@ def main(argv):
|
||||
ofp = open(ofile, "wb")
|
||||
current_label = None
|
||||
for label, inst, args, args_label in olines:
|
||||
if labels.has_key(label):
|
||||
if label in labels:
|
||||
current_label = labels[label][2]
|
||||
if opts.verbose:
|
||||
ofp.write("%s: /* %d */\n" % (labels[label][2], labels[label][3]))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user