|
| 1 | +// REQUIRES: aarch64 |
| 2 | +// RUN: rm -rf %t && split-file %s %t && cd %t |
| 3 | + |
| 4 | +//--- a.s |
| 5 | +.section .tbss,"awT",@nobits |
| 6 | +.global a |
| 7 | +a: |
| 8 | +.xword 0 |
| 9 | + |
| 10 | +//--- ok.s |
| 11 | +// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth ok.s -o ok.o |
| 12 | +// RUN: ld.lld -shared ok.o -o ok.so |
| 13 | +// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn ok.so | \ |
| 14 | +// RUN: FileCheck -DP=20 -DA=896 -DB=912 -DC=928 %s |
| 15 | +// RUN: llvm-readobj -r -x .got ok.so | FileCheck --check-prefix=REL \ |
| 16 | +// RUN: -DP1=20 -DA1=380 -DB1=390 -DC1=3A0 -DP2=020 -DA2=380 -DB2=390 -DC2=3a0 %s |
| 17 | + |
| 18 | +// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth a.s -o a.so.o |
| 19 | +// RUN: ld.lld -shared a.so.o -soname=so -o a.so |
| 20 | +// RUN: ld.lld ok.o a.so -o ok |
| 21 | +// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn ok | \ |
| 22 | +// RUN: FileCheck -DP=220 -DA=936 -DB=952 -DC=968 %s |
| 23 | +// RUN: llvm-readobj -r -x .got ok | FileCheck --check-prefix=REL \ |
| 24 | +// RUN: -DP1=220 -DA1=3A8 -DB1=3B8 -DC1=3C8 -DP2=220 -DA2=3a8 -DB2=3b8 -DC2=3c8 %s |
| 25 | + |
| 26 | + .text |
| 27 | + adrp x0, :tlsdesc_auth:a |
| 28 | + ldr x16, [x0, :tlsdesc_auth_lo12:a] |
| 29 | + add x0, x0, :tlsdesc_auth_lo12:a |
| 30 | + blraa x16, x0 |
| 31 | + |
| 32 | +// CHECK: adrp x0, 0x[[P]]000 |
| 33 | +// CHECK-NEXT: ldr x16, [x0, #[[A]]] |
| 34 | +// CHECK-NEXT: add x0, x0, #[[A]] |
| 35 | +// CHECK-NEXT: blraa x16, x0 |
| 36 | + |
| 37 | +/// Create relocation against local TLS symbols where linker should |
| 38 | +/// create target specific dynamic TLSDESC relocation where addend is |
| 39 | +/// the symbol VMA in tls block. |
| 40 | + |
| 41 | + adrp x0, :tlsdesc_auth:local1 |
| 42 | + ldr x16, [x0, :tlsdesc_auth_lo12:local1] |
| 43 | + add x0, x0, :tlsdesc_auth_lo12:local1 |
| 44 | + blraa x16, x0 |
| 45 | + |
| 46 | +// CHECK: adrp x0, 0x[[P]]000 |
| 47 | +// CHECK-NEXT: ldr x16, [x0, #[[B]]] |
| 48 | +// CHECK-NEXT: add x0, x0, #[[B]] |
| 49 | +// CHECK-NEXT: blraa x16, x0 |
| 50 | + |
| 51 | + adrp x0, :tlsdesc_auth:local2 |
| 52 | + ldr x16, [x0, :tlsdesc_auth_lo12:local2] |
| 53 | + add x0, x0, :tlsdesc_auth_lo12:local2 |
| 54 | + blraa x16, x0 |
| 55 | + |
| 56 | +// CHECK: adrp x0, 0x[[P]]000 |
| 57 | +// CHECK-NEXT: ldr x16, [x0, #[[C]]] |
| 58 | +// CHECK-NEXT: add x0, x0, #[[C]] |
| 59 | +// CHECK-NEXT: blraa x16, x0 |
| 60 | + |
| 61 | + .section .tbss,"awT",@nobits |
| 62 | + .type local1,@object |
| 63 | + .p2align 2 |
| 64 | +local1: |
| 65 | + .word 0 |
| 66 | + .size local1, 4 |
| 67 | + |
| 68 | + .type local2,@object |
| 69 | + .p2align 3 |
| 70 | +local2: |
| 71 | + .xword 0 |
| 72 | + .size local2, 8 |
| 73 | + |
| 74 | + |
| 75 | +// R_AARCH64_AUTH_TLSDESC - 0x0 -> start of tls block |
| 76 | +// R_AARCH64_AUTH_TLSDESC - 0x8 -> align (sizeof (local1), 8) |
| 77 | + |
| 78 | +// REL: Relocations [ |
| 79 | +// REL-NEXT: Section (5) .rela.dyn { |
| 80 | +// REL-NEXT: 0x[[P1]][[B1]] R_AARCH64_AUTH_TLSDESC - 0x0 |
| 81 | +// REL-NEXT: 0x[[P1]][[C1]] R_AARCH64_AUTH_TLSDESC - 0x8 |
| 82 | +// REL-NEXT: 0x[[P1]][[A1]] R_AARCH64_AUTH_TLSDESC a 0x0 |
| 83 | +// REL-NEXT: } |
| 84 | +// REL-NEXT: ] |
| 85 | + |
| 86 | +// REL: Hex dump of section '.got': |
| 87 | +// REL-NEXT: 0x00[[P2]][[A2]] 00000000 00000080 00000000 000000a0 |
| 88 | +// REL-NEXT: 0x00[[P2]][[B2]] 00000000 00000080 00000000 000000a0 |
| 89 | +// REL-NEXT: 0x00[[P2]][[C2]] 00000000 00000080 00000000 000000a0 |
| 90 | +/// ^^ |
| 91 | +/// 0b10000000 bit 63 address diversity = true, bits 61..60 key = IA |
| 92 | +/// ^^ |
| 93 | +/// 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA |
| 94 | + |
| 95 | +//--- err1.s |
| 96 | +// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth err1.s -o err1.o |
| 97 | +// RUN: not ld.lld -shared err1.o 2>&1 | FileCheck --check-prefix=ERR1 --implicit-check-not=error: %s |
| 98 | +// ERR1: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported |
| 99 | + .text |
| 100 | + adrp x0, :tlsdesc_auth:a |
| 101 | + ldr x16, [x0, :tlsdesc_auth_lo12:a] |
| 102 | + add x0, x0, :tlsdesc_auth_lo12:a |
| 103 | + blraa x16, x0 |
| 104 | + |
| 105 | + adrp x0, :tlsdesc:a |
| 106 | + ldr x1, [x0, :tlsdesc_lo12:a] |
| 107 | + add x0, x0, :tlsdesc_lo12:a |
| 108 | + blr x1 |
| 109 | + |
| 110 | +//--- err2.s |
| 111 | +// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth err2.s -o err2.o |
| 112 | +// RUN: not ld.lld -shared err2.o 2>&1 | FileCheck --check-prefix=ERR2 --implicit-check-not=error: %s |
| 113 | +// ERR2: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported |
| 114 | + .text |
| 115 | + adrp x0, :tlsdesc:a |
| 116 | + ldr x1, [x0, :tlsdesc_lo12:a] |
| 117 | + add x0, x0, :tlsdesc_lo12:a |
| 118 | + blr x1 |
| 119 | + |
| 120 | + adrp x0, :tlsdesc_auth:a |
| 121 | + ldr x16, [x0, :tlsdesc_auth_lo12:a] |
| 122 | + add x0, x0, :tlsdesc_auth_lo12:a |
| 123 | + blraa x16, x0 |
| 124 | + |
| 125 | +//--- err3.s |
| 126 | +// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux -mattr=+pauth err3.s -o err3.o |
| 127 | +// RUN: not ld.lld -shared err3.o 2>&1 | FileCheck --check-prefix=ERR3 --implicit-check-not=error: %s |
| 128 | +// ERR3: error: both AUTH and non-AUTH TLSDESC entries for 'a' requested, but only one type of TLSDESC entry per symbol is supported |
| 129 | + .text |
| 130 | + adrp x0, :tlsdesc_auth:a |
| 131 | + ldr x16, [x0, :tlsdesc_auth_lo12:a] |
| 132 | + add x0, x0, :tlsdesc_auth_lo12:a |
| 133 | + .tlsdesccall a |
| 134 | + blraa x16, x0 |
0 commit comments