llvm-project/lld/test/COFF/subsystem-inference-weak-external.s
Shoaib Meenai 72b2ca5d06 [COFF] Respect weak externals for mangled symbol searching
We were previously ignoring weak externals during these searches (which
are used for the entry point, exports, and subsystem inference), which
differed from link.exe behavior. It also meant that we could get
different behavior when linking an object file directly vs. packaging it
into a static library, because static library symbol name directories
include weak externals.

Reviewed By: mstorsjo, yozhu

Differential Revision: https://reviews.llvm.org/D139764
2022-12-12 10:52:31 -08:00

39 lines
914 B
ArmAsm

# REQUIRES: x86
# RUN: rm -rf %t && split-file %s %t
## Ensure that weak externals are considered during subsystem inference.
# RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t/cui.obj %t/cui.s
# RUN: lld-link -out:%t/cui.exe %t/cui.obj
# RUN: llvm-readobj --file-headers %t/cui.exe | FileCheck --check-prefix=CUI %s
# RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t/gui.obj %t/gui.s
# RUN: lld-link -out:%t/gui.exe %t/gui.obj
# RUN: llvm-readobj --file-headers %t/gui.exe | FileCheck --check-prefix=GUI %s
# CUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI
# GUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI
#--- cui.s
.global default_main
default_main:
ret
.weak main
main = default_main
.global mainCRTStartup
mainCRTStartup:
ret
#--- gui.s
.global default_WinMain
default_WinMain:
ret
.weak WinMain
WinMain = default_WinMain
.global WinMainCRTStartup
WinMainCRTStartup:
ret