150
|
1 # REQUIRES: x86
|
|
2
|
|
3 # Tests handling of the comdat selection type.
|
|
4 # (Except associative which is tested in associative-comdat.s and
|
|
5 # comdat-selection-associate-largest.s instead.)
|
|
6
|
|
7 # Create obj files with each selection type.
|
|
8 # RUN: sed -e s/SEL/discard/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.discard.obj
|
|
9 # RUN: sed -e s/SEL/discard/ -e s/.long/.short/ -e s/1/2/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.discard.short.2.obj
|
|
10 # RUN: sed -e s/SEL/one_only/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.one_only.obj
|
|
11 # RUN: sed -e s/SEL/same_size/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.same_size.obj
|
|
12 # RUN: sed -e s/SEL/same_size/ -e s/.long/.short/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.same_size.short.obj
|
|
13 # RUN: sed -e s/SEL/same_contents/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.same_contents.obj
|
|
14 # RUN: sed -e s/SEL/same_contents/ -e s/.long/.short/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.same_contents.short.obj
|
|
15 # RUN: sed -e s/SEL/same_contents/ -e s/1/2/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.same_contents.2.obj
|
|
16 # RUN: sed -e s/SEL/largest/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.largest.obj
|
|
17 # RUN: sed -e s/SEL/largest/ -e s/.long/.short/ -e s/1/2/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.largest.short.2.obj
|
|
18 # RUN: sed -e s/SEL/newest/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.newest.obj
|
|
19
|
|
20 .section .text$nm, "", SEL, symbol
|
|
21 .globl symbol
|
|
22 symbol:
|
|
23 .long 1
|
|
24
|
|
25 # First, pass each selection type twice. All should link fine except for
|
|
26 # one_only which should report a duplicate symbol error and newest which
|
|
27 # link.exe (and hence lld-link) doesn't understand.
|
|
28
|
|
29 # RUN: cp %t.discard.obj %t.obj && lld-link /dll /noentry /nodefaultlib %t.discard.obj %t.obj
|
|
30 # RUN: cp %t.one_only.obj %t.obj && not lld-link /dll /noentry /nodefaultlib %t.one_only.obj %t.obj 2>&1 | FileCheck --check-prefix=ONEONE %s
|
|
31 # ONEONE: lld-link: error: duplicate symbol: symbol
|
|
32 # RUN: cp %t.same_size.obj %t.obj && lld-link /dll /noentry /nodefaultlib %t.same_size.obj %t.obj
|
|
33 # RUN: cp %t.same_contents.obj %t.obj && lld-link /dll /noentry /nodefaultlib %t.same_contents.obj %t.obj
|
|
34 # RUN: cp %t.largest.obj %t.obj && lld-link /dll /noentry /nodefaultlib %t.largest.obj %t.obj
|
|
35 # RUN: cp %t.newest.obj %t.obj && not lld-link /dll /noentry /nodefaultlib %t.newest.obj %t.obj 2>&1 | FileCheck --check-prefix=NEWNEW %s
|
|
36 # NEWNEW: lld-link: error: unknown comdat type 7 for symbol
|
|
37
|
|
38 # /force doesn't affect errors about unknown comdat types.
|
|
39 # RUN: cp %t.newest.obj %t.obj && not lld-link /force /dll /noentry /nodefaultlib %t.newest.obj %t.obj 2>&1 | FileCheck --check-prefix=NEWNEWFORCE %s
|
|
40 # NEWNEWFORCE: lld-link: error: unknown comdat type 7 for symbol
|
|
41
|
|
42 # Check that same_size, same_contents, largest do what they're supposed to.
|
|
43
|
|
44 # Check that the "same_size" selection produces an error if passed two symbols
|
|
45 # with different size.
|
|
46 # RUN: not lld-link /dll /noentry /nodefaultlib %t.same_size.obj %t.same_size.short.obj 2>&1 | FileCheck --check-prefix=SAMESIZEDUPE %s
|
|
47 # SAMESIZEDUPE: lld-link: error: duplicate symbol: symbol
|
|
48
|
|
49 # Check that the "same_contents" selection produces an error if passed two
|
|
50 # symbols with different contents.
|
|
51 # RUN: not lld-link /dll /noentry /nodefaultlib %t.same_contents.obj %t.same_contents.2.obj 2>&1 | FileCheck --check-prefix=SAMECONTENTSDUPE1 %s
|
|
52 # SAMECONTENTSDUPE1: lld-link: error: duplicate symbol: symbol
|
|
53 # RUN: not lld-link /dll /noentry /nodefaultlib %t.same_contents.obj %t.same_contents.2.obj 2>&1 | FileCheck --check-prefix=SAMECONTENTSDUPE2 %s
|
|
54 # SAMECONTENTSDUPE2: lld-link: error: duplicate symbol: symbol
|
|
55
|
|
56 # Check that the "largest" selection picks the larger comdat (independent of
|
|
57 # the order the .obj files are passed on the commandline).
|
|
58 # RUN: lld-link /opt:noref /include:symbol /dll /noentry /nodefaultlib %t.largest.obj %t.largest.short.2.obj /out:%t.exe
|
|
59 # RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=LARGEST1 %s
|
|
60 # LARGEST1: Contents of section .text:
|
|
61 # LARGEST1: 180001000 01000000 ....
|
|
62
|
|
63 # FIXME: Make this pass when /opt:noref is passed.
|
|
64 # RUN: lld-link /include:symbol /dll /noentry /nodefaultlib %t.largest.short.2.obj %t.largest.obj /out:%t.exe
|
|
65 # RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=LARGEST2 %s
|
|
66 # LARGEST2: Contents of section .text:
|
|
67 # LARGEST2: 180001000 01000000 ....
|
|
68
|
|
69
|
|
70 # Test linking the same symbol with different comdat selection types.
|
|
71 # link.exe generally rejects this, except for "largest" which is allowed to
|
|
72 # combine with everything (https://bugs.llvm.org/show_bug.cgi?id=40094#c7).
|
|
73 # lld-link rejects all comdat selection type mismatches. Spot-test just a few
|
|
74 # combinations.
|
|
75
|
|
76 # RUN: not lld-link /verbose /dll /noentry /nodefaultlib %t.discard.obj %t.one_only.obj 2>&1 | FileCheck --check-prefix=DISCARDONE %s
|
|
77 # DISCARDONE: lld-link: conflicting comdat type for symbol: 2 in
|
|
78 # DISCARDONE: lld-link: error: duplicate symbol: symbol
|
|
79 # RUN: lld-link /verbose /force /dll /noentry /nodefaultlib %t.discard.obj %t.one_only.obj 2>&1 | FileCheck --check-prefix=DISCARDONEFORCE %s
|
|
80 # DISCARDONEFORCE: lld-link: conflicting comdat type for symbol: 2 in
|
|
81 # DISCARDONEFORCE: lld-link: warning: duplicate symbol: symbol
|
|
82
|
|
83 # Make sure the error isn't depending on the order of .obj files.
|
|
84 # RUN: not lld-link /verbose /dll /noentry /nodefaultlib %t.one_only.obj %t.discard.obj 2>&1 | FileCheck --check-prefix=ONEDISCARD %s
|
|
85 # ONEDISCARD: lld-link: conflicting comdat type for symbol: 1 in
|
|
86 # ONEDISCARD: lld-link: error: duplicate symbol: symbol
|
|
87
|
|
88 # RUN: not lld-link /verbose /dll /noentry /nodefaultlib %t.same_contents.obj %t.same_size.obj 2>&1 | FileCheck --check-prefix=CONTENTSSIZE %s
|
|
89 # CONTENTSSIZE: lld-link: conflicting comdat type for symbol: 4 in
|
|
90 # CONTENTSSIZE: lld-link: error: duplicate symbol: symbol
|
|
91
|
|
92 # Check that linking one 'discard' and one 'largest' has the effect of
|
|
93 # 'largest'.
|
|
94 # RUN: lld-link /dll /noentry /nodefaultlib %t.discard.short.2.obj %t.largest.obj
|
|
95 # RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=DISCARDLARGEST %s
|
|
96 # DISCARDLARGEST: Contents of section .text:
|
|
97 # DISCARDLARGEST: 180001000 01000000 ....
|
|
98 # RUN: lld-link /dll /noentry /nodefaultlib %t.largest.obj %t.discard.short.2.obj
|
|
99 # RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=LARGESTDISCARD %s
|
|
100 # LARGESTDISCARD: Contents of section .text:
|
|
101 # LARGESTDISCARD: 180001000 01000000 ....
|
|
102
|
|
103
|
|
104 # These cases are accepted by link.exe but not by lld-link.
|
|
105 # RUN: not lld-link /verbose /dll /noentry /nodefaultlib %t.largest.obj %t.one_only.obj 2>&1 | FileCheck --check-prefix=LARGESTONE %s
|
|
106 # LARGESTONE: lld-link: conflicting comdat type for symbol: 6 in
|
|
107 # LARGESTONE: lld-link: error: duplicate symbol: symbol
|