History

libtcc: support multiple -Wl,-rpath=...'s

grischka committed 9 years ago

Commit ee5425f1 parent 362cafb1 file · +11 −7Browse files

Unified · Split

libtcc.c+11−7
@@ -1310,11 +1310,15 @@ static const char *skip_linker_arg(const char **str) · 1309 unmodified lines
13101310 return s2;
13111311 }
13121312
1313−static char *copy_linker_arg(const char *p)
1313+static void copy_linker_arg(char **pp, const char *s, int sep)
13141314 {
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;
13161320 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);
13181322 }
13191323
13201324 /* set linker options */
@@ -1332,14 +1336,14 @@ static int tcc_set_linker(TCCState *s, const char *option) · 11 unmodified lines
13321336 } else if (link_option(option, "nostdlib", &p)) {
13331337 s->nostdlib = 1;
13341338 } else if (link_option(option, "fini=", &p)) {
1335− s->fini_symbol = copy_linker_arg(p);
1339+ copy_linker_arg(&s->fini_symbol, p, 0);
13361340 ignoring = 1;
13371341 } else if (link_option(option, "image-base=", &p)
13381342 || link_option(option, "Ttext=", &p)) {
13391343 s->text_addr = strtoull(p, &end, 16);
13401344 s->has_text_addr = 1;
13411345 } else if (link_option(option, "init=", &p)) {
1342− s->init_symbol = copy_linker_arg(p);
1346+ copy_linker_arg(&s->init_symbol, p, 0);
13431347 ignoring = 1;
13441348 } else if (link_option(option, "oformat=", &p)) {
13451349 #if defined(TCC_TARGET_PE)
@@ -1364,11 +1368,11 @@ static int tcc_set_linker(TCCState *s, const char *option) · 18 unmodified lines
13641368 } else if (link_option(option, "O", &p)) {
13651369 ignoring = 1;
13661370 } else if (link_option(option, "rpath=", &p)) {
1367− s->rpath = copy_linker_arg(p);
1371+ copy_linker_arg(&s->rpath, p, ':');
13681372 } else if (link_option(option, "section-alignment=", &p)) {
13691373 s->section_align = strtoul(p, &end, 16);
13701374 } else if (link_option(option, "soname=", &p)) {
1371− s->soname = copy_linker_arg(p);
1375+ copy_linker_arg(&s->soname, p, 0);
13721376 #ifdef TCC_TARGET_PE
13731377 } else if (link_option(option, "large-address-aware", &p)) {
13741378 s->pe_characteristics |= 0x20;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t