From 45184e01d80d0e01bc6d03a86e5aa4e706095e47 Mon Sep 17 00:00:00 2001 From: grischka Date: Mon, 11 Jul 2011 18:47:16 +0200 Subject: [PATCH] win32: add -Wl,--stack=xxx switch For example: $ tcc -Wl,--stack=4194309 which means 4 MB. Default is 1 MB. --- libtcc.c | 10 ++++------ tcc.h | 1 + tccpe.c | 2 ++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libtcc.c b/libtcc.c index fedd7e5b..46a13fc9 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1551,15 +1551,10 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) end = NULL; if (link_option(option, "Bsymbolic", &p)) { s->symbolic = TRUE; -#ifdef TCC_TARGET_PE - } else if (link_option(option, "file-alignment=", &p)) { - s->pe_file_align = strtoul(p, &end, 16); -#endif } else if (link_option(option, "fini=", &p)) { s->fini_symbol = p; if (s->warn_unsupported) warning("ignoring -fini %s", p); - } else if (link_option(option, "image-base=", &p)) { s->text_addr = strtoul(p, &end, 16); s->has_text_addr = 1; @@ -1567,7 +1562,6 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) s->init_symbol = p; if (s->warn_unsupported) warning("ignoring -init %s", p); - } else if (link_option(option, "oformat=", &p)) { #if defined(TCC_TARGET_PE) if (strstart(p, "pe-", NULL)) { @@ -1599,6 +1593,10 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) s->soname = p; multi = 0; #ifdef TCC_TARGET_PE + } else if (link_option(option, "file-alignment=", &p)) { + s->pe_file_align = strtoul(p, &end, 16); + } else if (link_option(option, "stack=", &p)) { + s->pe_stack_size = strtoul(p, &end, 10); } else if (link_option(option, "subsystem=", &p)) { #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) if (!strcmp(p, "native")) { diff --git a/tcc.h b/tcc.h index c3c10316..ce7ee226 100644 --- a/tcc.h +++ b/tcc.h @@ -565,6 +565,7 @@ struct TCCState { /* PE info */ int pe_subsystem; unsigned long pe_file_align; + unsigned long pe_stack_size; struct pe_uw { Section *pdata; int sym_1, sym_2, offs_1; diff --git a/tccpe.c b/tccpe.c index de2575a4..ed57c632 100644 --- a/tccpe.c +++ b/tccpe.c @@ -686,6 +686,8 @@ static int pe_write(struct pe_info *pe) pe_header.filehdr.NumberOfSections = pe->sec_count; pe_header.opthdr.SizeOfHeaders = pe->sizeofheaders; pe_header.opthdr.ImageBase = pe->imagebase; + if (pe->s1->pe_stack_size) + pe_header.opthdr.SizeOfStackReserve = pe->s1->pe_stack_size; if (PE_DLL == pe->type) pe_header.filehdr.Characteristics = CHARACTERISTICS_DLL; else if (PE_GUI != pe->type) -- 2.11.4.GIT