commit 2a28638 (HEAD -> refs/heads/i) Author: Steffen (Daode) Nurpmeso AuthorDate: 2016-06-04 15:48:15 +0200 Commit: Steffen (Daode) Nurpmeso CommitDate: 2016-06-06 21:50:26 +0200 Allow multiple -rpath linker arguments --- libtcc.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libtcc.c b/libtcc.c index 12ee171..dd1789c 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1834,6 +1834,29 @@ static char *copy_linker_arg(const char *p) return pstrncpy(tcc_malloc(q - p + 1), p, q - p); } +static char *concat_linker_arg_path(char *opath, const char *p) +{ + size_t plen, ol; + char *npath, *pbuf; + + pbuf = copy_linker_arg(p); + + if (opath != NULL) { + ol = strlen(opath); + plen = strlen(pbuf) +1; + npath = tcc_malloc(ol + 1 + plen); + + memcpy(npath, opath, ol); + tcc_free(opath); + + npath[ol++] = ':'; + memcpy(&npath[ol], pbuf, plen); + tcc_free(pbuf); + } else + npath = pbuf; + return npath; +} + /* set linker options */ static int tcc_set_linker(TCCState *s, const char *option) { @@ -1880,7 +1903,7 @@ static int tcc_set_linker(TCCState *s, const char *option) } else if (link_option(option, "O", &p)) { ignoring = 1; } else if (link_option(option, "rpath=", &p)) { - s->rpath = copy_linker_arg(p); + s->rpath = concat_linker_arg_path(s->rpath, p); } else if (link_option(option, "section-alignment=", &p)) { s->section_align = strtoul(p, &end, 16); } else if (link_option(option, "soname=", &p)) {