From b5e10411a1c764c7b7f82b8b1ff093df7546d028 Mon Sep 17 00:00:00 2001 From: midipix Date: Feb 26 2024 05:11:57 +0000 Subject: driver: added the --nm switch. --- diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 320a614..4940e9e 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -272,6 +272,7 @@ struct slbt_host_params { const char * flavor; const char * ar; const char * as; + const char * nm; const char * ranlib; const char * windres; const char * dlltool; diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index b3fe43a..c9cbdd6 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -397,6 +397,7 @@ int slbt_lib_get_driver_ctx( const char * cfgmeta_host; const char * cfgmeta_ar; const char * cfgmeta_as; + const char * cfgmeta_nm; const char * cfgmeta_ranlib; const char * cfgmeta_dlltool; @@ -455,6 +456,7 @@ int slbt_lib_get_driver_ctx( cfgmeta_host = 0; cfgmeta_ar = 0; cfgmeta_as = 0; + cfgmeta_nm = 0; cfgmeta_ranlib = 0; cfgmeta_dlltool = 0; @@ -662,6 +664,11 @@ int slbt_lib_get_driver_ctx( cfgmeta_as = cfgexplicit; break; + case TAG_NM: + cctx.host.nm = entry->arg; + cfgmeta_nm = cfgexplicit; + break; + case TAG_RANLIB: cctx.host.ranlib = entry->arg; cfgmeta_ranlib = cfgexplicit; @@ -888,6 +895,9 @@ int slbt_lib_get_driver_ctx( if (ctx->cctx.host.as && !cfgmeta_as) cfgmeta_as = cfglconf; + if (ctx->cctx.host.nm && !cfgmeta_nm) + cfgmeta_nm = cfglconf; + if (ctx->cctx.host.ranlib && !cfgmeta_ranlib) cfgmeta_ranlib = cfglconf; @@ -936,6 +946,7 @@ int slbt_lib_get_driver_ctx( cfgmeta_host, cfgmeta_ar, cfgmeta_as, + cfgmeta_nm, cfgmeta_ranlib, cfgmeta_dlltool)) return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); @@ -944,6 +955,9 @@ int slbt_lib_get_driver_ctx( if (slbt_driver_parse_tool_argv(ctx->cctx.host.ar,&ctx->host.ar_argv) < 0) return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); + if (slbt_driver_parse_tool_argv(ctx->cctx.host.nm,&ctx->host.nm_argv) < 0) + return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); + if (slbt_driver_parse_tool_argv(ctx->cctx.host.ranlib,&ctx->host.ranlib_argv) < 0) return slbt_lib_get_driver_ctx_fail(&ctx->ctx,0); diff --git a/src/host/slbt_host_params.c b/src/host/slbt_host_params.c index e140885..5c862a4 100644 --- a/src/host/slbt_host_params.c +++ b/src/host/slbt_host_params.c @@ -88,6 +88,7 @@ slbt_hidden int slbt_init_host_params( const char * cfgmeta_host, const char * cfgmeta_ar, const char * cfgmeta_as, + const char * cfgmeta_nm, const char * cfgmeta_ranlib, const char * cfgmeta_dlltool) { @@ -340,6 +341,24 @@ slbt_hidden int slbt_init_host_params( host->as = drvhost->as; } + /* nm */ + if (host->nm) + cfgmeta->nm = cfgmeta_nm ? cfgmeta_nm : cfgexplicit; + else { + if (!(drvhost->nm = calloc(1,toollen))) + return -1; + + if (fnative) { + strcpy(drvhost->nm,"nm"); + cfgmeta->nm = cfgnative; + } else { + sprintf(drvhost->nm,"%s-nm",host->host); + cfgmeta->nm = cfghost; + } + + host->nm = drvhost->nm; + } + /* ranlib */ if (host->ranlib) cfgmeta->ranlib = cfgmeta_ranlib ? cfgmeta_ranlib : cfgexplicit; @@ -469,6 +488,9 @@ slbt_hidden void slbt_free_host_params(struct slbt_host_strs * host) if (host->as) free(host->as); + if (host->nm) + free(host->nm); + if (host->ranlib) free(host->ranlib); @@ -483,6 +505,7 @@ slbt_hidden void slbt_free_host_params(struct slbt_host_strs * host) slbt_free_host_tool_argv(host->ar_argv); slbt_free_host_tool_argv(host->as_argv); + slbt_free_host_tool_argv(host->nm_argv); slbt_free_host_tool_argv(host->ranlib_argv); slbt_free_host_tool_argv(host->windres_argv); slbt_free_host_tool_argv(host->dlltool_argv); @@ -534,7 +557,7 @@ int slbt_host_set_althost( &ictx->ctx.ahost, &ictx->ctx.cctx.ahost, &ictx->ctx.cctx.acfgmeta, - 0,0,0,0,0)) { + 0,0,0,0,0,0)) { slbt_free_host_params(&ictx->ctx.ahost); return SLBT_CUSTOM_ERROR(ctx,SLBT_ERR_HOST_INIT); } diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 3b989b5..656c113 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -47,6 +47,7 @@ enum app_tags { TAG_FLAVOR, TAG_AR, TAG_AS, + TAG_NM, TAG_RANLIB, TAG_WINDRES, TAG_DLLTOOL, @@ -114,12 +115,14 @@ struct slbt_host_strs { char * flavor; char * ar; char * as; + char * nm; char * ranlib; char * windres; char * dlltool; char * mdso; char ** ar_argv; char ** as_argv; + char ** nm_argv; char ** ranlib_argv; char ** windres_argv; char ** dlltool_argv; @@ -284,6 +287,7 @@ int slbt_init_host_params( const char * cfgmeta_host, const char * cfgmeta_ar, const char * cfgmeta_as, + const char * cfgmeta_nm, const char * cfgmeta_ranlib, const char * cfgmeta_dlltool); diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c index f6bfd36..b96e4f9 100644 --- a/src/internal/slibtool_lconf_impl.c +++ b/src/internal/slibtool_lconf_impl.c @@ -819,6 +819,19 @@ slbt_hidden int slbt_get_lconf_flags( } + /* nm tool */ + if (!ctx->cctx.host.nm) { + if (slbt_get_lconf_var(confctx,"NM=",0x20,&val) < 0) + return SLBT_CUSTOM_ERROR( + dctx,SLBT_ERR_LCONF_PARSE); + + if (val[0] && !(ctx->host.nm = strdup(val))) + return SLBT_SYSTEM_ERROR(dctx,0); + + ctx->cctx.host.nm = ctx->host.nm; + } + + /* ranlib tool */ if (!ctx->cctx.host.ranlib) { if (slbt_get_lconf_var(confctx,"RANLIB=",0x20,&val) < 0) diff --git a/src/output/slbt_output_info.c b/src/output/slbt_output_info.c index 92106a7..a95324d 100644 --- a/src/output/slbt_output_info.c +++ b/src/output/slbt_output_info.c @@ -65,6 +65,9 @@ int slbt_output_info(const struct slbt_driver_ctx * dctx) if ((len = strlen(cctx->host.as)) > midwidth) midwidth = len; + if ((len = strlen(cctx->host.nm)) > midwidth) + midwidth = len; + if ((len = strlen(cctx->host.ranlib)) > midwidth) midwidth = len; @@ -104,6 +107,9 @@ int slbt_output_info(const struct slbt_driver_ctx * dctx) if (slbt_output_info_line(fdout,"as",cctx->host.as,cctx->cfgmeta.as,midwidth)) return SLBT_SYSTEM_ERROR(dctx,0); + if (slbt_output_info_line(fdout,"nm",cctx->host.nm,cctx->cfgmeta.nm,midwidth)) + return SLBT_SYSTEM_ERROR(dctx,0); + if (slbt_output_info_line(fdout,"ranlib",cctx->host.ranlib,cctx->cfgmeta.ranlib,midwidth)) return SLBT_SYSTEM_ERROR(dctx,0); diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c index 50d46b2..a6cc9b2 100644 --- a/src/skin/slbt_skin_default.c +++ b/src/skin/slbt_skin_default.c @@ -117,6 +117,9 @@ const slbt_hidden struct argv_option slbt_default_options[] = { {"as", 0,TAG_AS,ARGV_OPTARG_REQUIRED,0,0,"", "explicitly specify the assembler to be used (with dlltool)"}, + {"nm", 0,TAG_NM,ARGV_OPTARG_REQUIRED,0,0,"", + "explicitly specify the name mangler to be used"}, + {"ranlib", 0,TAG_RANLIB,ARGV_OPTARG_REQUIRED,0,0,"", "explicitly specify the librarian to be used"},