firasuke / cross / slibtool

Forked from cross/slibtool 6 months ago
Clone

e9dbdf link mode: executable wrapper: added --mode=execute backend support.

Authored and Committed by midipix 8 years ago
    link mode: executable wrapper: added --mode=execute backend support.
    
        
file modified
+12 -0
src/logic/slbt_exec_link.c CHANGED
@@ -798,6 +798,7 @@ static int slbt_exec_link_create_executable(
798
798
const char * exefilename)
799
799
{
800
800
char ** parg;
801
+ char * base;
801
802
char cwd [PATH_MAX];
802
803
char output [PATH_MAX];
803
804
char wrapper[PATH_MAX];
@@ -888,15 +889,26 @@ static int slbt_exec_link_create_executable(
888
889
ectx->argv = depsmeta.altv;
889
890
ectx->program = depsmeta.altv[0];
890
891
892
+ /* executable wrapper: base name */
893
+ if ((base = strrchr(dctx->cctx->output,'/')))
894
+ base++;
895
+ else
896
+ base = wrapper;
897
+
891
898
/* executable wrapper: footer */
892
899
fabspath = (exefilename[0] == '/');
893
900
894
901
if (fprintf(ectx->fwrapper,
895
902
"DL_PATH=\"$DL_PATH$LCOLON$%s\"\n\n"
896
903
"export %s=$DL_PATH\n\n"
904
+ "if [ `basename \"$0\"` = \"%s.exe.wrapper\" ]; then\n"
905
+ "\tprogram=\"$1\"; shift\n"
906
+ "\texec \"$program\" \"$@\"\n"
907
+ "fi\n\n"
897
908
"exec %s/%s \"$@\"\n",
898
909
dctx->cctx->settings.ldpathenv,
899
910
dctx->cctx->settings.ldpathenv,
911
+ base,
900
912
fabspath ? "" : cwd,
901
913
fabspath ? &exefilename[1] : exefilename) < 0)
902
914
return slbt_exec_link_exit(&depsmeta,-1);