This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Always interpret arm instructions as thumb on windows
ClosedPublic

Authored by mstorsjo on Nov 27 2019, 2:16 PM.

Details

Summary

Windows on arm always uses thumb mode, and doesn't have most of the mechanisms that are used in e.g. ELF for distinguishing between arm and thumb.

Diff Detail

Event Timeline

mstorsjo created this revision.Nov 27 2019, 2:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 27 2019, 2:16 PM
labath accepted this revision.Nov 27 2019, 11:18 PM

Seems reasonable. Just out of curiosity, is this restriction enforced in some way? E.g., if I manually do a bx to an arm address, will the system kill me?

This revision is now accepted and ready to land.Nov 27 2019, 11:18 PM

Seems reasonable. Just out of curiosity, is this restriction enforced in some way? E.g., if I manually do a bx to an arm address, will the system kill me?

No, such simple cases do work (or at least they used to), but the linker doesn't really have any means to e.g. set the x bit in bl/blx instructions properly. And allegedly, in earlier versions, the kernel didn't switch modes correctly when entering the kernel, so entering the kernel from arm code, would try to execute the kernel's code in arm mode, effectively crashing the system (https://reviews.llvm.org/D43005#1018582 for reference). I think that aspect is fixed these days, but it's pretty much unsupported on most levels where the interworking requires some support from the tools or frameworks.

And allegedly, in earlier versions, the kernel didn't switch modes correctly when entering the kernel, so entering the kernel from arm code, would try to execute the kernel's code in arm mode, effectively crashing the system

LOL :D

This revision was automatically updated to reflect the committed changes.

This is failing for me with:

(lldb) disassemble -b -n entry
error: Unable to find Disassembler plug-in for the 'armv7' architecture.

I assume that's because I run with LLVM_TARGETS_TO_BUILD:STRING=X86;AArch64 in my CMake configuration. Do we have a way to make this test condition on the ARM target being enabled or do we have the ARM target as a hard requirement for the test suit?

REQUIRES: arm ought to do the trick.

This is failing for me with:

(lldb) disassemble -b -n entry
error: Unable to find Disassembler plug-in for the 'armv7' architecture.

I assume that's because I run with LLVM_TARGETS_TO_BUILD:STRING=X86;AArch64 in my CMake configuration.

Oops, sorry about that.

Do we have a way to make this test condition on the ARM target being enabled or do we have the ARM target as a hard requirement for the test suit?

The ARM target should definitely not be a hard requirement. Is the test skipped for you if you add a # REQUIRES: arm line?

I pushed a commit to add such a REQUIRES line now.

Yeah, that fixes it. Thanks!