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
13951395 }
13961396
13971397
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)
13991399 {
14001400 const char *p, *q;
14011401 p = str;
@@ -1407,27 +1407,36 @@ static int strstart(const char *str, const char *val, const char **ptr) · 5 unmodified lines
14071407 q++;
14081408 }
14091409 if (ptr)
1410− *ptr = p;
1410+ *ptr = (char *) p;
14111411 return 1;
14121412 }
14131413
14141414 /* 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)
14161416 {
1417− const char *p = option;
1418− char *end = NULL;
1417+ char *p = option;
1418+ char *end;
14191419
14201420 while (option && *option) {
1421−
1421+ end = NULL;
14221422 if (strstart(option, "-Bsymbolic", &p)) {
14231423 s->symbolic = TRUE;
14241424 #ifdef TCC_TARGET_PE
14251425 } else if (strstart(option, "--file-alignment,", &p)) {
14261426 s->pe_file_align = strtoul(p, &end, 16);
14271427 #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+
14281433 } else if (strstart(option, "--image-base,", &p)) {
14291434 s->text_addr = strtoul(p, &end, 16);
14301435 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);
14311440
14321441 } else if (strstart(option, "--oformat,", &p)) {
14331442 #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
14961505 }
14971506
14981507 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;
15041513 }
15051514 } else
15061515 option = NULL;
libtcc.h+1−1
@@ -32,7 +32,7 @@ LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque, · 31 unmodified lines
3232 LIBTCCAPI int tcc_set_warning(TCCState *s, const char *warning_name, int value);
3333
3434 /* set linker option */
35−LIBTCCAPI const char * tcc_set_linker(TCCState *s, const char *option, int multi);
35+LIBTCCAPI const char * tcc_set_linker(TCCState *s, char *option, int multi);
3636
3737 /*****************************/
3838 /* preprocessor */
tcc.c+1−1
@@ -367,7 +367,7 @@ static int parse_args(TCCState *s, int argc, char **argv) · 366 unmodified lines
367367 break;
368368 case TCC_OPTION_Wl:
369369 {
370− if ((r = (char *)tcc_set_linker(s, optarg, TRUE)))
370+ if ((r = (char *) tcc_set_linker(s, (char *)optarg, TRUE)))
371371 error("unsupported linker option '%s'", r);
372372 }
373373 break;
tcc.h+4−0
@@ -462,6 +462,10 @@ struct TCCState { · 461 unmodified lines
462462 /* address of text section */
463463 unsigned long text_addr;
464464 int has_text_addr;
465+
466+ /* symbols to call at load-time / unload-time */
467+ const char *init_symbol;
468+ const char *fini_symbol;
465469
466470 /* output format, see TCC_OUTPUT_FORMAT_xxx */
467471 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