xref: /llvm-project/lld/test/ELF/relocation-copy-i686.s (revision 98a4289810ba49cea6f9a9be6d902e72f0c0d0e7)
1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
3// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %p/Inputs/relocation-copy.s -o %t2.o
4// RUN: ld.lld -shared %t2.o -soname=t.so -o %t.so
5// RUN: ld.lld -e main %t.o %t.so -o %t3
6// RUN: llvm-readobj -S -r --expand-relocs %t3 | FileCheck %s
7// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t3 | FileCheck --check-prefix=CODE %s
8
9.text
10.globl main
11.align 16, 0x90
12.type main,@function
13main:
14movl $5, x
15movl $7, y
16movl $9, z
17
18// CHECK:      Name: .bss
19// CHECK-NEXT:  Type: SHT_NOBITS
20// CHECK-NEXT:  Flags [
21// CHECK-NEXT:   SHF_ALLOC
22// CHECK-NEXT:   SHF_WRITE
23// CHECK-NEXT:  ]
24// CHECK-NEXT:  Address:  0x403270
25// CHECK-NEXT:  Offset:
26// CHECK-NEXT:  Size: 24
27// CHECK-NEXT:  Link: 0
28// CHECK-NEXT:  Info: 0
29// CHECK-NEXT:  AddressAlignment: 16
30// CHECK-NEXT:  EntrySize: 0
31
32// CHECK:      Relocations [
33// CHECK-NEXT:   Section ({{.*}}) .rel.dyn {
34// CHECK-NEXT:     Relocation {
35// CHECK-NEXT:       Offset:
36// CHECK-NEXT:       Type: R_386_COPY
37// CHECK-NEXT:       Symbol: x
38// CHECK-NEXT:     }
39// CHECK-NEXT:     Relocation {
40// CHECK-NEXT:       Offset:
41// CHECK-NEXT:       Type: R_386_COPY
42// CHECK-NEXT:       Symbol: y
43// CHECK-NEXT:     }
44// CHECK-NEXT:     Relocation {
45// CHECK-NEXT:       Offset:
46// CHECK-NEXT:       Type: R_386_COPY
47// CHECK-NEXT:       Symbol: z
48// CHECK-NEXT:     }
49// CHECK-NEXT:   }
50// CHECK-NEXT: ]
51
52// 16 is alignment here
53// CODE: Disassembly of section .text:
54// CODE-EMPTY:
55// CODE-NEXT: <main>:
56/// .bss + 0 = 0x403270
57// CODE-NEXT: 4011f0:       movl $0x5, 0x403270
58/// .bss + 16 = 0x403270 + 16 = 0x403280
59// CODE-NEXT: 4011fa:       movl $0x7, 0x403280
60/// .bss + 20 = 0x403270 + 20 = 0x403284
61// CODE-NEXT: 401204:       movl $0x9, 0x403284
62