8000 tools/mpy-tool.py: Add architecture flags to disassembly output. · micropython/micropython@b255224 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit b255224

Browse files
committed
tools/mpy-tool.py: Add architecture flags to disassembly output.
This commit extends "mpy-tool.py"'s disassembly output of a given MPY file (triggered via the "-d" command line option) to include newly added fields. Now the target architecture for the chosen MPY file is printed out to screen in human-readable format and, if present, architecture-specific flags. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
1 parent 64971f1 commit b255224

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tools/mpy-tool.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ class Config:
9696
MP_NATIVE_ARCH_RV32IMC = 11
9797
MP_NATIVE_ARCH_RV64IMC = 12
9898

99+
MP_NATIVE_ARCH_NAMES = [
100+
"NONE",
101+
"X86",
102+
"X64",
103+
"ARMV6",
104+
"ARMV6M",
105+
"ARMV7M",
106+
"ARMV7EM",
107+
"ARMV7EMSP",
108+
"ARMV7EMDP",
109+
"XTENSA",
110+
"XTENSAWIN",
111+
"RV32IMC",
112+
"RV64IMC",
113+
]
114+
99115
MP_PERSISTENT_OBJ_FUN_TABLE = 0
100116
MP_PERSISTENT_OBJ_NONE = 1
101117
MP_PERSISTENT_OBJ_FALSE = 2
@@ -635,6 +651,14 @@ def disassemble(self):
635651
print("mpy_source_file:", self.mpy_source_file)
636652
print("source_file:", self.source_file.str)
637653
print("header:", hexlify_to_str(self.header))
654+
arch_index = (self.header[2] >> 2) & 0x2F
655+
if arch_index >= len(MP_NATIVE_ARCH_NAMES):
656+
arch_name = "UNKNOWN"
657+
else:
658+
arch_name = MP_NATIVE_ARCH_NAMES[arch_index]
659+
print("arch:", arch_name)
660+
if self.header[2] & MP_NATIVE_ARCH_FLAGS_PRESENT != 0:
661+
print("arch_flags:", hex(self.arch_flags))
638662
print("qstr_table[%u]:" % len(self.qstr_table))
639663
for q in self.qstr_table:
640664
print(" %s" % q.str)

0 commit comments

Comments
 (0)
0