xmos / lib_xcore_math

XMOS optimised arithmetic and vector processing library
Other
6 stars 14 forks source link

Constants appear in disassembly as unknown opcodes #145

Open danielpieczko opened 1 year ago

danielpieczko commented 1 year ago

I built and disassembled the FFD xcore-voice application and found this:

<xscope_xlink_start_token_ret>:
             0x00093f12: c0 77:       retsp (u6)      0x0
             0x00093f14: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f16: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f18: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f1a: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f1c: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f1e: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f20: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f22: 80 ff:       ...
             0x00093f24: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f26: 80 ff:       ...
             0x00093f28: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f2a: 80 ff:       ...
             0x00093f2c: 00 00:       stw (2rus)      r0, r0[0x0]
             0x00093f2e: 80 ff:       ...

Note the 80 ff opcodes that can't be decoded into a valid instruction. It continues beyond this address with other values, some of which are valid instructions and others that aren't.

xscope_xlink_start_token_ret returns immediately and it turns out that the data which follows is unrelated to libxscope.a (which contains the xscope_xlink_start_token_ret symbol). Instead, this data is this set of constants.

They are in the .text section so they appear in the disassembly, so perhaps they should be in a data section instead. Using .text might be intentional for some reason (eg. to be able to dual-issue this code efficiently), so this change might not be possible without harming the performance.

This issue is purely cosmetic in that the code appears to work correctly, it just displays invalid instructions in the disassembly.