[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / arm-copy.s
blobd6de3045b0c8c63f1119ead856d41bd011f664bf
1 // REQUIRES: arm
2 // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
3 // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %p/Inputs/relocation-copy-arm.s -o %t2.o
4 // RUN: ld.lld -shared %t2.o -soname fixed-length-string.so -o %t2.so
5 // RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t3
6 // RUN: llvm-readobj -S -r --expand-relocs --symbols %t3 | FileCheck %s
7 // RUN: llvm-objdump -d --triple=armv7a-none-linux-gnueabi --no-show-raw-insn %t3 | FileCheck --check-prefix=CODE %s
8 // RUN: llvm-objdump -s --triple=armv7a-none-linux-gnueabi --section=.rodata %t3 | FileCheck --check-prefix=RODATA %s
10 // Copy relocations R_ARM_COPY are required for y and z
11 .syntax unified
12 .text
13 .globl _start
14 _start:
15 movw r2,:lower16: y
16 movt r2,:upper16: y
17 ldr r3,[pc,#4]
18 ldr r3,[r3,#0]
19 .rodata
20 .word z
22 // CHECK: Name: .bss
23 // CHECK-NEXT: Type: SHT_NOBITS
24 // CHECK-NEXT: Flags [
25 // CHECK-NEXT: SHF_ALLOC
26 // CHECK-NEXT: SHF_WRITE
27 // CHECK-NEXT: ]
28 // CHECK-NEXT: Address: 0x40220
29 // CHECK-NEXT: Offset:
30 // CHECK-NEXT: Size: 8
31 // CHECK-NEXT: Link:
32 // CHECK-NEXT: Info:
33 // CHECK-NEXT: AddressAlignment: 16
35 // CHECK: Relocations [
36 // CHECK-NEXT: Section {{.*}} .rel.dyn {
37 // CHECK-NEXT: Relocation {
38 // CHECK-NEXT: Offset: 0x40220
39 // CHECK-NEXT: Type: R_ARM_COPY
40 // CHECK-NEXT: Symbol: y
41 // CHECK-NEXT: }
42 // CHECK-NEXT: Relocation {
43 // CHECK-NEXT: Offset: 0x40224
44 // CHECK-NEXT: Type: R_ARM_COPY
45 // CHECK-NEXT: Symbol: z
46 // CHECK-NEXT: }
47 // CHECK-NEXT: }
49 // CHECK: Symbols [
50 // CHECK: Name: y
51 // CHECK-NEXT: Value: 0x40220
52 // CHECK-NEXT: Size: 4
53 // CHECK-NEXT: Binding: Global
54 // CHECK-NEXT: Type: Object
55 // CHECK-NEXT: Other:
56 // CHECK-NEXT: Section: .bss
57 // CHECK: Name: z
58 // CHECK-NEXT: Value: 0x40224
59 // CHECK-NEXT: Size: 4
60 // CHECK-NEXT: Binding: Global
61 // CHECK-NEXT: Type: Object
62 // CHECK-NEXT: Other: 0
63 // CHECK-NEXT: Section: .bss
65 // CODE: Disassembly of section .text:
66 // CODE-EMPTY:
67 // CODE-NEXT: <_start>:
68 /// S + A = 0x40220 + 0 = 65536 * 1 + 544
69 // CODE-NEXT: 201b4: movw r2, #544
70 // CODE-NEXT: 201b8: movt r2, #4
71 // CODE-NEXT: 201bc: ldr r3, [pc, #4]
72 // CODE-NEXT: 201c0: ldr r3, [r3]
75 // RODATA: Contents of section .rodata:
76 /// S(z) = 0x40004
77 // RODATA-NEXT: 101b0 24020400