From 0486939291bfe4406f688ffc8a62b4da2c7a95cf Mon Sep 17 00:00:00 2001 From: "Pavlas, Zdenek" Date: Mon, 12 Dec 2016 06:52:45 -0800 Subject: [PATCH] win32: support "-Wl,--large-address-aware" option --- libtcc.c | 2 ++ tcc.h | 1 + tccpe.c | 1 + 3 files changed, 4 insertions(+) diff --git a/libtcc.c b/libtcc.c index 270e986..11a7cf6 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1370,6 +1370,8 @@ static int tcc_set_linker(TCCState *s, const char *option) } else if (link_option(option, "soname=", &p)) { s->soname = copy_linker_arg(p); #ifdef TCC_TARGET_PE + } else if (link_option(option, "large-address-aware", &p)) { + s->pe_characteristics |= 0x20; } else if (link_option(option, "file-alignment=", &p)) { s->pe_file_align = strtoul(p, &end, 16); } else if (link_option(option, "stack=", &p)) { diff --git a/tcc.h b/tcc.h index 1488c26..7997e86 100644 --- a/tcc.h +++ b/tcc.h @@ -744,6 +744,7 @@ struct TCCState { #ifdef TCC_TARGET_PE /* PE info */ int pe_subsystem; + unsigned pe_characteristics; unsigned pe_file_align; unsigned pe_stack_size; # ifdef TCC_TARGET_X86_64 diff --git a/tccpe.c b/tccpe.c index e2101bb..44a823e 100644 --- a/tccpe.c +++ b/tccpe.c @@ -703,6 +703,7 @@ static int pe_write(struct pe_info *pe) pe_header.opthdr.SizeOfStackReserve = pe->s1->pe_stack_size; if (PE_DLL == pe->type) pe_header.filehdr.Characteristics = CHARACTERISTICS_DLL; + pe_header.filehdr.Characteristics |= pe->s1->pe_characteristics; sum = 0; pe_fwrite(&pe_header, sizeof pe_header, op, &sum);