summaryrefslogtreecommitdiff
path: root/tools/mpy-tool.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-06-11 11:36:39 +1000
committerDamien George <damien.p.george@gmail.com>2019-06-11 11:36:39 +1000
commit9d3031cc9d888321b122d7e92491ba045727ac32 (patch)
tree79ac545aef5a217989211ef539208ac0bd06f388 /tools/mpy-tool.py
parent62f004ba424920a01e60c7a9a064b8ec9cd69c12 (diff)
tools/mpy-tool.py: Fix linking of qstr objects in native ARM Thumb code.
Previously, when linking qstr objects in native code for ARM Thumb, the index into the machine code was being incremented by 4, not 8. It should be 8 to account for the size of the two machine instructions movw and movt. This patch makes sure the index into the machine code is incremented by the correct amount for all variations of qstr linking. See issue #4829.
Diffstat (limited to 'tools/mpy-tool.py')
-rwxr-xr-xtools/mpy-tool.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py
index db6fe2383..a97af7737 100755
--- a/tools/mpy-tool.py
+++ b/tools/mpy-tool.py
@@ -481,6 +481,7 @@ class RawCodeNative(RawCode):
if kind == 0:
# Generic 16-bit link
print(' %s & 0xff, %s >> 8,' % (qst, qst))
+ return 2
else:
# Architecture-specific link
is_obj = kind == 2
@@ -488,14 +489,17 @@ class RawCodeNative(RawCode):
qst = '((uintptr_t)MP_OBJ_NEW_QSTR(%s))' % qst
if config.native_arch in (MP_NATIVE_ARCH_X86, MP_NATIVE_ARCH_X64):
print(' %s & 0xff, %s >> 8, 0, 0,' % (qst, qst))
+ return 4
elif MP_NATIVE_ARCH_ARMV6M <= config.native_arch <= MP_NATIVE_ARCH_ARMV7EMDP:
if is_obj:
# qstr object, movw and movt
self._asm_thumb_rewrite_mov(pc, qst)
self._asm_thumb_rewrite_mov(pc + 4, '(%s >> 16)' % qst)
+ return 8
else:
# qstr number, movw instruction
self._asm_thumb_rewrite_mov(pc, qst)
+ return 4
else:
assert 0
@@ -523,8 +527,7 @@ class RawCodeNative(RawCode):
# link qstr
qi_off, qi_kind, qi_val = self.qstr_links[qi]
qst = global_qstrs[qi_val].qstr_id
- self._link_qstr(i, qi_kind, qst)
- i += 4
+ i += self._link_qstr(i, qi_kind, qst)
qi += 1
else:
# copy machine code (max 16 bytes)