Spaces:
Sleeping
Sleeping
Commit
·
6cdaa1a
1
Parent(s):
1ac2d88
relocs
Browse files
main.py
CHANGED
@@ -68,20 +68,27 @@ def compile(compiler, flags, source):
|
|
68 |
|
69 |
# Disassemble the object file
|
70 |
disassembly = subprocess.run(
|
71 |
-
["objdump", "-
|
72 |
capture_output=True,
|
73 |
text=True
|
74 |
).stdout
|
75 |
disassembly = trim_objdump(disassembly)
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
if result.returncode == 0:
|
78 |
-
return compiled_bytes, compile_output, disassembly
|
79 |
else:
|
80 |
-
return None, compile_output, disassembly
|
81 |
|
82 |
def predict(target_bytes, source, compiler, flags, disasm_arch, disasm_options):
|
83 |
target_bytes = bytes.fromhex(target_bytes)
|
84 |
-
compiled_bytes, compile_output, compiled_disassembly = compile(compiler, flags, source)
|
85 |
target_disassembly = disassemble_bytes(target_bytes, disasm_arch, disasm_options)
|
86 |
|
87 |
if compiled_bytes is not None:
|
@@ -91,6 +98,7 @@ def predict(target_bytes, source, compiler, flags, disasm_arch, disasm_options):
|
|
91 |
editdistance.eval(compiled_bytes, target_bytes),
|
92 |
compile_output,
|
93 |
compiled_disassembly,
|
|
|
94 |
target_disassembly
|
95 |
)
|
96 |
else:
|
@@ -100,6 +108,7 @@ def predict(target_bytes, source, compiler, flags, disasm_arch, disasm_options):
|
|
100 |
-1,
|
101 |
compile_output,
|
102 |
compiled_disassembly,
|
|
|
103 |
target_disassembly
|
104 |
)
|
105 |
|
@@ -130,6 +139,7 @@ def run():
|
|
130 |
gr.Number(label="Edit distance (lower is better)"),
|
131 |
gr.Textbox(label="Compiler Output"),
|
132 |
gr.Textbox(label="Compiled Disassembly"),
|
|
|
133 |
gr.Textbox(label="Target Disassembly"),
|
134 |
],
|
135 |
)
|
|
|
68 |
|
69 |
# Disassemble the object file
|
70 |
disassembly = subprocess.run(
|
71 |
+
["objdump", "-r", temp_o_file_name],
|
72 |
capture_output=True,
|
73 |
text=True
|
74 |
).stdout
|
75 |
disassembly = trim_objdump(disassembly)
|
76 |
|
77 |
+
# Relocs
|
78 |
+
relocs = subprocess.run(
|
79 |
+
["objdump", "-r", temp_o_file_name],
|
80 |
+
capture_output=True,
|
81 |
+
text=True
|
82 |
+
).stdout
|
83 |
+
|
84 |
if result.returncode == 0:
|
85 |
+
return relocs, compiled_bytes, compile_output, disassembly
|
86 |
else:
|
87 |
+
return None, None, compile_output, disassembly
|
88 |
|
89 |
def predict(target_bytes, source, compiler, flags, disasm_arch, disasm_options):
|
90 |
target_bytes = bytes.fromhex(target_bytes)
|
91 |
+
compiled_relocs, compiled_bytes, compile_output, compiled_disassembly = compile(compiler, flags, source)
|
92 |
target_disassembly = disassemble_bytes(target_bytes, disasm_arch, disasm_options)
|
93 |
|
94 |
if compiled_bytes is not None:
|
|
|
98 |
editdistance.eval(compiled_bytes, target_bytes),
|
99 |
compile_output,
|
100 |
compiled_disassembly,
|
101 |
+
compiled_relocs,
|
102 |
target_disassembly
|
103 |
)
|
104 |
else:
|
|
|
108 |
-1,
|
109 |
compile_output,
|
110 |
compiled_disassembly,
|
111 |
+
compiled_relocs,
|
112 |
target_disassembly
|
113 |
)
|
114 |
|
|
|
139 |
gr.Number(label="Edit distance (lower is better)"),
|
140 |
gr.Textbox(label="Compiler Output"),
|
141 |
gr.Textbox(label="Compiled Disassembly"),
|
142 |
+
gr.Textbox(label="Compiled relocations"),
|
143 |
gr.Textbox(label="Target Disassembly"),
|
144 |
],
|
145 |
)
|