summaryrefslogtreecommitdiff
path: root/src/logic/slbt_exec_link.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-12-19 10:59:37 -0500
committermidipix <writeonce@midipix.org>2017-12-19 18:50:37 -0500
commit1cecd7cc09807fadf3c6dc1af4d1e67fa9844f77 (patch)
tree979a2f1a1eac6cf0e967dbd795afd1d5366e3ffe /src/logic/slbt_exec_link.c
parentf83f76048d0094921afb0f4f4b0bb5b90e062755 (diff)
downloadslibtool-1cecd7cc09807fadf3c6dc1af4d1e67fa9844f77.tar.bz2
slibtool-1cecd7cc09807fadf3c6dc1af4d1e67fa9844f77.tar.xz
link mode: argument vector ordering: treat {.a|.so} the same way as -lfoo.
Diffstat (limited to 'src/logic/slbt_exec_link.c')
-rw-r--r--src/logic/slbt_exec_link.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 0721aef..2c7beb1 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -498,6 +498,8 @@ static int slbt_exec_link_finalize_argument_vector(
char ** dst;
char ** mark;
char ** cap;
+ int flast;
+ int fwhole;
size_t argc;
size_t first;
size_t last;
@@ -509,40 +511,48 @@ static int slbt_exec_link_finalize_argument_vector(
objidx = 0;
for (parg=ectx->argv; *parg; parg++) {
- arg = *parg;
+ arg = *parg;
+ flast = false;
+ fwhole = false;
- if ((arg[0] == '-') && (arg[1] == 'l')) {
- last = parg - base;
- first = first ? first : last;
+ if ((arg[0] == '-') && (arg[1] == 'l'))
+ flast = true;
+
+ else if ((arg[0] == '-') && (arg[1] == 'L'))
+ flast = true;
+
+ else if ((dot = strrchr(arg,'.')))
+ flast = !strcmp(dot,dctx->cctx->settings.arsuffix)
+ || !strcmp(dot,dctx->cctx->settings.dsosuffix)
+ || !strcmp(dot,dctx->cctx->settings.impsuffix);
+
+ else if ((arg[0] == '-')
+ && (arg[1] == 'W')
+ && (arg[2] == 'l')
+ && (arg[3] == ','))
+ fwhole = (!strcmp(&arg[4],"--whole-archive"))
+ && parg[1] && parg[2]
+ && !strcmp(parg[2],"-Wl,--no-whole-archive")
+ && (dot = strrchr(parg[1],'.'))
+ && !strcmp(dot,dctx->cctx->settings.arsuffix);
+
+
+ if (fwhole) {
+ parg = &parg[2];
+ flast = true;
+ objidx = parg - base;
+ }
- } else if ((arg[0] == '-') && (arg[1] == 'L')) {
+
+ if (flast) {
last = parg - base;
first = first ? first : last;
} else if (objidx) {
(void)0;
- } else if ((dot = strrchr(arg,'.'))) {
- if (!strcmp(dot,".o")
- || !strcmp(dot,".lo")
- || !strcmp(dot,dctx->cctx->settings.arsuffix)
- || !strcmp(dot,dctx->cctx->settings.dsosuffix)
- || !strcmp(dot,dctx->cctx->settings.impsuffix))
- objidx = parg - base;
- } else if ((arg[0] == '-')
- && (arg[1] == 'W')
- && (arg[2] == 'l')
- && (arg[3] == ',')) {
- if ((!strcmp(&arg[4],"--whole-archive"))
- && parg[1] && parg[2]
- && !strcmp(parg[2],"-Wl,--no-whole-archive")
- && (dot = strrchr(parg[1],'.'))
- && !strcmp(dot,dctx->cctx->settings.arsuffix)) {
+ } else if (dot && (!strcmp(dot,".o") || !strcmp(dot,".lo"))) {
objidx = parg - base;
- } else {
- last = parg - base;
- first = first ? first : last;
- }
}
}