• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
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
8
9SECTIONS {
10  .common_0 : { *file0.o(COMMON) }
11  .common_1 : { *file1.o(COMMON) }
12  .common_2 : { *file2.o(COMMON) }
13}
14
15# Make sure all 3 sections are allocated and they have sizes and alignments
16# corresponding to the commons assigned to them
17# CHECK:       Section {
18# CHECK:         Index:
19# CHECK:         Name: .common_0
20# CHECK-NEXT:    Type: SHT_NOBITS
21# CHECK-NEXT:    Flags [
22# CHECK-NEXT:      SHF_ALLOC
23# CHECK-NEXT:      SHF_WRITE
24# CHECK-NEXT:    ]
25# CHECK-NEXT:    Address: 0x4
26# CHECK-NEXT:    Offset: 0x
27# CHECK-NEXT:    Size: 4
28# CHECK-NEXT:    Link: 0
29# CHECK-NEXT:    Info: 0
30# CHECK-NEXT:    AddressAlignment: 4
31# CHECK-NEXT:    EntrySize: 0
32# CHECK-NEXT:  }
33# CHECK:       Section {
34# CHECK:         Index:
35# CHECK:         Name: .common_1
36# CHECK-NEXT:    Type: SHT_NOBITS
37# CHECK-NEXT:    Flags [
38# CHECK-NEXT:      SHF_ALLOC
39# CHECK-NEXT:      SHF_WRITE
40# CHECK-NEXT:    ]
41# CHECK-NEXT:    Address: 0x8
42# CHECK-NEXT:    Offset: 0x
43# CHECK-NEXT:    Size: 8
44# CHECK-NEXT:    Link: 0
45# CHECK-NEXT:    Info: 0
46# CHECK-NEXT:    AddressAlignment: 8
47# CHECK-NEXT:    EntrySize: 0
48# CHECK-NEXT:  }
49# CHECK:       Section {
50# CHECK:         Index:
51# CHECK:         Name: .common_2
52# CHECK-NEXT:    Type: SHT_NOBITS
53# CHECK-NEXT:    Flags [
54# CHECK-NEXT:      SHF_ALLOC
55# CHECK-NEXT:      SHF_WRITE
56# CHECK-NEXT:    ]
57# CHECK-NEXT:    Address: 0x10
58# CHECK-NEXT:    Offset: 0x
59# CHECK-NEXT:    Size: 48
60# CHECK-NEXT:    Link: 0
61# CHECK-NEXT:    Info: 0
62# CHECK-NEXT:    AddressAlignment: 16
63# CHECK-NEXT:    EntrySize: 0
64# CHECK-NEXT:  }
65
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
69# CHECK:       Symbol {
70# CHECK:         Name: common_multiple
71# CHECK-NEXT:    Value: 0x10
72# CHECK-NEXT:    Size: 32
73# CHECK-NEXT:    Binding: Global
74# CHECK-NEXT:    Type: Object
75# CHECK-NEXT:    Other: 0
76# CHECK-NEXT:    Section: .common_2
77# CHECK-NEXT:  }
78# CHECK:       Symbol {
79# CHECK:         Name: common_uniq_0
80# CHECK-NEXT:    Value: 0x4
81# CHECK-NEXT:    Size: 4
82# CHECK-NEXT:    Binding: Global
83# CHECK-NEXT:    Type: Object
84# CHECK-NEXT:    Other: 0
85# CHECK-NEXT:    Section: .common_0
86# CHECK-NEXT:  }
87# CHECK:       Symbol {
88# CHECK:         Name: common_uniq_1
89# CHECK-NEXT:    Value: 0x8
90# CHECK-NEXT:    Size: 8
91# CHECK-NEXT:    Binding: Global
92# CHECK-NEXT:    Type: Object
93# CHECK-NEXT:    Other: 0
94# CHECK-NEXT:    Section: .common_1
95# CHECK-NEXT:  }
96# CHECK:       Symbol {
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
104# CHECK-NEXT:  }
105