COFF: Infer entry point as early as possible, but not too early.
On Windows, we have four different main functions, {w,}{main,WinMain}. The linker has to choose a corresponding entry point function among {w,}{main,WinMain}CRTStartup. These entry point functions are defined in the standard library. The linker resolves one of them by looking at which main function is defined and adding a corresponding undefined symbol to the symbol table. Object files containing entry point functions conflicts each other. For example, we cannot resolve both mainCRTStartup and WinMainCRTStartup because other symbols defined in the files conflict. Previously, we inferred CRT function name at the very end of name resolution. I found that that is sometimes too late. If the linker already linked one of these four archive member objects, it's too late to change the decision. The right thing to do here is to infer entry point name after adding all symbols from command line files and before adding any other files (which are specified by directive sections). This patch does that. llvm-svn: 241236
Loading
Please register or sign in to comment