History

libtcc: Detect (but ignore) -init and -fini for -Wl

-- By by ... Detlef

Detlef Riekenberg committed 16 years ago

Commit 34dabe41 parent 87574de4 files · +26 −13Browse files

Unified · Split

4 files
  1. libtcc.c +20 −11
  2. libtcc.h +1 −1
  3. tcc.c +1 −1
  4. tcc.h +4 −0
libtcc.c+20−11
@@ -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
1398static int strstart(const char *str, const char *val, const char **ptr)1398static 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 */
1415PUB_FUNC const char * tcc_set_linker(TCCState *s, const char *option, int multi)1415PUB_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_PE1424#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#endif1427#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 } else1514 } else
1506 option = NULL;1515 option = NULL;
libtcc.h+1−1
@@ -32,7 +32,7 @@ LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque, · 31 unmodified lines
32LIBTCCAPI int tcc_set_warning(TCCState *s, const char *warning_name, int value);32LIBTCCAPI int tcc_set_warning(TCCState *s, const char *warning_name, int value);
33 33
34/* set linker option */34/* set linker option */
35LIBTCCAPI const char * tcc_set_linker(TCCState *s, const char *option, int multi);35LIBTCCAPI const char * tcc_set_linker(TCCState *s, char *option, int multi);
36 36
37/*****************************/37/*****************************/
38/* preprocessor */38/* preprocessor */
tcc.c+1−1
@@ -367,7 +367,7 @@ static int parse_args(TCCState *s, int argc, char **argv) · 366 unmodified lines
367 break;367 break;
368 case TCC_OPTION_Wl:368 case TCC_OPTION_Wl:
369 {369 {
370 if ((r = (char *)tcc_set_linker(s, optarg, TRUE)))370 if ((r = (char *) tcc_set_linker(s, (char *)optarg, TRUE)))
371 error("unsupported linker option '%s'", r);371 error("unsupported linker option '%s'", r);
372 }372 }
373 break;373 break;
tcc.h+4−0
@@ -462,6 +462,10 @@ struct TCCState { · 461 unmodified lines
462 /* address of text section */462 /* address of text section */
463 unsigned long text_addr;463 unsigned long text_addr;
464 int has_text_addr;464 int has_text_addr;
465
466 /* symbols to call at load-time / unload-time */
467 const char *init_symbol;
468 const char *fini_symbol;
465 469
466 /* output format, see TCC_OUTPUT_FORMAT_xxx */470 /* output format, see TCC_OUTPUT_FORMAT_xxx */
467 int output_format;471 int output_format;

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