I’m in the process of adding support for relocations in the AArch32 JITLink backend. While writing test cases making use of jitlink-check I noticed that decode_operand() was not able to disassemble Thumb instructions correctly though there is no problem with ARM instructions. I suspect the halfword layout in memory is the cause of it. I’m curious whether jitlink-check which is RuntimeDyldChecker under the hood, does not support Thumb instructions.
I never checked, so there might totally be an issue. Before we start investigating, can you please check this existing test that uses it for Thumb code? Does it reproduce your observation?
RuntimeDyld/ARM/COFF_Thumb.s works without an issue.
My initial suspicion is that the problem might be about the target triple. Rtdyld has no problem as triple is given as argument however jitlink infers the triple.
For example what the rtdyld sees as triple in the test case above is thumbv7-unknown-windows-msvc on this line in llvm-rtdyld driver.
In jitlink, the triple is armv7-- and Thumb is in the subtarget features +aclass,+thumb2,+vfp3,+neon on this line in llvm-jitlink driver.
Here is the test case I’m trying out Thumb with llvm-jitlink:
My initial suspicion is that the problem might be about the target triple. Rtdyld has no problem as triple is given as argument however jitlink infers the triple. […] In jitlink, the triple is armv7-- and Thumb is in the subtarget features +aclass,+thumb2,+vfp3,+neon
Yes, the decoding works if we force the triple to thumb. Inferring the triple from the object file always returns arm though and while we do get the +thumb2 feature, the disassembler only checks for the ARM::ModeThumb and not ARM::FeatureThumb2. That all seems on purpose as is.
What about forcing the triple to thumb if we find the +thumb2 feature here?
The LinkGraph tracks whether each symbol is thumb or not, right? Maybe we could plumb that through to the checker? Then it would work for mixed arm / thumb code too.