This is an archive of the discontinued LLVM Phabricator instance.

[MC][ARM] Add range checking for Thumb2 resolved fixups
ClosedPublic

Authored by peter.smith on May 1 2018, 4:28 AM.

Details

Summary

When the branch target of a Thumb2 unconditional or conditonal branch is resolved at assembly time, no range checking is performed on the result leading to incorrect immediates when the maximum range is exceeded. This change adds a range check: +- 16 Megabytes for unconditional branches, +- 1 Megabyte for the conditional branch.

The ranges for the branch instructions can be found in https://developer.arm.com/docs/ddi0406/c/arm-architecture-reference-manual-armv7-a-and-armv7-r-edition
For version C (latest) the higher range can be found in A4.3 Branch instructions. The conditional branch range can be found in A8.8.18 B encoding T3.

Diff Detail

Repository
rL LLVM

Event Timeline

peter.smith created this revision.May 1 2018, 4:28 AM
fhahn accepted this revision.Jun 1 2018, 6:21 AM

LGTM

test/MC/ARM/thumb2-branch-ranges.s
27 ↗(On Diff #144691)

I think using CHECK-LABEL to separate the checks might it slightly easier to track down failures in the future.

This revision is now accepted and ready to land.Jun 1 2018, 6:21 AM
This revision was automatically updated to reflect the committed changes.