Conversation
|
|
||
| 1: @ compiling to ram | ||
| .word XT_R_FROM @ get the synthetic jump address from return stack | ||
| .word XT_1PLUS @ set the thumb bit on the jump address |
There was a problem hiding this comment.
We need to set the thumb bit on the synthetic jump address
| addi s4, s4, 8 | ||
| .endm | ||
|
|
||
| .macro CODEWORD Name, Label |
There was a problem hiding this comment.
RV has the original macro definitions that are now ARCH specific
|
|
||
| # start of flash dictionary. The 0 is the stop marker. | ||
| .macro STARTDICT | ||
| .macro STARTDICTNOPFA |
There was a problem hiding this comment.
STARDICT is now ARCH specific so that we can mark PFA_NOP as .thumb_func for ARM
| So unfortunately we have add another set of symbols for the functions because of ARM, thus the _\Label symbols. | ||
| */ | ||
| .macro HEADER Flags, Name, Label, PFA | ||
| .macro HEADERNOPFA Flags, Name, Label, PFA |
There was a problem hiding this comment.
Splitting off most of the HEADER macro as HEADERNOPFA so that the body doesn't need to be duplicated on the ARM side just to set .thumb_func on the PFA symbol.
| .size _\Label, . - _\Label | ||
| .endm | ||
|
|
||
| .macro CODEWORD Name, Label |
There was a problem hiding this comment.
These macros are now ARCH specific
78a9a9b to
713c652
Compare
| .global _start | ||
| _start: | ||
| ldr r0, =PFA_COLD + 1 | ||
| ldr r0, =PFA_COLD |
There was a problem hiding this comment.
PFA_COLD already has the the thumb-bit set by the CODEWORD macro
| .word XT_COMMA | ||
| .word XT_DOLITERAL | ||
| .word PFA_XDODOES | ||
| .word XT_1PLUS @ MUST set the Thumb bit on the jump address! |
There was a problem hiding this comment.
PFA_XDODOES already has the thumb bit set
ARM interpreter relies on deprecated behaviour of
mov pc, r0which doesn't seem to trigger interworking even though it should as of ARM7. This PR replaces the use ofmov pc, r0with the correctbx r0which required some changes, largely making sure that any code-addresses being jumped to (mostly codeword PFAs) have the thumb bit set, so that it doesn't trigger interworking switch.The right way to ensure the thumb bit seems to be applying the
.thumb_funcdirective to those symbols that should have it. To achieve that the codeword macros (CODEWORD, HEADLESS, ...) are made architecture specific to be able to inject the directive on the ARM side.There are few additional addresses that aren't handled by the code-word macros :
HEADER and STARDICT macro are now split into a shared common part (HEADERNOPFA and STARTDICTNOPFA) invoked by ARCH specific variants. HEADER is still shared because only codeword macros need to be ARCH specific.
Note that only the
bx rNinstruction requires these changes, direct label jumps likeb DO_NEXTorb DO_EXECUTEare PC relative jumps that don't trigger interworking, therefore labels used in these jumps don't need to be marked as .thumb_funcs. However we need to be careful in the future because the linker can inject a veneer when the jump is too long, that uses abxjump under the hood, looking something like this:In these cases the target label does need to have the thumb bit set. So it's more futureproof to set the thumbbit in these cases even if it doesn't need to be at the moment. That's why it is applied to DO_NEXT and DO_EXECUTE as well and should probably be applied to any label that is used as a jump target where the distance can possibly become long at some point.