1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
3// RUN: ld.lld %t.o -o %t
4// RUN: llvm-readobj -S -r --symbols %t | FileCheck %s
5// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s
6
7// CHECK:      Name: .got.plt
8// CHECK-NEXT: Type: SHT_PROGBITS
9// CHECK-NEXT: Flags [
10// CHECK-NEXT:   SHF_ALLOC
11// CHECK-NEXT:   SHF_WRITE
12// CHECK-NEXT: ]
13// CHECK-NEXT: Address: 0x4020F4
14// CHECK-NEXT: Offset:
15// CHECK-NEXT: Size:
16// CHECK-NEXT: Link:
17// CHECK-NEXT: Info:
18// CHECK-NEXT: AddressAlignment:
19
20// CHECK:      Symbol {
21// CHECK:       Name: bar
22// CHECK-NEXT:  Value: 0x402100
23// CHECK-NEXT:  Size: 10
24// CHECK-NEXT:  Binding: Global
25// CHECK-NEXT:  Type: Object
26// CHECK-NEXT:  Other: 0
27// CHECK-NEXT:  Section: .bss
28// CHECK-NEXT: }
29// CHECK-NEXT: Symbol {
30// CHECK-NEXT:  Name: obj
31// CHECK-NEXT:  Value: 0x40210A
32// CHECK-NEXT:  Size: 10
33// CHECK-NEXT:  Binding: Global
34// CHECK-NEXT:  Type: Object
35// CHECK-NEXT:  Other: 0
36// CHECK-NEXT:  Section: .bss
37// CHECK-NEXT: }
38
39// 0x402000 - 0 = addr(.got) = 0x402000
40// 0x40200A - 10 = addr(.got) = 0x402000
41// 0x40200A + 5 - 15 = addr(.got) = 0x402000
42// DISASM:      Disassembly of section .text:
43// DISASM-EMPTY:
44// DISASM-NEXT: <_start>:
45// DISASM-NEXT: 4010d4: c7 81 0c 00 00 00 01 00 00 00 movl $1, 12(%ecx)
46// DISASM-NEXT: 4010de: c7 81 16 00 00 00 02 00 00 00 movl $2, 22(%ecx)
47// DISASM-NEXT: 4010e8: c7 81 1b 00 00 00 03 00 00 00 movl $3, 27(%ecx)
48
49.global _start
50_start:
51  movl $1, bar@GOTOFF(%ecx)
52  movl $2, obj@GOTOFF(%ecx)
53  movl $3, obj+5@GOTOFF(%ecx)
54  .type bar, @object
55  .comm bar, 10
56  .type obj, @object
57  .comm obj, 10
58