This patch adds a thunk for Thumb long branch on V6-M for eXecute Only.
Note that there is currently no support for a position independent and
eXecute Only V6-M long branch thunk.
Differential D153772
[ARM] armv6m eXecute Only (XO) long branch Thunk keith.walker.arm on Jun 26 2023, 7:39 AM. Authored by
Details This patch adds a thunk for Thumb long branch on V6-M for eXecute Only. Note that there is currently no support for a position independent and
Diff Detail
Event Timeline
Comment Actions Can you put [LLD] in the title [LLD][ARM] armv6m eXecute Only (XO) long branch Thunk?
Possible Typo, I think it is position independent. I think the use case of position independence and execute-only on v6-m, and requirements for long branches will be exceedingly rare so I think an error message is good enough. I think a PI variant is possible in theory although I don't think the existing ABI relocations could be used, would need to manually code them or alter the ABI.
Comment Actions Updated to address review comments:
During testing I found that there is an issue if the distance between the source & destination is exactly 16M. A branch instruction is generated (rather than the long thunk code squence) which is not legal for armv6-m which only allows branches +/-2K. However this is not specific to this XO change, it already happens if XO is not involved so I think this is something that should be fixed separately.
Comment Actions
I had thought something similar, but then managed to convince myself it wouldn't happen as LLD wouldn't generate a thunk for the narrow branch relocation, forgetting that these could be generated from BL relocations. I agree that it would be best fixed as a separate patch rather than tagged on to this one. Thanks for the update. I've only got a few more nits that I should have noticed first time round. Otherwise this looks good to me.
Comment Actions Made the following changes:
Comment Actions Ideally, we should improve the test to test the limit of the range extension thunk. ppc64-long-branch-pi.s checks this but such tests are not common for range extension thunk support. I'll be out of town til July 5. I think the code is good. Accepted once @peter.smith is happy as well.
Comment Actions I did originally try to add a range limit check and that was when I found (and mentioned in an earlier comment) that for armv6-m in general (not just XO) a branch instuction is generated which is not supported by the armv6-m architecure. Fixing that issue is outside the scope of this change specifically aimed at XO. Attempting to add a range limit check at this time would enshrine the invalid branch instruction as being correct. I think adding the range limit checks should be added when this branch problem is fixed for armv6-m in general. |
Not sure if we should prefer speed over space, but seeing the speed penalty, wouldn't it be better to use r12 instead of the stack to store the address?