2015-12-03 16:05:35 +08:00
|
|
|
// REQUIRES: aarch64
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %p/Inputs/relocation-copy.s -o %t2.o
|
2018-05-16 01:02:35 +08:00
|
|
|
// RUN: ld.lld -shared %t2.o -soname fixed-length-string.so -o %t2.so
|
2019-07-19 14:33:36 +08:00
|
|
|
// RUN: ld.lld %t.o %t2.so -o %t
|
|
|
|
// RUN: llvm-readobj -S -r --symbols %t | FileCheck %s
|
2020-03-16 08:47:44 +08:00
|
|
|
// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=CODE %s
|
|
|
|
// RUN: llvm-objdump -s --section=.rodata %t | FileCheck --check-prefix=RODATA %s
|
2015-12-03 16:05:35 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
adr x1, x
|
|
|
|
adrp x2, y
|
|
|
|
add x2, x2, :lo12:y
|
2016-04-14 09:48:11 +08:00
|
|
|
.rodata
|
2015-12-03 16:05:35 +08:00
|
|
|
.word z
|
|
|
|
|
|
|
|
// CHECK: Name: .bss
|
|
|
|
// CHECK-NEXT: Type: SHT_NOBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
2019-08-20 16:34:56 +08:00
|
|
|
// CHECK-NEXT: Address: 0x2303F0
|
2015-12-03 16:05:35 +08:00
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size: 24
|
|
|
|
// CHECK-NEXT: Link:
|
|
|
|
// CHECK-NEXT: Info:
|
|
|
|
// CHECK-NEXT: AddressAlignment: 16
|
|
|
|
|
|
|
|
// CHECK: Relocations [
|
|
|
|
// CHECK-NEXT: Section ({{.*}}) .rela.dyn {
|
2019-08-20 16:34:56 +08:00
|
|
|
// CHECK-NEXT: 0x2303F0 R_AARCH64_COPY x 0x0
|
|
|
|
// CHECK-NEXT: 0x230400 R_AARCH64_COPY y 0x0
|
|
|
|
// CHECK-NEXT: 0x230404 R_AARCH64_COPY z 0x0
|
2015-12-03 16:05:35 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
|
|
|
|
// CHECK: Symbols [
|
|
|
|
// CHECK: Name: x
|
2019-08-20 16:34:56 +08:00
|
|
|
// CHECK-NEXT: Value: 0x2303F0
|
2015-12-03 16:05:35 +08:00
|
|
|
// CHECK-NEXT: Size: 4
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Object
|
|
|
|
// CHECK-NEXT: Other:
|
|
|
|
// CHECK-NEXT: Section: .bss
|
|
|
|
// CHECK: Name: y
|
2019-08-20 16:34:56 +08:00
|
|
|
// CHECK-NEXT: Value: 0x230400
|
2015-12-03 16:05:35 +08:00
|
|
|
// CHECK-NEXT: Size: 4
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Object
|
|
|
|
// CHECK-NEXT: Other:
|
|
|
|
// CHECK-NEXT: Section: .bss
|
|
|
|
// CHECK: Name: z
|
2019-08-20 16:34:56 +08:00
|
|
|
// CHECK-NEXT: Value: 0x230404
|
2015-12-03 16:05:35 +08:00
|
|
|
// CHECK-NEXT: Size: 4
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Object
|
|
|
|
// CHECK-NEXT: Other:
|
|
|
|
// CHECK-NEXT: Section: .bss
|
|
|
|
// CHECK: ]
|
|
|
|
|
|
|
|
// CODE: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CODE-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// CODE-NEXT: <_start>:
|
2019-08-20 16:34:56 +08:00
|
|
|
// S + A - P = 0x2303f0 + 0 - 0x21031c = 131284
|
|
|
|
// CODE-NEXT: 21031c: adr x1, #131284
|
|
|
|
// Page(S + A) - Page(P) = Page(0x230400) - Page(0x210320) = 131072
|
2020-12-17 01:20:55 +08:00
|
|
|
// CODE-NEXT: 210320: adrp x2, 0x230000
|
2019-08-20 16:34:56 +08:00
|
|
|
// (S + A) & 0xFFF = (0x230400 + 0) & 0xFFF = 1024
|
|
|
|
// CODE-NEXT: 210324: add x2, x2, #1024
|
2015-12-03 16:05:35 +08:00
|
|
|
|
2016-04-14 09:48:11 +08:00
|
|
|
// RODATA: Contents of section .rodata:
|
2019-08-20 16:34:56 +08:00
|
|
|
// S(z) = 0x230404
|
|
|
|
// RODATA-NEXT: 200318 04042300
|