History

Support linker options passed in several -Wl param

ld support arguments to multiple-letter options being passed in two ways: * -opt=arg * -opt arg libtool generate command line of the second form. This commit add support for the second form so that libtool works with tcc. The way it is done is to concatenate all -Wl options into one and then pass it to set_linker.

Thomas Preud'homme committed 14 years ago

Commit 7fb04821 parent 1736a712 files · +19 −2Browse files

Unified · Split

2 files
  1. libtcc.c +3 −0
  2. tcc.c +16 −2
libtcc.c+3−0
@@ -1566,6 +1566,9 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) · 1565 unmodified lines
15661566 s->text_addr = strtoull(p, &end, 16);
15671567 s->has_text_addr = 1;
15681568 } else {
1569+ char *comma_ptr = strchr(option, ',');
1570+ if (comma_ptr)
1571+ *comma_ptr = '\0';
15691572 return option;
15701573 }
15711574
tcc.c+16−2
@@ -280,6 +280,8 @@ static int parse_args(TCCState *s, int argc, char **argv) · 279 unmodified lines
280280 const char *optarg, *p1, *r1;
281281 char *r;
282282 int was_pthread;
283+ char *linker_arg = NULL;
284+ unsigned long linker_argsize = 0;
283285
284286 was_pthread = 0; /* is set if commandline contains -pthread key */
285287
@@ -442,8 +444,17 @@ static int parse_args(TCCState *s, int argc, char **argv) · 156 unmodified lines
442444 s->rdynamic = 1;
443445 break;
444446 case TCC_OPTION_Wl:
445− if ((r = (char *) tcc_set_linker(s, (char *)optarg, TRUE)))
446− tcc_error("unsupported linker option '%s'", r);
447+ if (!linker_arg) {
448+ linker_argsize = strlen(optarg) + 1;
449+ linker_arg = tcc_malloc(linker_argsize);
450+ pstrcpy(linker_arg, linker_argsize, optarg);
451+ }
452+ else {
453+ linker_argsize += strlen(optarg) + 1;
454+ linker_arg = tcc_realloc(linker_arg, linker_argsize);
455+ pstrcat(linker_arg, linker_argsize, ",");
456+ pstrcat(linker_arg, linker_argsize, optarg);
457+ }
447458 break;
448459 case TCC_OPTION_E:
449460 output_type = TCC_OUTPUT_PREPROCESS;
@@ -465,6 +476,9 @@ static int parse_args(TCCState *s, int argc, char **argv) · 15 unmodified lines
465476 }
466477 }
467478 }
479+ if ((r = (char *) tcc_set_linker(s, (char *)linker_arg, TRUE)))
480+ tcc_error("unsupported linker option '%s'", r);
481+ tcc_free(linker_arg);
468482 /* fixme: these options could be different on your platform */
469483 if (was_pthread && output_type != TCC_OUTPUT_OBJ) {
470484 dynarray_add((void ***)&files, &nb_files, "-lpthread");

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