diff options
| author | Alessandro Gatti <a.gatti@frob.it> | 2025-09-23 01:20:18 +0200 | 
|---|---|---|
| committer | Alessandro Gatti <a.gatti@frob.it> | 2025-10-24 18:31:05 +0200 | 
| commit | b255224d096086cba3d51ecd4206b233eeced6ac (patch) | |
| tree | e757e5059805ec9403d3866e78bfb52b5f3e1a75 | |
| parent | 64971f1a65aed54e6a1c041d069c2cb75f2dd64b (diff) | |
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>
| -rwxr-xr-x | tools/mpy-tool.py | 24 | 
1 files changed, 24 insertions, 0 deletions
| diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index c68f17913..8fab1c969 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -96,6 +96,22 @@ MP_NATIVE_ARCH_XTENSAWIN = 10  MP_NATIVE_ARCH_RV32IMC = 11  MP_NATIVE_ARCH_RV64IMC = 12 +MP_NATIVE_ARCH_NAMES = [ +    "NONE", +    "X86", +    "X64", +    "ARMV6", +    "ARMV6M", +    "ARMV7M", +    "ARMV7EM", +    "ARMV7EMSP", +    "ARMV7EMDP", +    "XTENSA", +    "XTENSAWIN", +    "RV32IMC", +    "RV64IMC", +] +  MP_PERSISTENT_OBJ_FUN_TABLE = 0  MP_PERSISTENT_OBJ_NONE = 1  MP_PERSISTENT_OBJ_FALSE = 2 @@ -635,6 +651,14 @@ class CompiledModule:          print("mpy_source_file:", self.mpy_source_file)          print("source_file:", self.source_file.str)          print("header:", hexlify_to_str(self.header)) +        arch_index = (self.header[2] >> 2) & 0x2F +        if arch_index >= len(MP_NATIVE_ARCH_NAMES): +            arch_name = "UNKNOWN" +        else: +            arch_name = MP_NATIVE_ARCH_NAMES[arch_index] +        print("arch:", arch_name) +        if self.header[2] & MP_NATIVE_ARCH_FLAGS_PRESENT != 0: +            print("arch_flags:", hex(self.arch_flags))          print("qstr_table[%u]:" % len(self.qstr_table))          for q in self.qstr_table:              print("    %s" % q.str) | 
