Hello again,

a tcc(1) compiled on June 6th as well as one of [mob:3054a76] (as
well as one of [master], accidentally) fails to fail on the
attached file.

Ciao!

P.S.: any chance that the -rpath patch is committed?  I'll attach
it, too.

--steffen
enum{ a_0, a_1, a255 };
int
main(int argc, char **argv){
	switch(argc){
	a_0: return 0;
	a_1: return 1;
	a_255: return 255;
	}
}
    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)) {
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to