Unified · Split
| @@ -1310,11 +1310,15 @@ static const char *skip_linker_arg(const char **str) · 1309 unmodified lines | ||
| 1310 | 1310 | return s2; |
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | −static char *copy_linker_arg(const char *p) | |
| 1313 | +static void copy_linker_arg(char **pp, const char *s, int sep) | |
| 1314 | 1314 | { |
| 1315 | − const char *q = p; | |
| 1315 | + const char *q = s; | |
| 1316 | + char *p = *pp; | |
| 1317 | + int l = 0; | |
| 1318 | + if (p && sep) | |
| 1319 | + p[l = strlen(p)] = sep, ++l; | |
| 1316 | 1320 | skip_linker_arg(&q); |
| 1317 | − return pstrncpy(tcc_malloc(q - p + 1), p, q - p); | |
| 1321 | + pstrncpy(l + (*pp = tcc_realloc(p, q - s + l + 1)), s, q - s); | |
| 1318 | 1322 | } |
| 1319 | 1323 | |
| 1320 | 1324 | /* set linker options */ |
| @@ -1332,14 +1336,14 @@ static int tcc_set_linker(TCCState *s, const char *option) · 11 unmodified lines | ||
| 1332 | 1336 | } else if (link_option(option, "nostdlib", &p)) { |
| 1333 | 1337 | s->nostdlib = 1; |
| 1334 | 1338 | } else if (link_option(option, "fini=", &p)) { |
| 1335 | − s->fini_symbol = copy_linker_arg(p); | |
| 1339 | + copy_linker_arg(&s->fini_symbol, p, 0); | |
| 1336 | 1340 | ignoring = 1; |
| 1337 | 1341 | } else if (link_option(option, "image-base=", &p) |
| 1338 | 1342 | || link_option(option, "Ttext=", &p)) { |
| 1339 | 1343 | s->text_addr = strtoull(p, &end, 16); |
| 1340 | 1344 | s->has_text_addr = 1; |
| 1341 | 1345 | } else if (link_option(option, "init=", &p)) { |
| 1342 | − s->init_symbol = copy_linker_arg(p); | |
| 1346 | + copy_linker_arg(&s->init_symbol, p, 0); | |
| 1343 | 1347 | ignoring = 1; |
| 1344 | 1348 | } else if (link_option(option, "oformat=", &p)) { |
| 1345 | 1349 | #if defined(TCC_TARGET_PE) |
| @@ -1364,11 +1368,11 @@ static int tcc_set_linker(TCCState *s, const char *option) · 18 unmodified lines | ||
| 1364 | 1368 | } else if (link_option(option, "O", &p)) { |
| 1365 | 1369 | ignoring = 1; |
| 1366 | 1370 | } else if (link_option(option, "rpath=", &p)) { |
| 1367 | − s->rpath = copy_linker_arg(p); | |
| 1371 | + copy_linker_arg(&s->rpath, p, ':'); | |
| 1368 | 1372 | } else if (link_option(option, "section-alignment=", &p)) { |
| 1369 | 1373 | s->section_align = strtoul(p, &end, 16); |
| 1370 | 1374 | } else if (link_option(option, "soname=", &p)) { |
| 1371 | − s->soname = copy_linker_arg(p); | |
| 1375 | + copy_linker_arg(&s->soname, p, 0); | |
| 1372 | 1376 | #ifdef TCC_TARGET_PE |
| 1373 | 1377 | } else if (link_option(option, "large-address-aware", &p)) { |
| 1374 | 1378 | s->pe_characteristics |= 0x20; |