• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2# RUN: split-file %s %t
3
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
9
10## Check that we pick the definition with the larger size, regardless of
11## its alignment.
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 --check-prefix=SMALLER-ALIGNMENT
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 --check-prefix=SMALLER-ALIGNMENT
16
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 --check-prefix=LARGER-ALIGNMENT
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 --check-prefix=SMALLER-ALIGNMENT
23
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 --check-prefix=LARGER-ALIGNMENT
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 --check-prefix=LARGER-ALIGNMENT
28
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 --check-prefix=LARGER-ALIGNMENT
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 --check-prefix=LARGER-ALIGNMENT
33
34# SMALLER-ALIGNMENT-LABEL: Sections:
35# SMALLER-ALIGNMENT:       __common      {{[0-9a-f]+}} [[#%x, COMMON_START:]]  BSS
36
37# SMALLER-ALIGNMENT-LABEL: SYMBOL TABLE:
38# SMALLER-ALIGNMENT-DAG:   [[#COMMON_START]]      g     O __DATA,__common _check_size
39# SMALLER-ALIGNMENT-DAG:   [[#COMMON_START + 2]]  g     O __DATA,__common _end_marker
40# SMALLER-ALIGNMENT-DAG:   [[#COMMON_START + 8]]  g     O __DATA,__common _check_alignment
41
42# LARGER-ALIGNMENT-LABEL: Sections:
43# LARGER-ALIGNMENT:       __common      {{[0-9a-f]+}} [[#%x, COMMON_START:]]  BSS
44
45# LARGER-ALIGNMENT-LABEL: SYMBOL TABLE:
46# LARGER-ALIGNMENT-DAG:   [[#COMMON_START]]      g     O __DATA,__common _check_size
47# LARGER-ALIGNMENT-DAG:   [[#COMMON_START + 2]]  g     O __DATA,__common _end_marker
48# LARGER-ALIGNMENT-DAG:   [[#COMMON_START + 16]] g     O __DATA,__common _check_alignment
49
50#--- order
51## Order is important as we determine the size of a given symbol via the
52## address of the next symbol.
53_check_size
54_end_marker
55_check_alignment
56
57#--- smaller-size.s
58.comm _check_size, 1, 1
59.comm _check_alignment, 1, 4
60
61#--- same-size.s
62.comm _check_size, 2, 1
63.comm _check_alignment, 2, 4
64
65#--- zero-align.s
66.comm _check_size, 2, 1
67## If alignment is set to zero, use the size to determine the alignment.
68.comm _check_alignment, 16, 0
69
70#--- zero-align-round-up.s
71.comm _check_size, 2, 1
72## If alignment is set to zero, use the size to determine the alignment. If the
73## size is not a power of two, round it up. (In this case, 14 rounds to 16.)
74.comm _check_alignment, 14, 0
75
76#--- test.s
77.comm _check_size, 2, 1
78.comm _end_marker, 1
79.comm _check_alignment, 2, 3
80
81.globl _main
82_main:
83  ret
84