Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
// signed 16bit range.
if ((Kind == ARM::fixup_arm_movw_lo16 || Kind == ARM::fixup_arm_movt_hi16 ||
Kind == ARM::fixup_t2_movw_lo16 || Kind == ARM::fixup_t2_movt_hi16) &&
(Addend < minIntN(16) || Addend > maxIntN(16))) {
!Target.isAbsolute() && (Addend < minIntN(16) || Addend > maxIntN(16))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe could use IsResolved here instead? I guess it's basically the same thing in this context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, changed to !IsResolved.

Ctx.reportError(Fixup.getLoc(), "Relocation Not In Range");
return 0;
}
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/MC/ARM/arm-movt-movw-absolute-pass.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@RUN: llvm-mc -triple armv7-eabi -filetype obj -o - %s 2>&1 | FileCheck %s

.text
a:
movw r1, #:lower16:b - a + 65536
movt r1, #:upper16:b - a + 65536
b:

@CHECK-NOT: error: Relocation Not In Range
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking for the error message, please just check that we generate the correct instruction encoding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used arm-movt-movw-range-pass.s as a model.

llvm-mc -show-encoding produces :

        movw    r1, :lower16:((b-a)+65536)      @ encoding: [A,0x10'A',0b0000AAAA,0xe3]
                                        @   fixup A - offset: 0, value: (b-a)+65536, kind: fixup_arm_movw_lo16
        movt    r1, :upper16:((b-a)+65536)      @ encoding: [A,0x10'A',0b0100AAAA,0xe3]
                                        @   fixup A - offset: 0, value: (b-a)+65536, kind: fixup_arm_movt_hi16

so it doesn't show the value is resolved.

Do you want a test with llvm-objdump, like :

@RUN: llvm-mc -triple armv7-eabi -filetype obj %s -o - | llvm-objdump -d --triple armv7-eabi - | FileCheck %s

a:
    movw    r1, #:lower16:b - a + 65536
    movt    r1, #:upper16:b - a + 65536
b:

@CHECK: 0: e3001008 movw r1, #0x8
@CHECK: 4: e3401001 movt r1, #0x1

?

But it actually tests more, so I don't know know if you meant with "just check ...".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something with llvm-objdump seems fine, yes.

@CHECK-NOT: movw r1, #:lower16:b - a + 65536
@CHECK-NOT: ^
@CHECK-NOT: error: Relocation Not In Range
@CHECK-NOT: movt r1, #:upper16:b - a + 65536
@CHECK-NOT: ^
Loading