[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / aarch64-tlsdesc-zrel.s
blob1b35e0d29a26f80b55c1fabf5fbbdb21ed7d33e1
1 /// Check that we write addends for AArch64 TLSDESC relocations with -z rel
2 /// See https://bugs.llvm.org/show_bug.cgi?id=47009
3 // REQUIRES: aarch64
4 // RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
5 // RUN: ld.lld -shared %t.o -o %t-rela.so
6 // RUN: llvm-readobj -W -r -x .got %t-rela.so | FileCheck %s --check-prefixes=RELA,RELA-NO-ADDENDS
7 // RUN: ld.lld -shared %t.o -o %t-rela-addends.so --apply-dynamic-relocs
8 // RUN: llvm-readobj -W -r -x .got %t-rela-addends.so | FileCheck %s --check-prefixes=RELA,RELA-WITH-ADDENDS
10 // RELA: Relocations [
11 // RELA-NEXT: Section (5) .rela.dyn {
12 // RELA-NEXT: 0x[[#%x,ADDR:]] R_AARCH64_TLSDESC - 0x0
13 // RELA-NEXT: 0x[[#ADDR+16]] R_AARCH64_TLSDESC - 0x4
14 // RELA-NEXT: }
15 // RELA-NEXT: ]
16 // RELA-NEXT: Hex dump of section '.got':
17 // RELA-NEXT: 0x000[[#ADDR]] 00000000 00000000 00000000 00000000
18 // RELA-NO-ADDENDS-NEXT: 0x000[[#ADDR+16]] 00000000 00000000 00000000 00000000
19 // RELA-WITH-ADDENDS-NEXT: 0x000[[#ADDR+16]] 00000000 00000000 04000000 00000000
20 /// Addend 0x4 for R_AARCH64_TLSDESC -----^
21 // RELA-EMPTY:
23 // RUN: ld.lld -shared %t.o -o %t-rel.so -z rel
24 // RUN: llvm-readobj -W -r -x .got %t-rel.so | FileCheck %s --check-prefix=REL
25 // REL: Relocations [
26 // REL-NEXT: Section (5) .rel.dyn {
27 // REL-NEXT: 0x[[#%x,ADDR:]] R_AARCH64_TLSDESC -{{$}}
28 // REL-NEXT: 0x[[#ADDR+16]] R_AARCH64_TLSDESC -{{$}}
29 // REL-NEXT: }
30 // REL-NEXT: ]
31 // REL-NEXT: Hex dump of section '.got':
32 // REL-NEXT: 0x000[[#ADDR]] 00000000 00000000 00000000 00000000
33 // REL-NEXT: 0x000[[#ADDR+16]] 00000000 00000000 04000000 00000000
34 /// Addend 0x4 for R_AARCH64_TLSDESC -----^
35 // REL-EMPTY:
37 .text
38 foo:
39 adrp x0, :tlsdesc:x
40 ldr x1, [x0, :tlsdesc_lo12:x]
41 add x0, x0, :tlsdesc_lo12:x
42 .tlsdesccall x
43 blr x1
44 adrp x0, :tlsdesc:y
45 ldr x1, [x0, :tlsdesc_lo12:y]
46 add x0, x0, :tlsdesc_lo12:y
47 .tlsdesccall y
48 blr x1
49 ret
51 .section .tbss,"awT",@nobits
52 .p2align 2
53 .hidden x
55 .word 0
57 .p2align 2
58 .hidden y
60 .word 0