Skip to content

Commit 3df8135

Browse files
committed
[ARM][MC][Thumb] Recommit: Revert relocation for some pc-relative fixups.
Summary: This commit recommits the reversion of https://reviews.llvm.org/D75039. Concensus appears to be in favour of assembly-time resolution of these ADR and LDR relocations, in line with GNU. The previous backout broke many lld tests, now fixed by Peter Smith in 61bccda. Reviewers: psmith Subscribers: kristof.beyls, hiraditya, danielkiss, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78301
1 parent 43abef0 commit 3df8135

File tree

6 files changed

+15
-40
lines changed

6 files changed

+15
-40
lines changed

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

+5-7
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
7171
// Name Offset (bits) Size (bits) Flags
7272
{"fixup_arm_ldst_pcrel_12", 0, 32, IsPCRelConstant},
7373
{"fixup_t2_ldst_pcrel_12", 0, 32,
74-
MCFixupKindInfo::FKF_IsPCRel |
75-
MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
74+
IsPCRelConstant | MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
7675
{"fixup_arm_pcrel_10_unscaled", 0, 32, IsPCRelConstant},
7776
{"fixup_arm_pcrel_10", 0, 32, IsPCRelConstant},
7877
{"fixup_t2_pcrel_10", 0, 32,
@@ -82,12 +81,10 @@ const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
8281
{"fixup_t2_pcrel_9", 0, 32,
8382
IsPCRelConstant | MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
8483
{"fixup_thumb_adr_pcrel_10", 0, 8,
85-
MCFixupKindInfo::FKF_IsPCRel |
86-
MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
84+
IsPCRelConstant | MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
8785
{"fixup_arm_adr_pcrel_12", 0, 32, IsPCRelConstant},
8886
{"fixup_t2_adr_pcrel_12", 0, 32,
89-
MCFixupKindInfo::FKF_IsPCRel |
90-
MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
87+
IsPCRelConstant | MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
9188
{"fixup_arm_condbranch", 0, 24, MCFixupKindInfo::FKF_IsPCRel},
9289
{"fixup_arm_uncondbranch", 0, 24, MCFixupKindInfo::FKF_IsPCRel},
9390
{"fixup_t2_condbranch", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
@@ -119,7 +116,8 @@ const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
119116
{"fixup_bfc_target", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
120117
{"fixup_bfcsel_else_target", 0, 32, 0},
121118
{"fixup_wls", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
122-
{"fixup_le", 0, 32, MCFixupKindInfo::FKF_IsPCRel}};
119+
{"fixup_le", 0, 32, MCFixupKindInfo::FKF_IsPCRel}
120+
};
123121
const static MCFixupKindInfo InfosBE[ARM::NumTargetFixupKinds] = {
124122
// This table *must* be in the order that the fixup_* kinds are defined in
125123
// ARMFixupKinds.h.

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

-7
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target,
147147
default:
148148
return ELF::R_ARM_THM_CALL;
149149
}
150-
case ARM::fixup_thumb_adr_pcrel_10:
151-
case ARM::fixup_arm_thumb_cp:
152-
return ELF::R_ARM_THM_PC8;
153-
case ARM::fixup_t2_adr_pcrel_12:
154-
return ELF::R_ARM_THM_ALU_PREL_11_0;
155-
case ARM::fixup_t2_ldst_pcrel_12:
156-
return ELF::R_ARM_THM_PC12;
157150
case ARM::fixup_bf_target:
158151
return ELF::R_ARM_THM_BF16;
159152
case ARM::fixup_bfc_target:

llvm/test/MC/ARM/pcrel-global-rel.s

-18
This file was deleted.

llvm/test/MC/ARM/pcrel-global.s

+8
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ vldr d0, foo @ arm_pcrel_10
1111
adr r2, foo @ arm_adr_pcrel_12
1212
ldr r0, foo @ arm_ldst_pcrel_12
1313

14+
.thumb
15+
.thumb_func
16+
17+
.globl bar
18+
bar:
19+
adr r0, bar @ thumb_adr_pcrel_10
20+
adr.w r0, bar @ t2_adr_pcrel_12
21+
ldr.w pc, bar @ t2_ldst_pcrel_12

llvm/test/MC/ARM/thumb1-relax-adr.s

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
@ RUN: not llvm-mc -triple thumbv6m-none-macho -filetype=obj -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
22
@ RUN: not llvm-mc -triple thumbv7m-none-macho -filetype=obj -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
3-
@ RUN: llvm-mc -triple thumbv6m-none-eabi -filetype=obj %s -o - | llvm-readobj --relocs | FileCheck --check-prefix=CHECK-ELF-T1 %s
4-
@ RUN: llvm-mc -triple thumbv7m-none-eabi -filetype=obj %s -o - | llvm-readobj --relocs | FileCheck --check-prefix=CHECK-ELF-T2 %s
3+
@ RUN: not llvm-mc -triple thumbv7m-none-eabi -filetype=obj -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
54

65
.global func1
76
_func1:
87
adr r0, _func2
98
@ CHECK-ERROR: unsupported relocation on symbol
10-
@ CHECK-ELF-T1: 0x0 R_ARM_THM_PC8 _func2 0x0
11-
@ CHECK-ELF-T2: 0x0 R_ARM_THM_ALU_PREL_11_0 _func2 0x0
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
@ RUN: not llvm-mc -triple thumbv6m-none-macho -filetype=obj -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
22
@ RUN: not llvm-mc -triple thumbv7m-none-macho -filetype=obj -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
3-
@ RUN: llvm-mc -triple thumbv6m-none-eabi -filetype=obj %s -o - | llvm-readobj --relocs | FileCheck --check-prefix=CHECK-ELF-T1 %s
4-
@ RUN: llvm-mc -triple thumbv7m-none-eabi -filetype=obj %s -o - | llvm-readobj --relocs | FileCheck --check-prefix=CHECK-ELF-T2 %s
3+
@ RUN: not llvm-mc -triple thumbv7m-none-eabi -filetype=obj -o /dev/null %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
54

65
.global func1
76
_func1:
87
ldr r0, _func2
98
@ CHECK-ERROR: unsupported relocation on symbol
10-
@ CHECK-ELF-T1: 0x0 R_ARM_THM_PC8 _func2 0x0
11-
@ CHECK-ELF-T2: 0x0 R_ARM_THM_PC12 _func2 0x0

0 commit comments

Comments
 (0)