Allow multiple -rpath linker arguments --- libtcc.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libtcc.c b/libtcc.c index f184502..1956008 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1375,6 +1375,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) { @@ -1422,7 +1445,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)) {