1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/relocation-copy.s -o %t2.o
4// RUN: ld.lld -shared %t2.o -o %t.so
5// RUN: ld.lld %t.o %t.so -o %t3
6// RUN: llvm-readobj -s -r --expand-relocs %t3 | FileCheck %s
7// RUN: llvm-objdump -d %t3 | FileCheck -check-prefix=CODE %s
8
9.text
10.global _start
11_start:
12movl $5, x
13movl $7, y
14movl $9, z
15movl $x, %edx
16movl $y, %edx
17movl $z, %edx
18
19// CHECK:      Name: .bss
20// CHECK-NEXT:  Type: SHT_NOBITS (0x8)
21// CHECK-NEXT:  Flags [ (0x3)
22// CHECK-NEXT:   SHF_ALLOC (0x2)
23// CHECK-NEXT:   SHF_WRITE (0x1)
24// CHECK-NEXT:  ]
25// CHECK-NEXT:  Address: 0x203000
26// CHECK-NEXT:  Offset:
27// CHECK-NEXT:  Size: 24
28// CHECK-NEXT:  Link: 0
29// CHECK-NEXT:  Info: 0
30// CHECK-NEXT:  AddressAlignment: 16
31// CHECK-NEXT:  EntrySize: 0
32
33// CHECK:      Relocations [
34// CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
35// CHECK-NEXT:     Relocation {
36// CHECK-NEXT:       Offset:
37// CHECK-NEXT:       Type: R_X86_64_COPY
38// CHECK-NEXT:       Symbol: x
39// CHECK-NEXT:       Addend: 0x0
40// CHECK-NEXT:     }
41// CHECK-NEXT:     Relocation {
42// CHECK-NEXT:       Offset:
43// CHECK-NEXT:       Type: R_X86_64_COPY
44// CHECK-NEXT:       Symbol: y
45// CHECK-NEXT:       Addend: 0x0
46// CHECK-NEXT:     }
47// CHECK-NEXT:     Relocation {
48// CHECK-NEXT:       Offset:
49// CHECK-NEXT:       Type: R_X86_64_COPY
50// CHECK-NEXT:       Symbol: z
51// CHECK-NEXT:       Addend: 0x0
52// CHECK-NEXT:     }
53// CHECK-NEXT:   }
54// CHECK-NEXT: ]
55
56// 2109440 = 0x203000
57// 16 is alignment here
58// 2109456 = 0x203000 + 16
59// 2109460 = 0x203000 + 16 + 4
60// CODE: Disassembly of section .text:
61// CODE-NEXT: _start:
62// CODE-NEXT: 201000: {{.*}} movl $5, 2109440
63// CODE-NEXT: 20100b: {{.*}} movl $7, 2109456
64// CODE-NEXT: 201016: {{.*}} movl $9, 2109460
65// CODE-NEXT: 201021: {{.*}} movl $2109440, %edx
66// CODE-NEXT: 201026: {{.*}} movl $2109456, %edx
67// CODE-NEXT: 20102b: {{.*}} movl $2109460, %edx
68