History

revert 'no-libtcc1' feature

from 43ae3503904d42a171305b2708f9fd1d37a352ea and a3578379fbd36b663032869a15a0c28c32be4cf6 Sorry, but this feature appears to be rather a personal experiment than generically interesting for other people. Also those "other people" always have some interest in TCC staying simple. One can still avoid the startup code from libtcc1.a simply by providing __start explicitly. While at it: Tidy tccpe.c:pe_add_runtime(), somewhat.

grischka committed 6 years ago

Commit aed5cd01 parent 4cd62982 files · +27 −36Browse files

Unified · Split

2 files
  1. tccelf.c +2 −3
  2. tccpe.c +25 −33
tccelf.c+2−3
@@ -1318,12 +1318,11 @@ static void add_init_array_defines(TCCState *s1, const char *section_name) · 1317 unmodified lines
13181318 }
13191319
13201320 #ifndef TCC_TARGET_PE
1321−static int tcc_add_support(TCCState *s1, const char *filename)
1321+static void tcc_add_support(TCCState *s1, const char *filename)
13221322 {
13231323 char buf[1024];
1324− if (!filename || strlen(filename)==0) return 0;
13251324 snprintf(buf, sizeof(buf), "%s/%s", s1->tcc_lib_path, filename);
1326− return tcc_add_file(s1, buf);
1325+ tcc_add_file(s1, buf);
13271326 }
13281327 #endif
13291328
tccpe.c+25−33
@@ -1855,48 +1855,41 @@ ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack) · 1854 unmodified lines
18551855
18561856 static void tcc_add_support(TCCState *s1, const char *filename)
18571857 {
1858− if (!filename || strlen(filename)==0) return;
18591858 if (tcc_add_dll(s1, filename, 0) < 0)
18601859 tcc_error_noabort("%s not found", filename);
18611860 }
18621861
18631862 static void pe_add_runtime(TCCState *s1, struct pe_info *pe)
18641863 {
1865− const char *start_symbol = NULL;
1866− int pe_type = 0;
1867− int unicode_entry = 0;
1864+ const char *start_symbol;
1865+ int pe_type;
18681866
1869− if (find_elf_sym(symtab_section, PE_STDSYM("WinMain","@16")))
1870− pe_type = PE_GUI;
1871− else
1872− if (find_elf_sym(symtab_section, PE_STDSYM("wWinMain","@16"))) {
1873− pe_type = PE_GUI;
1874− unicode_entry = PE_GUI;
1875− }
1876− else
18771867 if (TCC_OUTPUT_DLL == s1->output_type) {
18781868 pe_type = PE_DLL;
1879− }
1880− else {
1881− pe_type = PE_EXE;
1882− if (find_elf_sym(symtab_section, "wmain"))
1883− unicode_entry = PE_EXE;
1884− else
1885− /* use main() directly when TCC1 is "" */
1886− if (strlen(TCC_LIBTCC1)==0){
1887− start_symbol = "_main";
1888− }
1889− }
1869+ start_symbol = PE_STDSYM("__dllstart","@12");
1870+ } else {
1871+ const char *run_symbol;
1872+ if (find_elf_sym(symtab_section, PE_STDSYM("WinMain","@16"))) {
1873+ start_symbol = "__winstart";
1874+ run_symbol = "__runwinmain";
1875+ pe_type = PE_GUI;
1876+ } else if (find_elf_sym(symtab_section, PE_STDSYM("wWinMain","@16"))) {
1877+ start_symbol = "__wwinstart";
1878+ run_symbol = "__runwwinmain";
1879+ pe_type = PE_GUI;
1880+ } else if (find_elf_sym(symtab_section, "wmain")) {
1881+ start_symbol = "__wstart";
1882+ run_symbol = "__runwmain";
1883+ pe_type = PE_EXE;
1884+ } else {
1885+ start_symbol = "__start";
1886+ run_symbol = "__runmain";
1887+ pe_type = PE_EXE;
18901888
1891− if(!start_symbol)
1892− start_symbol =
1893− TCC_OUTPUT_MEMORY == s1->output_type
1894− ? PE_GUI == pe_type ? (unicode_entry ? "__runwwinmain" : "__runwinmain")
1895− : (unicode_entry ? "__runwmain" : "__runmain")
1896− : PE_DLL == pe_type ? PE_STDSYM("__dllstart","@12")
1897− : PE_GUI == pe_type ? (unicode_entry ? "__wwinstart": "__winstart")
1898− : (unicode_entry ? "__wstart" : "__start")
1899− ;
1889+ }
1890+ if (TCC_OUTPUT_MEMORY == s1->output_type)
1891+ start_symbol = run_symbol;
1892+ }
19001893
19011894 pe->start_symbol = start_symbol + 1;
19021895 if (!s1->leading_underscore || strchr(start_symbol, '@'))
@@ -2053,5 +2046,4 @@ ST_FUNC int pe_output_file(TCCState *s1, const char *filename) · 150 unmodified lines
20532046 }
20542047
20552048 /* ------------------------------------------------------------- */
2056−/* vim: set expandtab ts=4 sw=4 sts=4 tw=80 :*/
20572049

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t