Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / COFF / entry-weak-external.s
blobaa1bcf2f899d8869142de017096326cd2a71bc0c
1 # REQUIRES: x86
2 # RUN: rm -rf %t && split-file %s %t
4 ## Ensure that we resolve the entry point to the unmangled weak alias instead of
5 ## the mangled library definition (which would fail with an undefined symbol).
7 # RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t/entry-weak.obj %t/entry-weak.s
8 # RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t/entry-mangled.obj %t/entry-mangled.s
9 # RUN: llvm-lib -out:%t/entry-mangled.lib %t/entry-mangled.obj
10 # RUN: lld-link -subsystem:console -entry:entry -out:%t/entry-weak-external.exe %t/entry-weak.obj %t/entry-mangled.lib
11 # RUN: llvm-readobj --file-headers %t/entry-weak-external.exe | FileCheck %s
13 ## Ensure that we don't resolve the entry point to a weak alias pointing to an
14 ## undefined symbol (which would have caused the entry point to be 0 instead of
15 ## an actual address). I can't think of a way of triggering this edge case
16 ## without using /force:unresolved, which means it likely doesn't matter in
17 ## practice, but we still match link.exe's behavior for it.
19 # RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t/entry-weak-undefined.obj %t/entry-weak-undefined.s
20 # RUN: lld-link -subsystem:console -entry:entry -force:unresolved -out:%t/entry-undefined-weak-external.exe \
21 # RUN: %t/entry-weak-undefined.obj %t/entry-mangled.lib
22 # RUN: llvm-readobj --file-headers %t/entry-undefined-weak-external.exe | FileCheck %s
24 # CHECK: AddressOfEntryPoint: 0x1000
26 #--- entry-weak.s
27 .globl default_entry
28 default_entry:
29 ret
31 .weak entry
32 entry = default_entry
34 #--- entry-mangled.s
35 .globl "?entry@@YAHXZ"
36 "?entry@@YAHXZ":
37 jmp does_not_exist
39 #--- entry-weak-undefined.s
40 .weak entry
41 entry = does_not_exist