Closed Quuxplusone closed 5 years ago
Thanks for the report and the suggested, LLD has tended to focus on Arm v7a for
Linux and tends to add new functionality only when people need it. Please do
keep reporting problems as you find them.
We should be able to take it from here. With luck I'll have time to do it this
week, but it may slip till after Christmas due to holidays. If you want to go
ahead and submit it yourself there are instructions at
https://llvm.org/docs/DeveloperPolicy.html#making-and-submitting-a-patch
If you do, you would probably want something like the following sequence, which
preserves the ABI required 8-byte stack alignment, and is a bit smaller.
push {r0, r1}
ldr r0, [pc, #4]
str r0, [sp, #4]
pop {r0, pc}
.word DESTINATION
Adding tests is fairly straightforward and can generally be worked out by
following the examples in lld/test/ELF , look for the arm-thunk*.s files,
particularly those that use a linker script. What we'd do is add a new .s file
for the v6-m thunks run lld and then use llvm-objdump to check that the thunks
we'd expected had been created. The FileCheck program tests the output
https://llvm.org/docs/CommandGuide/FileCheck.html
There is actually a prototype test already there for non-support of v6m thunks. See test/ELF/arm-thumb-nov6thunk.s this could be renamed and converted to a test for v6m fairly simply.
Indeed your version is better, and I did forget about the stack alignment.
The test does not appear to be part of the official 7.0 tarball, I guess it has been introduced on SVN or Git.
I'll try to have a look at it, thanks for the pointer.
As it happens it looks like I'll definitely be able to submit a patch this week hopefully tomorrow.
The file was added on the 20th August 2018 which AFAIK is after the branch date for 7.0. It is almost always best to use the svn or git mirrors for development as LLVM tends to move fast.
I've submitted https://reviews.llvm.org/D55555 for review. This is rebased on top of LLVM trunk and probably won't apply on top of the 7.0 source.
Committed support for v6 Thunks in r349337 resolving for now.
Thanks a lot for addressing this issue, Peter.
ARMv6M does not support movw/movt Thumb2 instructions.
Current LLD version v7.0 emits such instructions to generate long jump in thunks. For example, this code generation occurs when code is relocated from flash to RAM on embedded Cortex-M0/M0+ cores.
This prevents using LLD with Cortex-M0/M0+ cores when such a feature is used.
I've written a small patch to support this feature, but I'm not a LLD developer and I do not know how to write valid tests for the LLVM infrastructure, so I guess this would require more work effort to propose a valid patch:
https://gist.github.com/eblot/43552f8c01cc7d2ee4faef42454c2c83
It only support absolute addressing, not position-independent code - I'm not sure this is a useful feature on M0+ core anyway and I would not have any real world examples to test it.