2017-12-05 23:59:05 +08:00
|
|
|
// REQUIRES: aarch64
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o
|
|
|
|
// RUN: echo "SECTIONS { \
|
|
|
|
// RUN: .text1 0x10000 : { *(.text.01) *(.text.02) *(.text.03) } \
|
2017-12-15 23:30:00 +08:00
|
|
|
// RUN: .text2 0x8010000 : { *(.text.04) } } " > %t.script
|
2018-02-09 08:15:12 +08:00
|
|
|
// RUN: ld.lld --script %t.script -fix-cortex-a53-843419 -verbose %t.o -o %t2 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix=CHECK-PRINT %s
|
2017-12-15 18:32:34 +08:00
|
|
|
// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 | FileCheck %s
|
2017-12-05 23:59:05 +08:00
|
|
|
|
2017-12-15 23:30:00 +08:00
|
|
|
// %t2 is 128 Megabytes, so delete it early.
|
2017-12-15 22:56:01 +08:00
|
|
|
// RUN: rm %t2
|
|
|
|
|
2017-12-05 23:59:05 +08:00
|
|
|
// Test cases for Cortex-A53 Erratum 843419 that involve interactions with
|
|
|
|
// range extension thunks. Both erratum fixes and range extension thunks need
|
|
|
|
// precise address information and after creation alter address information.
|
|
|
|
|
|
|
|
|
|
|
|
.section .text.01, "ax", %progbits
|
|
|
|
.balign 4096
|
|
|
|
.globl _start
|
|
|
|
.type _start, %function
|
|
|
|
_start:
|
|
|
|
bl far_away
|
|
|
|
// Thunk to far_away, size 16-bytes goes here.
|
|
|
|
|
|
|
|
.section .text.02, "ax", %progbits
|
|
|
|
.space 4096 - 28
|
|
|
|
|
|
|
|
// Erratum sequence will only line up at address 0 modulo 0xffc when
|
|
|
|
// Thunk is inserted.
|
|
|
|
.section .text.03, "ax", %progbits
|
|
|
|
.globl t3_ff8_ldr
|
|
|
|
.type t3_ff8_ldr, %function
|
|
|
|
t3_ff8_ldr:
|
|
|
|
adrp x0, dat
|
|
|
|
ldr x1, [x1, #0]
|
|
|
|
ldr x0, [x0, :got_lo12:dat]
|
|
|
|
ret
|
|
|
|
|
|
|
|
// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 10FFC in unpatched output.
|
2017-12-15 18:32:34 +08:00
|
|
|
// CHECK: t3_ff8_ldr:
|
2017-12-15 23:30:00 +08:00
|
|
|
// CHECK-NEXT: 10ffc: 00 00 04 90 adrp x0, #134217728
|
|
|
|
// CHECK-NEXT: 11000: 21 00 40 f9 ldr x1, [x1]
|
|
|
|
// CHECK-NEXT: 11004: 02 00 00 14 b #8
|
|
|
|
// CHECK-NEXT: 11008: c0 03 5f d6 ret
|
2017-12-15 18:32:34 +08:00
|
|
|
// CHECK: __CortexA53843419_11004:
|
[ELF] Simplify RelRo, TLS, NOBITS section ranks and make RW PT_LOAD start with RelRo
Old: PT_LOAD(.data | PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .bss)
New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .data .bss)
The placement of | indicates page alignment caused by PT_GNU_RELRO. The
new layout has simpler rules and saves space for many cases.
Old size: roundup(.data) + roundup(.data.rel.ro)
New size: roundup(.data.rel.ro + .bss.rel.ro) + .data
Other advantages:
* At runtime the 3 memory mappings decrease to 2.
* start(PT_TLS) = start(PT_GNU_RELRO) = start(RW PT_LOAD). This
simplifies binary manipulation tools.
GNU strip before 2.31 discards PT_GNU_RELRO if its
address is not equal to the start of its associated PT_LOAD.
This has been fixed by https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f
But with this change, we will be compatible with GNU strip before 2.31
* Before, .got.plt (non-relro by default) was placed before .got (relro
by default), which made it impossible to have _GLOBAL_OFFSET_TABLE_
(start of .got.plt on x86-64) equal to the end of .got (R_GOT*_FROM_END)
(https://bugs.llvm.org/show_bug.cgi?id=36555). With the new ordering, we
can improve on this regard if we'd like to.
Reviewers: ruiu, espindola, pcc
Subscribers: emaste, arichardson, llvm-commits, joerg, jdoerfert
Differential Revision: https://reviews.llvm.org/D56828
llvm-svn: 356117
2019-03-14 11:47:45 +08:00
|
|
|
// CHECK-NEXT: 1100c: 00 04 40 f9 ldr x0, [x0, #8]
|
2017-12-15 23:30:00 +08:00
|
|
|
// CHECK-NEXT: 11010: fe ff ff 17 b #-8
|
2017-12-15 18:32:34 +08:00
|
|
|
|
2017-12-05 23:59:05 +08:00
|
|
|
.section .text.04, "ax", %progbits
|
|
|
|
.globl far_away
|
|
|
|
.type far_away, function
|
|
|
|
far_away:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.section .data
|
|
|
|
.globl dat
|
|
|
|
dat: .quad 0
|