diff options
author | midipix <writeonce@midipix.org> | 2024-02-21 01:17:11 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-02-21 03:24:48 +0000 |
commit | f420747a94d043196cc10c98eaa89c6a3b1e6cc6 (patch) | |
tree | eac8f1ad553132a3495d6503f868f9738066e7c4 | |
parent | 98dca8dc6c2494f4120db435328a81fbc1becf4e (diff) | |
download | slibtool-f420747a94d043196cc10c98eaa89c6a3b1e6cc6.tar.bz2 slibtool-f420747a94d043196cc10c98eaa89c6a3b1e6cc6.tar.xz |
execution context: added support for -export-symbols.
-rw-r--r-- | include/slibtool/slibtool.h | 4 | ||||
-rw-r--r-- | src/internal/slibtool_driver_impl.h | 3 | ||||
-rw-r--r-- | src/logic/slbt_exec_ctx.c | 36 |
3 files changed, 38 insertions, 5 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 4185cb2..a3525b6 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -207,6 +207,9 @@ struct slbt_exec_ctx { char ** symdefs; char ** symfile; + char ** explarg; + char ** expsyms; + char ** lout[2]; char ** mout[2]; char ** rpath[2]; @@ -232,6 +235,7 @@ struct slbt_exec_ctx { char * relfilename; char * dsorellnkname; char * deffilename; + char * mapfilename; char * rpathfilename; char * dimpfilename; diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 6bbd5d0..c325134 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -167,12 +167,13 @@ struct slbt_driver_ctx_alloc { struct slbt_exec_ctx_impl { const struct slbt_driver_ctx * dctx; + struct slbt_symlist_ctx * sctx; + struct slbt_exec_ctx ctx; int argc; char * args; char * shadow; char * dsoprefix; size_t size; - struct slbt_exec_ctx ctx; int fdwrapper; char ** lout[2]; char ** mout[2]; diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c index 0e02c23..4667691 100644 --- a/src/logic/slbt_exec_ctx.c +++ b/src/logic/slbt_exec_ctx.c @@ -104,12 +104,12 @@ static struct slbt_exec_ctx_impl * slbt_exec_ctx_alloc( /* buffer size (ldirname, lbasename, lobjname, aobjname, etc.) */ if (dctx->cctx->output) - size += 9*strlen(dctx->cctx->output); + size += 10*strlen(dctx->cctx->output); else if ((csrc = slbt_source_file(dctx->cctx->cargv))) - size += 9*strlen(csrc); + size += 10*strlen(csrc); /* pessimistic: long dso suffix, long x.y.z version */ - size += 9 * (16 + 16 + 16 + 16); + size += 10 * (16 + 16 + 16 + 16); /* pessimistic argc: .libs/libfoo.so --> -L.libs -lfoo */ argc *= 2; @@ -122,6 +122,7 @@ static struct slbt_exec_ctx_impl * slbt_exec_ctx_alloc( if (dctx->cctx->mode == SLBT_MODE_LINK) size += strlen(dctx->cctx->settings.arprefix) + 1 + strlen(dctx->cctx->settings.arsuffix) + 1 + + strlen(dctx->cctx->settings.mapsuffix) + 1 + strlen(dctx->cctx->settings.dsoprefix) + 1 + strlen(dctx->cctx->settings.dsoprefix) + 1 + strlen(dctx->cctx->settings.dsoprefix) + 1 @@ -293,6 +294,8 @@ int slbt_ectx_get_exec_ctx( ictx->ctx.lsoname = &ictx->ctx.argv[i++]; ictx->ctx.symdefs = &ictx->ctx.argv[i++]; ictx->ctx.symfile = &ictx->ctx.argv[i++]; + ictx->ctx.explarg = &ictx->ctx.argv[i++]; + ictx->ctx.expsyms = &ictx->ctx.argv[i++]; ictx->ctx.lout[0] = &ictx->ctx.argv[i++]; ictx->ctx.lout[1] = &ictx->ctx.argv[i++]; @@ -338,7 +341,7 @@ int slbt_ectx_get_exec_ctx( + 1; } - /* linking: arfilename, lafilename, laifilename, dsobasename, dsofilename */ + /* linking: arfilename, lafilename, laifilename, dsobasename, dsofilename, mapfilename */ if (dctx->cctx->mode == SLBT_MODE_LINK && dctx->cctx->libname) { /* arprefix, dsoprefix */ if (dctx->cctx->drvflags & SLBT_DRIVER_MODULE) { @@ -399,6 +402,17 @@ int slbt_ectx_get_exec_ctx( dctx->cctx->settings.dsosuffix); ch++; + /* mapfilename */ + ictx->ctx.mapfilename = ch; + ch += sprintf(ch,"%s%s%s%s%s%s", + ictx->ctx.ldirname, + dsoprefix, + dctx->cctx->libname, + dctx->cctx->release ? "-" : "", + dctx->cctx->release ? dctx->cctx->release : "", + dctx->cctx->settings.mapsuffix); + ch++; + /* deffilename */ ictx->ctx.deffilename = ch; ch += sprintf(ch,"%s%s%s%s%s%s.def", @@ -504,6 +518,13 @@ int slbt_ectx_get_exec_ctx( ch += sprintf(ch,".libs/%s",dctx->cctx->output) + 1; } + /* vector of exported symbols (raw input via -export-symbols) */ + if (dctx->cctx->expsyms) + if (slbt_lib_get_symlist_ctx( + dctx,dctx->cctx->expsyms, + &ictx->sctx) < 0) + return SLBT_NESTED_ERROR(dctx); + /* argument strings shadow copy */ memcpy(ictx->shadow,ictx->args,ictx->size); @@ -529,6 +550,9 @@ static int slbt_ectx_free_exec_ctx_impl( struct slbt_exec_ctx_impl * ictx, int status) { + if (ictx->sctx) + slbt_lib_free_symlist_ctx(ictx->sctx); + if (ictx->fdwrapper >= 0) close(ictx->fdwrapper); @@ -598,6 +622,8 @@ slbt_hidden void slbt_reset_placeholders(struct slbt_exec_ctx * ectx) *ectx->lsoname = "-USLIBTOOL_PLACEHOLDER_LSONAME"; *ectx->symdefs = "-USLIBTOOL_PLACEHOLDER_SYMDEF_SWITCH"; *ectx->symfile = "-USLIBTOOL_PLACEHOLDER_SYMDEF_FILE"; + *ectx->explarg = "-USLIBTOOL_PLACEHOLDER_EXPSYMS_SWITCH"; + *ectx->expsyms = "-USLIBTOOL_PLACEHOLDER_EXPSYMS_FILE"; *ectx->lout[0] = "-USLIBTOOL_PLACEHOLDER_OUTPUT_SWITCH"; *ectx->lout[1] = "-USLIBTOOL_PLACEHOLDER_OUTPUT_FILE"; @@ -622,6 +648,8 @@ slbt_hidden void slbt_disable_placeholders(struct slbt_exec_ctx * ectx) *ectx->lsoname = 0; *ectx->symdefs = 0; *ectx->symfile = 0; + *ectx->explarg = 0; + *ectx->expsyms = 0; *ectx->lout[0] = 0; *ectx->lout[1] = 0; |