[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / got.s
blob194b726935d970f2ddaa06c6bd69228ab746015a
1 // REQUIRES: x86
2 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
4 // RUN: ld.lld -shared %t2.o -soname=t2.so -o %t2.so
5 // RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t
6 // RUN: llvm-readobj -S -r %t | FileCheck %s
7 // RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s
9 // CHECK: Name: .got
10 // CHECK-NEXT: Type: SHT_PROGBITS
11 // CHECK-NEXT: Flags [
12 // CHECK-NEXT: SHF_ALLOC
13 // CHECK-NEXT: SHF_WRITE
14 // CHECK-NEXT: ]
15 // CHECK-NEXT: Address: 0x202338
16 // CHECK-NEXT: Offset:
17 // CHECK-NEXT: Size: 16
18 // CHECK-NEXT: Link: 0
19 // CHECK-NEXT: Info: 0
20 // CHECK-NEXT: AddressAlignment: 8
22 // CHECK: Relocations [
23 // CHECK-NEXT: Section ({{.*}}) .rela.dyn {
24 // CHECK-NEXT: 0x202338 R_X86_64_GLOB_DAT bar 0x0
25 // CHECK-NEXT: 0x202340 R_X86_64_GLOB_DAT zed 0x0
26 // CHECK-NEXT: }
27 // CHECK-NEXT: ]
30 // Unfortunately FileCheck can't do math, so we have to check for explicit
31 // values:
32 // 0x202338 - (0x201270 + 2) - 4 = 4290
33 // 0x202338 - (0x201276 + 2) - 4 = 4284
34 // 0x202340 - (0x20127c + 2) - 4 = 4286
36 // DISASM: <_start>:
37 // DISASM-NEXT: 201270: {{.*}} jmpq *4290(%rip)
38 // DISASM-NEXT: 201276: {{.*}} jmpq *4284(%rip)
39 // DISASM-NEXT: 20127c: {{.*}} jmpq *4286(%rip)
41 .global _start
42 _start:
43 jmp *bar@GOTPCREL(%rip)
44 jmp *bar@GOTPCREL(%rip)
45 jmp *zed@GOTPCREL(%rip)