diff options
| author | Thomas Preud'homme <robotux@celest.fr> | 2012-03-15 00:22:00 +0100 |
|---|---|---|
| committer | Thomas Preud'homme <robotux@celest.fr> | 2012-03-15 00:25:40 +0100 |
| commit | 7fb0482a4645d59068ccefe44a3a022b649e5a3a (patch) | |
| tree | fb46a6cc2c3073f59c87d8ba0efed47ba6c6ae75 | |
| parent | 1736a71b71221df7c81b0d3da25e774f3c4005d2 (diff) | |
| download | tinycc-7fb0482a4645d59068ccefe44a3a022b649e5a3a.tar.gz tinycc-7fb0482a4645d59068ccefe44a3a022b649e5a3a.tar.bz2 | |
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.
| -rw-r--r-- | libtcc.c | 3 | ||||
| -rw-r--r-- | tcc.c | 18 |
2 files changed, 19 insertions, 2 deletions
@@ -1566,6 +1566,9 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) s->text_addr = strtoull(p, &end, 16); s->has_text_addr = 1; } else { + char *comma_ptr = strchr(option, ','); + if (comma_ptr) + *comma_ptr = '\0'; return option; } @@ -280,6 +280,8 @@ static int parse_args(TCCState *s, int argc, char **argv) const char *optarg, *p1, *r1; char *r; int was_pthread; + char *linker_arg = NULL; + unsigned long linker_argsize = 0; was_pthread = 0; /* is set if commandline contains -pthread key */ @@ -442,8 +444,17 @@ static int parse_args(TCCState *s, int argc, char **argv) s->rdynamic = 1; break; case TCC_OPTION_Wl: - if ((r = (char *) tcc_set_linker(s, (char *)optarg, TRUE))) - tcc_error("unsupported linker option '%s'", r); + if (!linker_arg) { + linker_argsize = strlen(optarg) + 1; + linker_arg = tcc_malloc(linker_argsize); + pstrcpy(linker_arg, linker_argsize, optarg); + } + else { + linker_argsize += strlen(optarg) + 1; + linker_arg = tcc_realloc(linker_arg, linker_argsize); + pstrcat(linker_arg, linker_argsize, ","); + pstrcat(linker_arg, linker_argsize, optarg); + } break; case TCC_OPTION_E: output_type = TCC_OUTPUT_PREPROCESS; @@ -465,6 +476,9 @@ static int parse_args(TCCState *s, int argc, char **argv) } } } + if ((r = (char *) tcc_set_linker(s, (char *)linker_arg, TRUE))) + tcc_error("unsupported linker option '%s'", r); + tcc_free(linker_arg); /* fixme: these options could be different on your platform */ if (was_pthread && output_type != TCC_OUTPUT_OBJ) { dynarray_add((void ***)&files, &nb_files, "-lpthread"); |
