2 # RUN: echo '.long 0; .comm common_uniq_0,4,4; .comm common_multiple,8,8' \
3 # RUN: | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tfile0.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec1.s -o %tfile1.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec2.s -o %tfile2.o
6 # RUN: ld.lld -o %t1 --script %s %tfile0.o %tfile1.o %tfile2.o
7 # RUN: llvm-readobj -S --symbols %t1 | FileCheck %s
10 .common_0 : { *file0.o(COMMON) }
11 .common_1 : { *file1.o(COMMON) }
12 .common_2 : { *file2.o(COMMON) }
15 # Make sure all 3 sections are allocated and they have sizes and alignments
16 # corresponding to the commons assigned to them
19 # CHECK: Name: .common_0
20 # CHECK-NEXT: Type: SHT_NOBITS
22 # CHECK-NEXT: SHF_ALLOC
23 # CHECK-NEXT: SHF_WRITE
25 # CHECK-NEXT: Address: 0x4
26 # CHECK-NEXT: Offset: 0x
30 # CHECK-NEXT: AddressAlignment: 4
31 # CHECK-NEXT: EntrySize: 0
35 # CHECK: Name: .common_1
36 # CHECK-NEXT: Type: SHT_NOBITS
38 # CHECK-NEXT: SHF_ALLOC
39 # CHECK-NEXT: SHF_WRITE
41 # CHECK-NEXT: Address: 0x8
42 # CHECK-NEXT: Offset: 0x
46 # CHECK-NEXT: AddressAlignment: 8
47 # CHECK-NEXT: EntrySize: 0
51 # CHECK: Name: .common_2
52 # CHECK-NEXT: Type: SHT_NOBITS
54 # CHECK-NEXT: SHF_ALLOC
55 # CHECK-NEXT: SHF_WRITE
57 # CHECK-NEXT: Address: 0x10
58 # CHECK-NEXT: Offset: 0x
59 # CHECK-NEXT: Size: 48
62 # CHECK-NEXT: AddressAlignment: 16
63 # CHECK-NEXT: EntrySize: 0
66 # Commons with unique name in each file must be assigned to that file's section.
67 # For a common with multiple definitions, the largest one wins and it must be
68 # assigned to the section from the file which provided the winning def
70 # CHECK: Name: common_uniq_0
71 # CHECK-NEXT: Value: 0x4
73 # CHECK-NEXT: Binding: Global
74 # CHECK-NEXT: Type: Object
75 # CHECK-NEXT: Other: 0
76 # CHECK-NEXT: Section: .common_0
79 # CHECK: Name: common_multiple
80 # CHECK-NEXT: Value: 0x10
81 # CHECK-NEXT: Size: 32
82 # CHECK-NEXT: Binding: Global
83 # CHECK-NEXT: Type: Object
84 # CHECK-NEXT: Other: 0
85 # CHECK-NEXT: Section: .common_2
88 # CHECK: Name: common_uniq_1
89 # CHECK-NEXT: Value: 0x8
91 # CHECK-NEXT: Binding: Global
92 # CHECK-NEXT: Type: Object
93 # CHECK-NEXT: Other: 0
94 # CHECK-NEXT: Section: .common_1
97 # CHECK: Name: common_uniq_2
98 # CHECK-NEXT: Value: 0x30
99 # CHECK-NEXT: Size: 16
100 # CHECK-NEXT: Binding: Global
101 # CHECK-NEXT: Type: Object
102 # CHECK-NEXT: Other: 0
103 # CHECK-NEXT: Section: .common_2