Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AArch64] Cortex-a53-843419 erratum should not apply to relaxed TLS.
The changes to the instructions performed by TLS relaxation and the errata patching are performed with relocations. As these are applied so late the errata scanning won't see the changes in the section data made by the TLS relaxation. This can lead to a TLS relaxed sequence being patched when it doesn't need to be. The fix checks to see if there is a R_RELAX_TLS_IE_TO_LE instruction at the same address as the ADRP as this indicates the presence of a relaxation of a sequence that might get recognised as a patch. Differential Revision: https://reviews.llvm.org/D54854 llvm-svn: 347649
- Loading branch information
Showing
2 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// REQUIRES: aarch64 | ||
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o | ||
// RUN: ld.lld -fix-cortex-a53-843419 %t.o -o %t2 | ||
// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 | FileCheck %s | ||
|
||
// The following code sequence is covered by the TLS IE to LE relaxation. It | ||
// transforms the ADRP, LDR to MOVZ, MOVK. The former can trigger a | ||
// cortex-a53-843419 patch, whereas the latter can not. As both | ||
// relaxation and patching transform instructions very late in the | ||
// link there is a possibility of them both being simultaneously | ||
// applied. In this case the relaxed sequence is immune from the erratum so we | ||
// prefer to keep it. | ||
.text | ||
.balign 4096 | ||
.space 4096 - 8 | ||
.globl _start | ||
.type _start,@function | ||
_start: | ||
mrs x1, tpidr_el0 | ||
adrp x0, :gottprel:v | ||
ldr x1, [x0, #:gottprel_lo12:v] | ||
adrp x0, :gottprel:v | ||
ldr x1, [x0, #:gottprel_lo12:v] | ||
ret | ||
|
||
// CHECK: _start: | ||
// CHECK-NEXT: 210ff8: 41 d0 3b d5 mrs x1, TPIDR_EL0 | ||
// CHECK-NEXT: 210ffc: 00 00 a0 d2 movz x0, #0, lsl #16 | ||
// CHECK-NEXT: 211000: 01 02 80 f2 movk x1, #16 | ||
// CHECK-NEXT: 211004: 00 00 a0 d2 movz x0, #0, lsl #16 | ||
// CHECK-NEXT: 211008: 01 02 80 f2 movk x1, #16 | ||
// CHECK-NEXT: 21100c: c0 03 5f d6 ret | ||
|
||
.type v,@object | ||
.section .tbss,"awT",@nobits | ||
.globl v | ||
v: | ||
.word 0 |