| @@ -1395,7 +1395,7 @@ PUB_FUNC int tcc_set_flag(TCCState *s, const char *flag_name, int value) · 1394 unmodified lines |
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | |
| 1398 | | −static int strstart(const char *str, const char *val, const char **ptr) |
| 1398 | +static int strstart(const char *str, const char *val, char **ptr) |
| 1399 | 1399 | { |
| 1400 | 1400 | const char *p, *q; |
| 1401 | 1401 | p = str; |
| @@ -1407,27 +1407,36 @@ static int strstart(const char *str, const char *val, const char **ptr) · 5 unmodified lines |
| 1407 | 1407 | q++; |
| 1408 | 1408 | } |
| 1409 | 1409 | if (ptr) |
| 1410 | | − *ptr = p; |
| 1410 | + *ptr = (char *) p; |
| 1411 | 1411 | return 1; |
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | 1414 | /* set linker options */ |
| 1415 | | −PUB_FUNC const char * tcc_set_linker(TCCState *s, const char *option, int multi) |
| 1415 | +PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) |
| 1416 | 1416 | { |
| 1417 | | − const char *p = option; |
| 1418 | | − char *end = NULL; |
| 1417 | + char *p = option; |
| 1418 | + char *end; |
| 1419 | 1419 | |
| 1420 | 1420 | while (option && *option) { |
| 1421 | | − |
| 1421 | + end = NULL; |
| 1422 | 1422 | if (strstart(option, "-Bsymbolic", &p)) { |
| 1423 | 1423 | s->symbolic = TRUE; |
| 1424 | 1424 | #ifdef TCC_TARGET_PE |
| 1425 | 1425 | } else if (strstart(option, "--file-alignment,", &p)) { |
| 1426 | 1426 | s->pe_file_align = strtoul(p, &end, 16); |
| 1427 | 1427 | #endif |
| 1428 | + } else if (strstart(option, "-fini,", &p)) { |
| 1429 | + s->fini_symbol = p; |
| 1430 | + if (s->warn_unsupported) |
| 1431 | + warning("ignoring -fini %s", p); |
| 1432 | + |
| 1428 | 1433 | } else if (strstart(option, "--image-base,", &p)) { |
| 1429 | 1434 | s->text_addr = strtoul(p, &end, 16); |
| 1430 | 1435 | s->has_text_addr = 1; |
| 1436 | + } else if (strstart(option, "-init,", &p)) { |
| 1437 | + s->init_symbol = p; |
| 1438 | + if (s->warn_unsupported) |
| 1439 | + warning("ignoring -init %s", p); |
| 1431 | 1440 | |
| 1432 | 1441 | } else if (strstart(option, "--oformat,", &p)) { |
| 1433 | 1442 | #if defined(TCC_TARGET_PE) |
| @@ -1496,11 +1505,11 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, const char *option, int multi) · 62 unmodified lines |
| 1496 | 1505 | } |
| 1497 | 1506 | |
| 1498 | 1507 | if (multi) { |
| 1499 | | − if (end) { |
| 1500 | | − option = end; |
| 1501 | | − } else { |
| 1502 | | − option = strchr(p, ','); |
| 1503 | | − if (option) option++; |
| 1508 | + option = NULL; |
| 1509 | + p = strchr( (end) ? end : p, ','); |
| 1510 | + if (p) { |
| 1511 | + *p = 0; /* terminate last option */ |
| 1512 | + option = ++p; |
| 1504 | 1513 | } |
| 1505 | 1514 | } else |
| 1506 | 1515 | option = NULL; |