diff options
| author | YX Hao <lifenjoiner@163.com> | 2017-02-15 21:58:35 +0800 |
|---|---|---|
| committer | YX Hao <lifenjoiner@163.com> | 2017-02-17 21:09:26 +0800 |
| commit | 86e3cd0c5ac9d6e8e80306f9f5fdcce4a4c38dc5 (patch) | |
| tree | eba8a96a4d75747281e3f937167ec8f7ebff5540 /tccpe.c | |
| parent | f33801e25e7ea54cf46e2892df1550148604d559 (diff) | |
| download | tinycc-86e3cd0c5ac9d6e8e80306f9f5fdcce4a4c38dc5.tar.gz tinycc-86e3cd0c5ac9d6e8e80306f9f5fdcce4a4c38dc5.tar.bz2 | |
Add support for Unicode entries 'wmain' and 'wWinMain' on Windows
'-run' suported. argvs are converted.
But don't use compliled Unicode CLI exe-file to get inputs interactively in other codepage!
Please add other compliling supports than 'build-tcc.bat' (Who is good at them).
Diffstat (limited to 'tccpe.c')
| -rw-r--r-- | tccpe.c | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -1759,34 +1759,46 @@ static void pe_add_runtime(TCCState *s1, struct pe_info *pe) { const char *start_symbol; int pe_type = 0; + int unicode_entry = 0; if (find_elf_sym(symtab_section, PE_STDSYM("WinMain","@16"))) pe_type = PE_GUI; else + if (find_elf_sym(symtab_section, PE_STDSYM("wWinMain","@16"))) { + pe_type = PE_GUI; + unicode_entry = PE_GUI; + } + else if (TCC_OUTPUT_DLL == s1->output_type) { pe_type = PE_DLL; /* need this for 'tccelf.c:relocate_section()' */ s1->output_type = TCC_OUTPUT_EXE; } - else + else { pe_type = PE_EXE; + if (find_elf_sym(symtab_section, "wmain")) + unicode_entry = PE_EXE; + } start_symbol = TCC_OUTPUT_MEMORY == s1->output_type - ? PE_GUI == pe_type ? "__runwinmain" : "_main" + ? PE_GUI == pe_type ? (unicode_entry ? "__runwwinmain" : "__runwinmain") + : (unicode_entry ? "__runwmain" : "__runmain") : PE_DLL == pe_type ? PE_STDSYM("__dllstart","@12") - : PE_GUI == pe_type ? "__winstart" : "__start" + : PE_GUI == pe_type ? (unicode_entry ? "__wwinstart": "__winstart") + : (unicode_entry ? "__wstart" : "__start") ; if (!s1->leading_underscore || strchr(start_symbol, '@')) ++start_symbol; /* grab the startup code from libtcc1 */ - if (TCC_OUTPUT_MEMORY != s1->output_type || PE_GUI == pe_type) - set_elf_sym(symtab_section, - 0, 0, - ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0, - SHN_UNDEF, start_symbol); + /* only (PE_Dll == pe_type) doesn't need it, + (TCC_OUTPUT_MEMORY == s1->output_type && PE_Dll == pe_type) is illegal */ + set_elf_sym(symtab_section, + 0, 0, + ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0, + SHN_UNDEF, start_symbol); tcc_add_pragma_libs(s1); |
