llvm-project
75 строк · 3.1 Кб
1# REQUIRES: x86
2# RUN: rm -rf %t; 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 -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
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 -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
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 -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
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 -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
33
34# CHECK-LABEL: Sections:
35# CHECK: __common {{[0-9a-f]+}} [[#%.16x, COMMON_START:]] BSS
36
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
41
42#--- order
43## Order is important as we determine the size of a given symbol via the
44## address of the next symbol.
45_check_size
46_end_marker
47_check_alignment
48
49#--- smaller-size.s
50.comm _check_size, 1, 1
51.comm _check_alignment, 1, 4
52
53#--- same-size.s
54.comm _check_size, 2, 1
55.comm _check_alignment, 2, 4
56
57#--- zero-align.s
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
61
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
67
68#--- test.s
69.comm _check_size, 2, 1
70.comm _end_marker, 1
71.comm _check_alignment, 2, 3
72
73.globl _main
74_main:
75ret
76