2 # RUN: rm -rf %t; split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/same-size.s -o %t/same-size.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/smaller-size.s -o %t/smaller-size.o
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/zero-align.s -o %t/zero-align.o
8 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/zero-align-round-up.s -o %t/zero-align-round-up.o
10 ## Check that we pick the definition with the larger size, regardless of
12 # RUN: %lld %t/test.o %t/smaller-size.o -order_file %t/order -o %t/test
13 # RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#ALIGN=8
14 # RUN: %lld %t/smaller-size.o %t/test.o -order_file %t/order -o %t/test
15 # RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#ALIGN=8
17 ## When the sizes are equal, we pick the symbol whose file occurs later in the
18 ## command-line argument list.
19 # RUN: %lld %t/test.o %t/same-size.o -order_file %t/order -o %t/test
20 # RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#ALIGN=16
21 # RUN: %lld %t/same-size.o %t/test.o -order_file %t/order -o %t/test
22 # RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#ALIGN=8
24 # RUN: %lld %t/test.o %t/zero-align.o -order_file %t/order -o %t/test
25 # RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#ALIGN=16
26 # RUN: %lld %t/zero-align.o %t/test.o -order_file %t/order -o %t/test
27 # RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#ALIGN=16
29 # RUN: %lld %t/test.o %t/zero-align-round-up.o -order_file %t/order -o %t/test
30 # RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#ALIGN=16
31 # RUN: %lld %t/zero-align-round-up.o %t/test.o -order_file %t/order -o %t/test
32 # RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s -D#ALIGN=16
34 # CHECK-LABEL: Sections:
35 # CHECK: __common {{[0-9a-f]+}} [[#%.16x, COMMON_START:]] BSS
37 # CHECK-LABEL: SYMBOL TABLE:
38 # CHECK-DAG: [[#%.16x, COMMON_START]] g O __DATA,__common _check_size
39 # CHECK-DAG: [[#%.16x, COMMON_START + 2]] g O __DATA,__common _end_marker
40 # CHECK-DAG: [[#%.16x, COMMON_START + ALIGN]] g O __DATA,__common _check_alignment
43 ## Order is important as we determine the size of a given symbol via the
44 ## address of the next symbol.
50 .comm _check_size, 1, 1
51 .comm _check_alignment, 1, 4
54 .comm _check_size, 2, 1
55 .comm _check_alignment, 2, 4
58 .comm _check_size, 2, 1
59 ## If alignment is set to zero, use the size to determine the alignment.
60 .comm _check_alignment, 16, 0
62 #--- zero-align-round-up.s
63 .comm _check_size, 2, 1
64 ## If alignment is set to zero, use the size to determine the alignment. If the
65 ## size is not a power of two, round it up. (In this case, 14 rounds to 16.)
66 .comm _check_alignment, 14, 0
69 .comm _check_size, 2, 1
71 .comm _check_alignment, 2, 3