summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-05-11 20:59:04 +0000
committermidipix <writeonce@midipix.org>2021-05-11 22:53:19 +0000
commit70949a39b9587465f5ab1d7930d1d100bc4485a0 (patch)
tree653df3dc598b43cabfbb464ac34f40497d6f541a /src/logic
parenta7dc81851ba2af566ce6d99579375f9b073587af (diff)
downloadslibtool-70949a39b9587465f5ab1d7930d1d100bc4485a0.tar.bz2
slibtool-70949a39b9587465f5ab1d7930d1d100bc4485a0.tar.xz
link mode: slbt_exec_link_create_executable(): place .exe.wrapper under .libs/.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/slbt_exec_execute.c19
-rw-r--r--src/logic/slbt_exec_install.c14
-rw-r--r--src/logic/slbt_exec_link.c10
3 files changed, 24 insertions, 19 deletions
diff --git a/src/logic/slbt_exec_execute.c b/src/logic/slbt_exec_execute.c
index b397306..9966e4d 100644
--- a/src/logic/slbt_exec_execute.c
+++ b/src/logic/slbt_exec_execute.c
@@ -49,16 +49,6 @@ int slbt_exec_execute(
script = ectx->cargv[1];
if (script) {
- /* wrapper */
- if ((size_t)snprintf(wrapper,sizeof(wrapper),
- "%s%s.exe.wrapper",
- (script[0] == '/') ? "" : "./",
- script)
- >= sizeof(wrapper)) {
- slbt_free_exec_ctx(actx);
- return SLBT_BUFFER_ERROR(dctx);
- }
-
/* exeref */
if ((base = strrchr(script,'/')))
base++;
@@ -69,6 +59,15 @@ int slbt_exec_execute(
mark = exeref + (base - script);
sprintf(mark,".libs/%s",base);
+ /* wrapper */
+ if ((size_t)snprintf(wrapper,sizeof(wrapper),
+ "%s.exe.wrapper",
+ exeref)
+ >= sizeof(wrapper)) {
+ slbt_free_exec_ctx(actx);
+ return SLBT_BUFFER_ERROR(dctx);
+ }
+
/* fdcwd */
fdcwd = slbt_driver_fdcwd(dctx);
diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c
index 072c301..fc401e5 100644
--- a/src/logic/slbt_exec_install.c
+++ b/src/logic/slbt_exec_install.c
@@ -326,8 +326,8 @@ static int slbt_exec_install_entry(
{
int ret;
int fdcwd;
+ const char * base;
char * dot;
- char * base;
char * host;
char * mark;
char * slash;
@@ -352,8 +352,16 @@ static int slbt_exec_install_entry(
struct stat st;
/* executable wrapper? */
- if ((size_t)snprintf(slnkname,sizeof(slnkname),"%s.exe.wrapper",
- entry->arg) >= sizeof(slnkname))
+ base = (slash = strrchr(entry->arg,'/'))
+ ? ++slash : entry->arg;
+
+ strcpy(slnkname,entry->arg);
+ mark = &slnkname[base - entry->arg];
+ slen = sizeof(slnkname) - (mark - slnkname);
+
+ if ((size_t)snprintf(mark,slen,
+ ".libs/%s.exe.wrapper",
+ base) >= slen)
return SLBT_BUFFER_ERROR(dctx);
/* fdcwd */
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index e11f0b7..e07a5e0 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -1698,16 +1698,14 @@ static int slbt_exec_link_create_executable(
/* executable wrapper symlink */
if ((size_t)snprintf(wraplnk,sizeof(wraplnk),"%s.exe.wrapper",
- dctx->cctx->output) >= sizeof(wraplnk))
+ exefilename) >= sizeof(wraplnk))
return slbt_exec_link_exit(
&depsmeta,
SLBT_BUFFER_ERROR(dctx));
/* executable wrapper: base name */
- if ((base = strrchr(wraplnk,'/')))
- base++;
- else
- base = wraplnk;
+ base = strrchr(wraplnk,'/');
+ base++;
/* executable wrapper: footer */
fabspath = (exefilename[0] == '/');
@@ -1752,7 +1750,7 @@ static int slbt_exec_link_create_executable(
if (slbt_create_symlink(
dctx,ectx,
dctx->cctx->output,wraplnk,
- SLBT_SYMLINK_DEFAULT))
+ SLBT_SYMLINK_WRAPPER))
return slbt_exec_link_exit(
&depsmeta,
SLBT_NESTED_ERROR(dctx));