| @@ -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 | const char *p, *q; | 1400 | const char *p, *q; |
| 1401 | p = str; | 1401 | p = str; |
| @@ -1407,27 +1407,36 @@ static int strstart(const char *str, const char *val, const char **ptr) · 5 unmodified lines |
| 1407 | q++; | 1407 | q++; |
| 1408 | } | 1408 | } |
| 1409 | if (ptr) | 1409 | if (ptr) |
| 1410 | *ptr = p; | 1410 | *ptr = (char *) p; |
| 1411 | return 1; | 1411 | return 1; |
| 1412 | } | 1412 | } |
| 1413 | | 1413 | |
| 1414 | /* set linker options */ | 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; | 1417 | char *p = option; |
| 1418 | char *end = NULL; | 1418 | char *end; |
| 1419 | | 1419 | |
| 1420 | while (option && *option) { | 1420 | while (option && *option) { |
| 1421 | | 1421 | end = NULL; |
| 1422 | if (strstart(option, "-Bsymbolic", &p)) { | 1422 | if (strstart(option, "-Bsymbolic", &p)) { |
| 1423 | s->symbolic = TRUE; | 1423 | s->symbolic = TRUE; |
| 1424 | #ifdef TCC_TARGET_PE | 1424 | #ifdef TCC_TARGET_PE |
| 1425 | } else if (strstart(option, "--file-alignment,", &p)) { | 1425 | } else if (strstart(option, "--file-alignment,", &p)) { |
| 1426 | s->pe_file_align = strtoul(p, &end, 16); | 1426 | s->pe_file_align = strtoul(p, &end, 16); |
| 1427 | #endif | 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 | } else if (strstart(option, "--image-base,", &p)) { | 1433 | } else if (strstart(option, "--image-base,", &p)) { |
| 1429 | s->text_addr = strtoul(p, &end, 16); | 1434 | s->text_addr = strtoul(p, &end, 16); |
| 1430 | s->has_text_addr = 1; | 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 | } else if (strstart(option, "--oformat,", &p)) { | 1441 | } else if (strstart(option, "--oformat,", &p)) { |
| 1433 | #if defined(TCC_TARGET_PE) | 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 | if (multi) { | 1507 | if (multi) { |
| 1499 | if (end) { | 1508 | option = NULL; |
| 1500 | option = end; | 1509 | p = strchr( (end) ? end : p, ','); |
| 1501 | } else { | 1510 | if (p) { |
| 1502 | option = strchr(p, ','); | 1511 | *p = 0; /* terminate last option */ |
| 1503 | if (option) option++; | 1512 | option = ++p; |
| 1504 | } | 1513 | } |
| 1505 | } else | 1514 | } else |
| 1506 | option = NULL; | 1515 | option = NULL; |