From 13b997668e32a4b451783fd80525cf221149c5b3 Mon Sep 17 00:00:00 2001 From: grischka Date: Tue, 10 Sep 2013 15:36:56 +0200 Subject: [PATCH] win32: fix libtcc support For "tcc -run file.c", I was trying to initialize the FP control in a function in libtcc1.a (_runmain) before calling main. Unfortunately that turned out to cause problems with for example libtcc_test since such usage doesn't necessarily define a 'main' function. So for tcc -run we're back to relying on the FP control word that is set in the startup code of tcc.exe rsp. libtcc.dll. This fixes part of commit 73faaea227a53e365dd75f1dba7a5071c7b5e541 --- tccpe.c | 7 ++++--- win32/lib/crt1.c | 6 ------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/tccpe.c b/tccpe.c index 05fed09d..19b20abf 100644 --- a/tccpe.c +++ b/tccpe.c @@ -1741,7 +1741,7 @@ static void pe_add_runtime(TCCState *s1, struct pe_info *pe) start_symbol = TCC_OUTPUT_MEMORY == s1->output_type - ? PE_GUI == pe_type ? "__runwinmain" : "__runmain" + ? PE_GUI == pe_type ? "__runwinmain" : "_main" : PE_DLL == pe_type ? PE_STDSYM("__dllstart","@12") : PE_GUI == pe_type ? "__winstart" : "__start" ; @@ -1750,7 +1750,7 @@ static void pe_add_runtime(TCCState *s1, struct pe_info *pe) ++start_symbol; /* grab the startup code from libtcc1 */ - if (start_symbol) + if (TCC_OUTPUT_MEMORY != s1->output_type || PE_GUI == pe_type) add_elf_sym(symtab_section, 0, 0, ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0, @@ -1775,10 +1775,11 @@ static void pe_add_runtime(TCCState *s1, struct pe_info *pe) if (TCC_OUTPUT_MEMORY == s1->output_type) { pe_type = PE_RUN; s1->runtime_main = start_symbol; + } else { + pe->start_addr = (DWORD)tcc_get_symbol_err(s1, start_symbol); } pe->type = pe_type; - pe->start_addr = (DWORD)tcc_get_symbol_err(s1, start_symbol); } ST_FUNC int pe_output_file(TCCState * s1, const char *filename) diff --git a/win32/lib/crt1.c b/win32/lib/crt1.c index cde39102..3e1d17ff 100644 --- a/win32/lib/crt1.c +++ b/win32/lib/crt1.c @@ -31,10 +31,4 @@ int _start(void) exit(ret); } -int _runmain(int argc, char **argv) -{ - _controlfp(0x10000, 0x30000); - return main(argc, argv, NULL); -} - // ============================================= -- 2.11.4.GIT