llvm.org GIT mirror llvm / cba7ac7
MC: correct IMAGE_REL_ARM_MOV32T relocation emission This corrects the emission of IMAGE_REL_ARM_MOV32T relocations. Previously, we were avoiding the high portion of the relocation too early. If there was a section-relative relocation with an offset greater than 16-bits (65535), you would end up truncating the high order bits of the offset. Allow the current relocation representation to flow through out the MC layer to the object writer. Use the new ability to restrict recorded relocations to avoid emitting the relocation into the final object. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209337 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 6 years ago
3 changed file(s) with 44 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
10281028 switch (ARM16Expr->getKind()) {
10291029 default: llvm_unreachable("Unsupported ARMFixup");
10301030 case ARMMCExpr::VK_ARM_HI16:
1031 if (Triple(STI.getTargetTriple()).isOSWindows())
1032 return 0;
1033
10341031 Kind = MCFixupKind(isThumb2(STI) ? ARM::fixup_t2_movt_hi16
10351032 : ARM::fixup_arm_movt_hi16);
10361033 break;
2626
2727 unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup,
2828 bool IsCrossSection) const override;
29
30 bool recordRelocation(const MCFixup &) const override;
2931 };
3032
3133 unsigned ARMWinCOFFObjectWriter::getRelocType(const MCValue &Target,
6062 case ARM::fixup_arm_thumb_blx:
6163 return COFF::IMAGE_REL_ARM_BLX23T;
6264 case ARM::fixup_t2_movw_lo16:
65 case ARM::fixup_t2_movt_hi16:
6366 return COFF::IMAGE_REL_ARM_MOV32T;
64 case ARM::fixup_t2_movt_hi16:
65 llvm_unreachable("High-word for pair-wise relocations are contiguously "
66 "addressed as an IMAGE_REL_ARM_MOV32T relocation");
6767 }
68 }
69
70 bool ARMWinCOFFObjectWriter::recordRelocation(const MCFixup &Fixup) const {
71 return static_cast(Fixup.getKind()) != ARM::fixup_t2_movt_hi16;
6872 }
6973 }
7074
0 @ RUN: llvm-mc -triple thumbv7-windows-itanium -filetype obj -o - %s \
1 @ RUN: | llvm-readobj -r - | FileCheck -check-prefix CHECK-RELOCATIONS %s
2
3 @ RUN: llvm-mc -triple thumbv7-windows-itanium -filetype obj -o - %s \
4 @ RUN: | llvm-objdump -d - | FileCheck -check-prefix CHECK-ENCODING %s
5
6 .syntax unified
7 .thumb
8 .text
9
10 .def truncation
11 .scl 3
12 .type 32
13 .endef
14 .align 2
15 .thumb_func
16 truncation:
17 movw r0, :lower16:.Lerange
18 movt r0, :upper16:.Lerange
19 bx lr
20
21 .section .rdata,"rd"
22 .Lbuffer:
23 .zero 65536
24 .Lerange:
25 .asciz "-erange"
26
27 @ CHECK-RELOCATIONS: Relocations [
28 @ CHECK-RELOCATIONS: .text {
29 @ CHECK-RELOCATIONS: 0x0 IMAGE_REL_ARM_MOV32T .rdata
30 @ CHECK-RELOCATIONS-NOT: 0x4 IMAGE_REL_ARM_MOV32T .rdata
31 @ CHECK-RELOCATIONS: }
32 @ CHECK-RELOCATIONS: ]
33
34 @ CHECK-ENCODING: 0: 40 f2 00 00
35 @ CHECK-ENCODING-NEXT: 4: c0 f2 01 00
36