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 73faaea227
This commit is contained in:
grischka 2013-09-10 15:36:56 +02:00
parent 235a65033f
commit 13b997668e
2 changed files with 4 additions and 9 deletions

View File

@ -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)

View File

@ -31,10 +31,4 @@ int _start(void)
exit(ret);
}
int _runmain(int argc, char **argv)
{
_controlfp(0x10000, 0x30000);
return main(argc, argv, NULL);
}
// =============================================