Skip to content

Commit 86b9dfd

Browse files
authored
Add has_decompiler for arm32 platforms (#1741)
* Add has_decompiler for arm32 platforms * Handle missing '.syntax unified' for gba * allow fallback to default compiler if arch is supported
1 parent d40983d commit 86b9dfd

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

backend/coreapp/decompiler_wrapper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def decompile(
3030
if len(asm.splitlines()) > MAX_M2C_ASM_LINES:
3131
return "/* Too many lines to decompile; please run m2c manually */"
3232
try:
33+
if platform.id == "gba" and "thumb_func_start" in asm:
34+
asm = f".syntax unified\n{asm}"
3335
ret = M2CWrapper.decompile(asm, context, compiler, platform.arch)
3436
except M2CError as e:
3537
# Attempt to decompile the source without context as a last-ditch effort

backend/coreapp/m2c_wrapper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def get_triple(compiler: Compiler, arch: str) -> str:
3333

3434
if compiler.type != CompilerType.OTHER:
3535
triple += f"-{compiler.type.value}"
36-
else:
37-
raise M2CError(f"Unsupported compiler '{compiler}'")
3836

3937
return triple
4038

backend/coreapp/platforms.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def from_id(platform_id: str) -> Platform:
226226
assemble_cmd='sed -i -e "s/;/;@/" "$INPUT" && arm-none-eabi-as -march=armv5te -mthumb -o "$OUTPUT" "$PRELUDE" "$INPUT"',
227227
objdump_cmd="arm-none-eabi-objdump",
228228
nm_cmd="arm-none-eabi-nm",
229+
has_decompiler=True,
229230
)
230231

231232
GBA = Platform(
@@ -236,6 +237,7 @@ def from_id(platform_id: str) -> Platform:
236237
assemble_cmd='sed -i -e "s/;/;@/" "$INPUT" && arm-none-eabi-as -mcpu=arm7tdmi -mthumb -o "$OUTPUT" "$PRELUDE" "$INPUT"',
237238
objdump_cmd="arm-none-eabi-objdump",
238239
nm_cmd="arm-none-eabi-nm",
240+
has_decompiler=True,
239241
)
240242

241243
N3DS = Platform(
@@ -246,6 +248,7 @@ def from_id(platform_id: str) -> Platform:
246248
assemble_cmd='sed -i -e "s/;/;@/" "$INPUT" && arm-none-eabi-as -mfpu=vfpv2 -march=armv6k -o "$OUTPUT" "$PRELUDE" "$INPUT"',
247249
objdump_cmd="arm-none-eabi-objdump",
248250
nm_cmd="arm-none-eabi-nm",
251+
has_decompiler=True,
249252
)
250253

251254
_platforms: OrderedDict[str, Platform] = OrderedDict(

0 commit comments

Comments
 (0)