brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.7 KiB · a20ee38 Raw
108 lines · plain
1# REQUIRES: x862 3# Tests handling of the comdat selection type.4# (Except associative which is tested in associative-comdat.s and5# 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.obj9# 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.obj10# RUN: sed -e s/SEL/one_only/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.one_only.obj11# RUN: sed -e s/SEL/same_size/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.same_size.obj12# 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.obj13# RUN: sed -e s/SEL/same_contents/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.same_contents.obj14# 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.obj15# 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.obj16# RUN: sed -e s/SEL/largest/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.largest.obj17# 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.obj18# RUN: sed -e s/SEL/newest/ %s | llvm-mc -triple x86_64-pc-win32 -filetype=obj -o %t.newest.obj19 20        .section .text$nm, "", SEL, symbol21        .globl symbol22symbol:23        .long 124 25# First, pass each selection type twice. All should link fine except for26# one_only which should report a duplicate symbol error and newest which27# 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.obj30# 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 %s31# ONEONE: lld-link: error: duplicate symbol: symbol32# RUN: cp %t.same_size.obj %t.obj && lld-link /dll /noentry /nodefaultlib %t.same_size.obj %t.obj33# RUN: cp %t.same_contents.obj %t.obj && lld-link /dll /noentry /nodefaultlib %t.same_contents.obj %t.obj34# RUN: cp %t.largest.obj %t.obj && lld-link /dll /noentry /nodefaultlib %t.largest.obj %t.obj35# RUN: cp %t.newest.obj %t.obj && env LLD_IN_TEST=1 not lld-link /dll /noentry /nodefaultlib %t.newest.obj %t.obj 2>&1 | FileCheck --check-prefix=NEWNEW %s36# NEWNEW: lld-link: error: unknown comdat type 7 for symbol37 38# /force doesn't affect errors about unknown comdat types.39# RUN: cp %t.newest.obj %t.obj && env LLD_IN_TEST=1 not lld-link /force /dll /noentry /nodefaultlib %t.newest.obj %t.obj 2>&1 | FileCheck --check-prefix=NEWNEWFORCE %s40# NEWNEWFORCE: lld-link: error: unknown comdat type 7 for symbol41 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 symbols45# 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 %s47# SAMESIZEDUPE: lld-link: error: duplicate symbol: symbol48 49# Check that the "same_contents" selection produces an error if passed two50# 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 %s52# SAMECONTENTSDUPE1: lld-link: error: duplicate symbol: symbol53# RUN: not lld-link /dll /noentry /nodefaultlib %t.same_contents.obj %t.same_contents.2.obj 2>&1 | FileCheck --check-prefix=SAMECONTENTSDUPE2 %s54# SAMECONTENTSDUPE2: lld-link: error: duplicate symbol: symbol55 56# Check that the "largest" selection picks the larger comdat (independent of57# 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.exe59# RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=LARGEST1 %s60# 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.exe65# RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=LARGEST2 %s66# 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 to72# 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 few74# combinations.75 76# RUN: not lld-link /verbose /dll /noentry /nodefaultlib %t.discard.obj %t.one_only.obj 2>&1 | FileCheck --check-prefix=DISCARDONE %s77# DISCARDONE: lld-link: conflicting comdat type for symbol: 2 in78# DISCARDONE: lld-link: error: duplicate symbol: symbol79# RUN: lld-link /verbose /force /dll /noentry /nodefaultlib %t.discard.obj %t.one_only.obj 2>&1 | FileCheck --check-prefix=DISCARDONEFORCE %s80# DISCARDONEFORCE: lld-link: conflicting comdat type for symbol: 2 in81# DISCARDONEFORCE: lld-link: warning: duplicate symbol: symbol82 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 %s85# ONEDISCARD: lld-link: conflicting comdat type for symbol: 1 in86# ONEDISCARD: lld-link: error: duplicate symbol: symbol87 88# RUN: not lld-link /verbose /dll /noentry /nodefaultlib %t.same_contents.obj %t.same_size.obj 2>&1 | FileCheck --check-prefix=CONTENTSSIZE %s89# CONTENTSSIZE: lld-link: conflicting comdat type for symbol: 4 in90# CONTENTSSIZE: lld-link: error: duplicate symbol: symbol91 92# Check that linking one 'discard' and one 'largest' has the effect of93# 'largest'.94# RUN: lld-link /dll /noentry /nodefaultlib %t.discard.short.2.obj %t.largest.obj95# RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=DISCARDLARGEST %s96# DISCARDLARGEST: Contents of section .text:97# DISCARDLARGEST:   180001000 01000000 ....98# RUN: lld-link /dll /noentry /nodefaultlib %t.largest.obj %t.discard.short.2.obj99# RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=LARGESTDISCARD %s100# 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 %s106# LARGESTONE: lld-link: conflicting comdat type for symbol: 6 in107# LARGESTONE: lld-link: error: duplicate symbol: symbol108