Skip to content

Commit 5e80358

Browse files
authored
[llvm][ARM] Allow MOVT and MOVW on the offset between two labels (#168072)
In this case, the value is a constant, not an addend to a relocation. So the "Relocation Not In Range" error must not be triggered. Regression from PR #112877 Fixes #132322
1 parent 3e499e9 commit 5e80358

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
428428
// signed 16bit range.
429429
if ((Kind == ARM::fixup_arm_movw_lo16 || Kind == ARM::fixup_arm_movt_hi16 ||
430430
Kind == ARM::fixup_t2_movw_lo16 || Kind == ARM::fixup_t2_movt_hi16) &&
431-
(Addend < minIntN(16) || Addend > maxIntN(16))) {
431+
!IsResolved && (Addend < minIntN(16) || Addend > maxIntN(16))) {
432432
Ctx.reportError(Fixup.getLoc(), "Relocation Not In Range");
433433
return 0;
434434
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@RUN: llvm-mc -triple armv7-eabi -filetype obj %s -o - | llvm-objdump -d --triple armv7-eabi - | FileCheck %s
2+
3+
a:
4+
movw r1, #:lower16:b - a + 65536
5+
movt r1, #:upper16:b - a + 65536
6+
b:
7+
8+
@CHECK: 0: e3001008 movw r1, #0x8
9+
@CHECK: 4: e3401001 movt r1, #0x1

0 commit comments

Comments
 (0)