History

libtcc.c: -m option cleanup

handle mms-bitfields as sub-options of -m. (-mfloat-abi is still special because it requires arguments) tcc.c: help(): - list -mms-bitfields under 'Target specific options' libtcc.c/MEM_DEBUG - add check for past buffer writes

grischka committed 9 years ago

Commit d2332391 parent a1c12b94 files · +148 −197Browse files

Unified · Split

4 files
  1. libtcc.c +124 −177
  2. tcc.c +21 −17
  3. tcc.h +1 −1
  4. tccpp.c +2 −2
libtcc.c+124−177
@@ -245,7 +245,14 @@ PUB_FUNC void tcc_memstats(int bench) · 244 unmodified lines
245245
246246 #define MEM_DEBUG_MAGIC1 0xFEEDDEB1
247247 #define MEM_DEBUG_MAGIC2 0xFEEDDEB2
248−#define MEM_DEBUG_FILE_LEN 15
248+#define MEM_DEBUG_MAGIC3 0xFEEDDEB3
249+#define MEM_DEBUG_FILE_LEN 40
250+#define MEM_DEBUG_CHECK3(header) \
251+ ((mem_debug_header_t*)((char*)header + header->size))->magic3
252+#define MEM_USER_PTR(header) \
253+ ((char *)header + offsetof(mem_debug_header_t, magic3))
254+#define MEM_HEADER_PTR(ptr) \
255+ (mem_debug_header_t *)((char*)ptr - offsetof(mem_debug_header_t, magic3))
249256
250257 struct mem_debug_header {
251258 unsigned magic1;
@@ -255,6 +262,7 @@ struct mem_debug_header { · 3 unmodified lines
255262 int line_num;
256263 char file_name[MEM_DEBUG_FILE_LEN + 1];
257264 unsigned magic2;
265+ unsigned magic3;
258266 };
259267
260268 typedef struct mem_debug_header mem_debug_header_t;
@@ -263,76 +271,70 @@ static mem_debug_header_t *mem_debug_chain; · 2 unmodified lines
263271 static unsigned mem_cur_size;
264272 static unsigned mem_max_size;
265273
274+static mem_debug_header_t *malloc_check(void *ptr, const char *msg)
275+{
276+ mem_debug_header_t * header = MEM_HEADER_PTR(ptr);
277+ if (header->magic1 != MEM_DEBUG_MAGIC1 ||
278+ header->magic2 != MEM_DEBUG_MAGIC2 ||
279+ MEM_DEBUG_CHECK3(header) != MEM_DEBUG_MAGIC3 ||
280+ header->size == (unsigned)-1) {
281+ fprintf(stderr, "%s check failed\n", msg);
282+ if (header->magic1 == MEM_DEBUG_MAGIC1)
283+ fprintf(stderr, "%s:%u: block allocated here.\n",
284+ header->file_name, header->line_num);
285+ exit(1);
286+ }
287+ return header;
288+}
289+
266290 PUB_FUNC void *tcc_malloc_debug(unsigned long size, const char *file, int line)
267291 {
268− void *ptr;
269292 int ofs;
270−
271293 mem_debug_header_t *header;
272294
273− ptr = malloc(sizeof(mem_debug_header_t) + size);
274− if (!ptr)
295+ header = malloc(sizeof(mem_debug_header_t) + size);
296+ if (!header)
275297 tcc_error("memory full (malloc)");
276298
277− mem_cur_size += size;
278− if (mem_cur_size > mem_max_size)
279− mem_max_size = mem_cur_size;
280−
281− header = (mem_debug_header_t *)ptr;
282−
283299 header->magic1 = MEM_DEBUG_MAGIC1;
284300 header->magic2 = MEM_DEBUG_MAGIC2;
285301 header->size = size;
302+ MEM_DEBUG_CHECK3(header) = MEM_DEBUG_MAGIC3;
286303 header->line_num = line;
287−
288304 ofs = strlen(file) - MEM_DEBUG_FILE_LEN;
289305 strncpy(header->file_name, file + (ofs > 0 ? ofs : 0), MEM_DEBUG_FILE_LEN);
290306 header->file_name[MEM_DEBUG_FILE_LEN] = 0;
291307
292308 header->next = mem_debug_chain;
293309 header->prev = NULL;
294−
295310 if (header->next)
296311 header->next->prev = header;
297−
298312 mem_debug_chain = header;
299313
300− ptr = (char *)ptr + sizeof(mem_debug_header_t);
301− return ptr;
314+ mem_cur_size += size;
315+ if (mem_cur_size > mem_max_size)
316+ mem_max_size = mem_cur_size;
317+
318+ return MEM_USER_PTR(header);
302319 }
303320
304321 PUB_FUNC void tcc_free_debug(void *ptr)
305322 {
306323 mem_debug_header_t *header;
307−
308324 if (!ptr)
309325 return;
310−
311− ptr = (char *)ptr - sizeof(mem_debug_header_t);
312− header = (mem_debug_header_t *)ptr;
313− if (header->magic1 != MEM_DEBUG_MAGIC1 ||
314− header->magic2 != MEM_DEBUG_MAGIC2 ||
315− header->size == (unsigned)-1 )
316− {
317− tcc_error("tcc_free check failed");
318− }
319−
326+ header = malloc_check(ptr, "tcc_free");
320327 mem_cur_size -= header->size;
321328 header->size = (unsigned)-1;
322−
323329 if (header->next)
324330 header->next->prev = header->prev;
325−
326331 if (header->prev)
327332 header->prev->next = header->next;
328−
329333 if (header == mem_debug_chain)
330334 mem_debug_chain = header->next;
331−
332− free(ptr);
335+ free(header);
333336 }
334337
335−
336338 PUB_FUNC void *tcc_mallocz_debug(unsigned long size, const char *file, int line)
337339 {
338340 void *ptr;
@@ -345,52 +347,26 @@ PUB_FUNC void *tcc_realloc_debug(void *ptr, unsigned long size, const char *file · 6 unmodified lines
345347 {
346348 mem_debug_header_t *header;
347349 int mem_debug_chain_update = 0;
348−
349− if (!ptr) {
350− ptr = tcc_malloc_debug(size, file, line);
351− return ptr;
352− }
353−
354− ptr = (char *)ptr - sizeof(mem_debug_header_t);
355− header = (mem_debug_header_t *)ptr;
356− if (header->magic1 != MEM_DEBUG_MAGIC1 ||
357− header->magic2 != MEM_DEBUG_MAGIC2 ||
358− header->size == (unsigned)-1 )
359− {
360− check_error:
361− tcc_error("tcc_realloc check failed");
362− }
363−
364− mem_debug_chain_update = (header == mem_debug_chain);
365−
366− mem_cur_size -= header->size;
367− ptr = realloc(ptr, sizeof(mem_debug_header_t) + size);
368350 if (!ptr)
351+ return tcc_malloc_debug(size, file, line);
352+ header = malloc_check(ptr, "tcc_realloc");
353+ mem_cur_size -= header->size;
354+ mem_debug_chain_update = (header == mem_debug_chain);
355+ header = realloc(header, sizeof(mem_debug_header_t) + size);
356+ if (!header)
369357 tcc_error("memory full (realloc)");
370−
371− header = (mem_debug_header_t *)ptr;
372− if (header->magic1 != MEM_DEBUG_MAGIC1 ||
373− header->magic2 != MEM_DEBUG_MAGIC2)
374− {
375− goto check_error;
376− }
377−
378− mem_cur_size += size;
379− if (mem_cur_size > mem_max_size)
380− mem_max_size = mem_cur_size;
381−
382358 header->size = size;
359+ MEM_DEBUG_CHECK3(header) = MEM_DEBUG_MAGIC3;
383360 if (header->next)
384361 header->next->prev = header;
385−
386362 if (header->prev)
387363 header->prev->next = header;
388−
389364 if (mem_debug_chain_update)
390365 mem_debug_chain = header;
391−
392− ptr = (char *)ptr + sizeof(mem_debug_header_t);
393− return ptr;
366+ mem_cur_size += size;
367+ if (mem_cur_size > mem_max_size)
368+ mem_max_size = mem_cur_size;
369+ return MEM_USER_PTR(header);
394370 }
395371
396372 PUB_FUNC char *tcc_strdup_debug(const char *str, const char *file, int line)
@@ -405,10 +381,8 @@ PUB_FUNC void tcc_memstats(int bench) · 8 unmodified lines
405381 {
406382 if (mem_cur_size) {
407383 mem_debug_header_t *header = mem_debug_chain;
408−
409384 fprintf(stderr, "MEM_DEBUG: mem_leak= %d bytes, mem_max_size= %d bytes\n",
410385 mem_cur_size, mem_max_size);
411−
412386 while (header) {
413387 fprintf(stderr, "%s:%u: error: %u bytes leaked\n",
414388 header->file_name, header->line_num, header->size);
@@ -417,16 +391,10 @@ PUB_FUNC void tcc_memstats(int bench) · 2 unmodified lines
417391 #if MEM_DEBUG-0 == 2
418392 exit(2);
419393 #endif
420− }
421− else if (bench)
394+ } else if (bench)
422395 fprintf(stderr, "mem_max_size= %d bytes\n", mem_max_size);
423396 }
424−
425−#undef MEM_DEBUG_MAGIC1
426−#undef MEM_DEBUG_MAGIC2
427−#undef MEM_DEBUG_FILE_LEN
428−
429−#endif
397+#endif /* MEM_DEBUG */
430398
431399 #define free(p) use_tcc_free(p)
432400 #define malloc(s) use_tcc_malloc(s)
@@ -760,7 +728,6 @@ LIBTCCAPI TCCState *tcc_new(void) · 327 unmodified lines
760728 s->alacarte_link = 1;
761729 s->nocommon = 1;
762730 s->warn_implicit_function_declaration = 1;
763− s->ms_bitfields = 0;
764731
765732 #ifdef CHAR_IS_UNSIGNED
766733 s->char_is_unsigned = 1;
@@ -1231,14 +1198,6 @@ typedef struct FlagDef { · 464 unmodified lines
12311198 const char *name;
12321199 } FlagDef;
12331200
1234−static const FlagDef warning_defs[] = {
1235− { offsetof(TCCState, warn_unsupported), 0, "unsupported" },
1236− { offsetof(TCCState, warn_write_strings), 0, "write-strings" },
1237− { offsetof(TCCState, warn_error), 0, "error" },
1238− { offsetof(TCCState, warn_implicit_function_declaration), WD_ALL,
1239− "implicit-function-declaration" },
1240−};
1241−
12421201 static int no_flag(const char **pp)
12431202 {
12441203 const char *p = *pp;
@@ -1248,73 +1207,35 @@ static int no_flag(const char **pp) · 3 unmodified lines
12481207 return 1;
12491208 }
12501209
1251−ST_FUNC int set_flag(TCCState *s, const FlagDef *flags, int nb_flags,
1252− const char *name, int value)
1210+ST_FUNC int set_flag(TCCState *s, const FlagDef *flags, const char *name)
12531211 {
1254− int i;
1212+ int value, ret;
12551213 const FlagDef *p;
12561214 const char *r;
12571215
1216+ value = 1;
12581217 r = name;
12591218 if (no_flag(&r))
1260− value = !value;
1261−
1262− for(i = 0, p = flags; i < nb_flags; i++, p++) {
1263− if (!strcmp(r, p->name))
1264− goto found;
1265− }
1266− return -1;
1267− found:
1268− if (p->flags & FD_INVERT)
1269− value = !value;
1270− *(int *)((uint8_t *)s + p->offset) = value;
1271− return 0;
1272−}
1219+ value = 0;
12731220
1274−/* set/reset a warning */
1275−static int tcc_set_warning(TCCState *s, const char *warning_name, int value)
1276−{
1277− int i;
1278− const FlagDef *p;
1279−
1280− if (!strcmp(warning_name, "all")) {
1281− for(i = 0, p = warning_defs; i < countof(warning_defs); i++, p++) {
1282− if (p->flags & WD_ALL)
1283− *(int *)((uint8_t *)s + p->offset) = 1;
1221+ for (ret = -1, p = flags; p->name; ++p) {
1222+ if (ret) {
1223+ if (strcmp(r, p->name))
1224+ continue;
1225+ } else {
1226+ if (0 == (p->flags & WD_ALL))
1227+ continue;
1228+ }
1229+ if (p->offset) {
1230+ *(int*)((char *)s + p->offset) =
1231+ p->flags & FD_INVERT ? !value : value;
1232+ if (ret)
1233+ return 0;
1234+ } else {
1235+ ret = 0;
12841236 }
1285− return 0;
1286− } else {
1287− return set_flag(s, warning_defs, countof(warning_defs),
1288− warning_name, value);
12891237 }
1290−}
1291−
1292−static const FlagDef flag_defs[] = {
1293− { offsetof(TCCState, char_is_unsigned), 0, "unsigned-char" },
1294− { offsetof(TCCState, char_is_unsigned), FD_INVERT, "signed-char" },
1295− { offsetof(TCCState, nocommon), FD_INVERT, "common" },
1296− { offsetof(TCCState, leading_underscore), 0, "leading-underscore" },
1297− { offsetof(TCCState, ms_extensions), 0, "ms-extensions" },
1298− { offsetof(TCCState, old_struct_init_code), 0, "old-struct-init-code" },
1299− { offsetof(TCCState, dollars_in_identifiers), 0, "dollars-in-identifiers" },
1300−};
1301−
1302−/* set/reset a flag */
1303−static int tcc_set_flag(TCCState *s, const char *flag_name, int value)
1304−{
1305− return set_flag(s, flag_defs, countof(flag_defs),
1306− flag_name, value);
1307−}
1308−
1309−static const FlagDef m_defs[] = {
1310−#ifdef TCC_TARGET_X86_64
1311− { offsetof(TCCState, nosse), FD_INVERT, "sse" },
1312−#endif
1313− { 0, 0, " no flag" },
1314−};
1315−static int tcc_set_m_flag(TCCState *s, const char *flag_name, int value)
1316−{
1317− return set_flag(s, m_defs, countof(m_defs), flag_name, value);
1238+ return ret;
13181239 }
13191240
13201241 static int strstart(const char *val, const char **str)
@@ -1517,7 +1438,6 @@ enum { · 196 unmodified lines
15171438 TCC_OPTION_c,
15181439 TCC_OPTION_dumpversion,
15191440 TCC_OPTION_d,
1520− TCC_OPTION_float_abi,
15211441 TCC_OPTION_static,
15221442 TCC_OPTION_std,
15231443 TCC_OPTION_shared,
@@ -1530,7 +1450,7 @@ enum { · 6 unmodified lines
15301450 TCC_OPTION_Wp,
15311451 TCC_OPTION_W,
15321452 TCC_OPTION_O,
1533− TCC_OPTION_mms_bitfields,
1453+ TCC_OPTION_mfloat_abi,
15341454 TCC_OPTION_m,
15351455 TCC_OPTION_f,
15361456 TCC_OPTION_isystem,
@@ -1578,9 +1498,6 @@ static const TCCOption tcc_options[] = { · 41 unmodified lines
15781498 { "c", TCC_OPTION_c, 0 },
15791499 { "dumpversion", TCC_OPTION_dumpversion, 0},
15801500 { "d", TCC_OPTION_d, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1581−#ifdef TCC_TARGET_ARM
1582− { "mfloat-abi", TCC_OPTION_float_abi, TCC_OPTION_HAS_ARG },
1583−#endif
15841501 { "static", TCC_OPTION_static, 0 },
15851502 { "std", TCC_OPTION_std, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
15861503 { "shared", TCC_OPTION_shared, 0 },
@@ -1598,8 +1515,10 @@ static const TCCOption tcc_options[] = { · 11 unmodified lines
15981515 { "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
15991516 { "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
16001517 { "O", TCC_OPTION_O, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1601− { "mms-bitfields", TCC_OPTION_mms_bitfields, 0}, /* must go before option 'm' */
1602− { "m", TCC_OPTION_m, TCC_OPTION_HAS_ARG },
1518+#ifdef TCC_TARGET_ARM
1519+ { "mfloat-abi", TCC_OPTION_mfloat_abi, TCC_OPTION_HAS_ARG },
1520+#endif
1521+ { "m", TCC_OPTION_m, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
16031522 { "f", TCC_OPTION_f, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
16041523 { "isystem", TCC_OPTION_isystem, TCC_OPTION_HAS_ARG },
16051524 { "iwithprefix", TCC_OPTION_iwithprefix, TCC_OPTION_HAS_ARG },
@@ -1617,6 +1536,35 @@ static const TCCOption tcc_options[] = { · 11 unmodified lines
16171536 { NULL, 0, 0 },
16181537 };
16191538
1539+static const FlagDef options_W[] = {
1540+ { 0, 0, "all" },
1541+ { offsetof(TCCState, warn_unsupported), 0, "unsupported" },
1542+ { offsetof(TCCState, warn_write_strings), 0, "write-strings" },
1543+ { offsetof(TCCState, warn_error), 0, "error" },
1544+ { offsetof(TCCState, warn_implicit_function_declaration), WD_ALL,
1545+ "implicit-function-declaration" },
1546+ { 0, 0, NULL }
1547+};
1548+
1549+static const FlagDef options_f[] = {
1550+ { offsetof(TCCState, char_is_unsigned), 0, "unsigned-char" },
1551+ { offsetof(TCCState, char_is_unsigned), FD_INVERT, "signed-char" },
1552+ { offsetof(TCCState, nocommon), FD_INVERT, "common" },
1553+ { offsetof(TCCState, leading_underscore), 0, "leading-underscore" },
1554+ { offsetof(TCCState, ms_extensions), 0, "ms-extensions" },
1555+ { offsetof(TCCState, old_struct_init_code), 0, "old-struct-init-code" },
1556+ { offsetof(TCCState, dollars_in_identifiers), 0, "dollars-in-identifiers" },
1557+ { 0, 0, NULL }
1558+};
1559+
1560+static const FlagDef options_m[] = {
1561+ { offsetof(TCCState, ms_bitfields), 0, "ms-bitfields" },
1562+#ifdef TCC_TARGET_X86_64
1563+ { offsetof(TCCState, nosse), FD_INVERT, "sse" },
1564+#endif
1565+ { 0, 0, NULL }
1566+};
1567+
16201568 static void parse_option_D(TCCState *s1, const char *optarg)
16211569 {
16221570 char *sym = tcc_strdup(optarg);
@@ -1766,18 +1714,6 @@ reparse: · 143 unmodified lines
17661714 else
17671715 goto unsupported_option;
17681716 break;
1769−#ifdef TCC_TARGET_ARM
1770− case TCC_OPTION_float_abi:
1771− /* tcc doesn't support soft float yet */
1772− if (!strcmp(optarg, "softfp")) {
1773− s->float_abi = ARM_SOFTFP_FLOAT;
1774− tcc_undefine_symbol(s, "__ARM_PCS_VFP");
1775− } else if (!strcmp(optarg, "hard"))
1776− s->float_abi = ARM_HARD_FLOAT;
1777− else
1778− tcc_error("unsupported float abi '%s'", optarg);
1779− break;
1780−#endif
17811717 case TCC_OPTION_static:
17821718 s->static_link = 1;
17831719 break;
@@ -1791,12 +1727,6 @@ reparse: · 7 unmodified lines
17911727 case TCC_OPTION_soname:
17921728 s->soname = tcc_strdup(optarg);
17931729 break;
1794− case TCC_OPTION_m:
1795− if (!strcmp(optarg, "32") || !strcmp(optarg, "64"))
1796− s->option_m = tcc_strdup(optarg);
1797− else if (tcc_set_m_flag(s, optarg, 1) < 0)
1798− goto unsupported_option;
1799− break;
18001730 case TCC_OPTION_o:
18011731 if (s->outfile) {
18021732 tcc_warning("multiple -o option");
@@ -1841,11 +1771,31 @@ reparse: · 38 unmodified lines
18411771 do ++s->verbose; while (*optarg++ == 'v');
18421772 break;
18431773 case TCC_OPTION_f:
1844− if (tcc_set_flag(s, optarg, 1) < 0)
1774+ if (set_flag(s, options_f, optarg) < 0)
1775+ goto unsupported_option;
1776+ break;
1777+#ifdef TCC_TARGET_ARM
1778+ case TCC_OPTION_mfloat_abi:
1779+ /* tcc doesn't support soft float yet */
1780+ if (!strcmp(optarg, "softfp")) {
1781+ s->float_abi = ARM_SOFTFP_FLOAT;
1782+ tcc_undefine_symbol(s, "__ARM_PCS_VFP");
1783+ } else if (!strcmp(optarg, "hard"))
1784+ s->float_abi = ARM_HARD_FLOAT;
1785+ else
1786+ tcc_error("unsupported float abi '%s'", optarg);
1787+ break;
1788+#endif
1789+ case TCC_OPTION_m:
1790+ if (set_flag(s, options_m, optarg) == 0)
1791+ break;
1792+ else if (x = atoi(optarg), x == 32 || x == 64)
1793+ s->cross_target = x;
1794+ else
18451795 goto unsupported_option;
18461796 break;
18471797 case TCC_OPTION_W:
1848− if (tcc_set_warning(s, optarg, 1) < 0)
1798+ if (set_flag(s, options_W, optarg) < 0)
18491799 goto unsupported_option;
18501800 break;
18511801 case TCC_OPTION_w:
@@ -1893,9 +1843,6 @@ reparse: · 41 unmodified lines
18931843 case TCC_OPTION_O:
18941844 last_o = atoi(optarg);
18951845 break;
1896− case TCC_OPTION_mms_bitfields:
1897− s->ms_bitfields = 1;
1898− break;
18991846 case TCC_OPTION_traditional:
19001847 case TCC_OPTION_pedantic:
19011848 case TCC_OPTION_pipe:
tcc.c+21−17
@@ -97,16 +97,11 @@ static void help(void) · 96 unmodified lines
9797 " -o outfile set output filename\n"
9898 " -run run compiled source\n"
9999 " -fflag set or reset (with 'no-' prefix) 'flag' (see man page)\n"
100− " -mms-bitfields use bitfield alignment consistent with MSVC\n"
101100 " -Wwarning set or reset (with 'no-' prefix) 'warning' (see man page)\n"
102101 " -w disable all warnings\n"
103102 " -v show version\n"
104103 " -vv show included files (as sole argument: show search paths)\n"
105− " -dumpversion\n"
106104 " -bench show compilation statistics\n"
107− " -xc -xa specify type of the next infile\n"
108− " - use stdin pipe as infile\n"
109− " @listfile read arguments from listfile\n"
110105 "Preprocessor options:\n"
111106 " -Idir add include path 'dir'\n"
112107 " -Dsym[=val] define 'sym' with value 'val'\n"
@@ -117,12 +112,12 @@ static void help(void) · 4 unmodified lines
117112 "Linker options:\n"
118113 " -Ldir add library path 'dir'\n"
119114 " -llib link with dynamic or static library 'lib'\n"
120− " -pthread link with -lpthread and -D_REENTRANT (POSIX Linux)\n"
121115 " -r generate (relocatable) object file\n"
122− " -rdynamic export all global symbols to dynamic linker\n"
123116 " -shared generate a shared library\n"
117+ " -rdynamic export all global symbols to dynamic linker\n"
124118 " -soname set name for shared library to be used at runtime\n"
125119 " -static static linking\n"
120+ " -pthread link with -lpthread and -D_REENTRANT (POSIX Linux)\n"
126121 " -Wl,-opt[=val] set linker option (see manual)\n"
127122 "Debugger options:\n"
128123 " -g generate runtime debug info\n"
@@ -133,11 +128,24 @@ static void help(void) · 4 unmodified lines
133128 " -bt N show N callers in stack traces\n"
134129 #endif
135130 "Misc options:\n"
131+ " -x[c|a|n] specify type of the next infile\n"
136132 " -nostdinc do not use standard system include paths\n"
137133 " -nostdlib do not link with standard crt and libraries\n"
138− " -Bdir use 'dir' as tcc internal library and include path\n"
134+ " -Bdir use 'dir' as tcc's private library/include path\n"
139135 " -MD generate target dependencies for make\n"
140136 " -MF depfile put generated dependencies here\n"
137+ " -dumpversion print version\n"
138+ " - use stdin pipe as infile\n"
139+ " @listfile read arguments from listfile\n"
140+ "Target specific options:\n"
141+ " -m32/64 execute i386/x86-64 cross compiler\n"
142+ " -mms-bitfields use MSVC bitfield layout\n"
143+#ifdef TCC_TARGET_ARM
144+ " -mfloat-abi hard/softfp on arm\n"
145+#endif
146+#ifdef TCC_TARGET_X86_64
147+ " -mno-sse disable floats on x86-64\n"
148+#endif
141149 );
142150 }
143151
@@ -155,10 +163,10 @@ static int execvp_win32(const char *prog, char **argv) · 11 unmodified lines
155163 }
156164 #define execvp execvp_win32
157165 #endif
158−static void exec_other_tcc(TCCState *s, char **argv, const char *optarg)
166+static void exec_other_tcc(TCCState *s, char **argv, int option)
159167 {
160168 char child_path[4096], *child_name; const char *target;
161− switch (atoi(optarg)) {
169+ switch (option) {
162170 #ifdef TCC_TARGET_I386
163171 case 32: break;
164172 case 64: target = "x86_64";
@@ -179,14 +187,10 @@ static void exec_other_tcc(TCCState *s, char **argv, const char *optarg) · 14 unmodified lines
179187 execvp(argv[0] = child_path, argv);
180188 }
181189 tcc_error("'%s' not found", child_name);
182− case 0: /* ignore -march etc. */
183− break;
184− default:
185− tcc_warning("unsupported option \"-m%s\"", optarg);
186190 }
187191 }
188192 #else
189−#define exec_other_tcc(s, argv, optarg)
193+#define exec_other_tcc(s, argv, option)
190194 #endif
191195
192196 static void gen_makedeps(TCCState *s, const char *target, const char *filename)
@@ -274,8 +278,8 @@ int main(int argc, char **argv) · 81 unmodified lines
274278 return 1;
275279 }
276280
277− if (s->option_m)
278− exec_other_tcc(s, argv, s->option_m);
281+ if (s->cross_target)
282+ exec_other_tcc(s, argv, s->cross_target);
279283
280284 if (s->verbose)
281285 display_info(s, 0);
tcc.h+1−1
@@ -762,7 +762,7 @@ struct TCCState { · 761 unmodified lines
762762 int nb_libraries; /* number of libs thereof */
763763 int filetype;
764764 char *outfile; /* output filename */
765− char *option_m; /* only -m32/-m64 handled */
765+ int cross_target; /* -m32/-m64 */
766766 int print_search_dirs; /* option */
767767 int option_r; /* option -r */
768768 int do_bench; /* option -bench */
tccpp.c+2−2
@@ -186,13 +186,13 @@ tail_call: · 185 unmodified lines
186186 #ifdef TAL_DEBUG
187187 if (al->nb_allocs > 0) {
188188 uint8_t *p;
189− fprintf(stderr, "TAL_DEBUG: mem leak %d chunks (limit= %d)\n",
189+ fprintf(stderr, "TAL_DEBUG: memory leak %d chunk(s) (limit= %d)\n",
190190 al->nb_allocs, al->limit);
191191 p = al->buffer;
192192 while (p < al->p) {
193193 tal_header_t *header = (tal_header_t *)p;
194194 if (header->line_num > 0) {
195− fprintf(stderr, "%s:%d: chunk of %d bytes\n",
195+ fprintf(stderr, "%s:%d: chunk of %d bytes leaked\n",
196196 header->file_name, header->line_num, header->size);
197197 }
198198 p += header->size + sizeof(tal_header_t);

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