summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-26 01:40:46 +0000
committermidipix <writeonce@midipix.org>2024-02-26 01:40:46 +0000
commita2aa784db35ca08cc5a7e65de1831cd53fb52346 (patch)
tree746f75dfcd519dd6165918838618d37f30b0e07d /src
parent3d2f83b5a3d42dd9b3430379a08a81f8004c7eb4 (diff)
downloadslibtool-a2aa784db35ca08cc5a7e65de1831cd53fb52346.tar.bz2
slibtool-a2aa784db35ca08cc5a7e65de1831cd53fb52346.tar.xz
slbt_get_lconf_flags(): cache the configuration in library friendly form.
Diffstat (limited to 'src')
-rw-r--r--src/driver/slbt_driver_ctx.c3
-rw-r--r--src/internal/slibtool_driver_impl.h1
-rw-r--r--src/internal/slibtool_lconf_impl.c48
3 files changed, 35 insertions, 17 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index a94b352..b3fe43a 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -1001,6 +1001,9 @@ static void slbt_lib_free_driver_ctx_impl(struct slbt_driver_ctx_alloc * ictx)
ictx->ctx.lconf.addr,
ictx->ctx.lconf.size);
+ if (ictx->ctx.lconfctx)
+ slbt_lib_free_txtfile_ctx(ictx->ctx.lconfctx);
+
for (objlistp=ictx->ctx.objlistv; objlistp->name; objlistp++) {
free(objlistp->objv);
free(objlistp->addr);
diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h
index b6ab601..3b989b5 100644
--- a/src/internal/slibtool_driver_impl.h
+++ b/src/internal/slibtool_driver_impl.h
@@ -142,6 +142,7 @@ struct slbt_driver_ctx_impl {
struct slbt_host_strs ahost;
struct slbt_fd_ctx fdctx;
struct slbt_map_info lconf;
+ struct slbt_txtfile_ctx * lconfctx;
struct slbt_obj_list * objlistv;
const struct slbt_archive_ctx * arctx;
diff --git a/src/internal/slibtool_lconf_impl.c b/src/internal/slibtool_lconf_impl.c
index 9addd0a..c526bad 100644
--- a/src/internal/slibtool_lconf_impl.c
+++ b/src/internal/slibtool_lconf_impl.c
@@ -366,13 +366,21 @@ static int slbt_lconf_trace_result_silent(
int fd,
int fdat,
const char * lconf,
- int err)
+ int err,
+ char (*pathbuf)[PATH_MAX])
{
(void)dctx;
(void)fd;
(void)fdat;
(void)lconf;
- return err ? (-1) : fd;
+
+ if (err)
+ return -1;
+
+ if (slbt_realpath(fdat,lconf,0,*pathbuf,sizeof(*pathbuf)) <0)
+ return -1;
+
+ return fd;
}
static int slbt_lconf_trace_result_plain(
@@ -380,16 +388,16 @@ static int slbt_lconf_trace_result_plain(
int fd,
int fdat,
const char * lconf,
- int err)
+ int err,
+ char (*pathbuf)[PATH_MAX])
{
int fderr;
const char * cpath;
- char path[PATH_MAX];
fderr = slbt_driver_fderr(dctx);
- cpath = !(slbt_realpath(fdat,lconf,0,path,sizeof(path)))
- ? path : lconf;
+ cpath = !(slbt_realpath(fdat,lconf,0,*pathbuf,sizeof(*pathbuf)))
+ ? *pathbuf : lconf;
switch (err) {
case 0:
@@ -428,16 +436,16 @@ static int slbt_lconf_trace_result_annotated(
int fd,
int fdat,
const char * lconf,
- int err)
+ int err,
+ char (*pathbuf)[PATH_MAX])
{
int fderr;
const char * cpath;
- char path[PATH_MAX];
fderr = slbt_driver_fderr(dctx);
- cpath = !(slbt_realpath(fdat,lconf,0,path,sizeof(path)))
- ? path : lconf;
+ cpath = !(slbt_realpath(fdat,lconf,0,*pathbuf,sizeof(*pathbuf)))
+ ? *pathbuf : lconf;
switch (err) {
case 0:
@@ -506,7 +514,8 @@ static int slbt_lconf_trace_result_annotated(
static int slbt_lconf_open(
struct slbt_driver_ctx * dctx,
- const char * lconf)
+ const char * lconf,
+ char (*lconfpath)[PATH_MAX])
{
int fderr;
int fdcwd;
@@ -527,7 +536,8 @@ static int slbt_lconf_open(
int,const char *,int,int);
int (*trace_result)(struct slbt_driver_ctx *,
- int,int,const char *,int);
+ int,int,const char *,int,
+ char (*)[PATH_MAX]);
lconf = lconf ? lconf : "libtool";
fderr = slbt_driver_fderr(dctx);
@@ -573,7 +583,7 @@ static int slbt_lconf_open(
if (lconf && strchr(lconf,'/'))
return ((fdlconf = trace_openat(dctx,fdcwd,lconf,O_RDONLY,0)) < 0)
? SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_LCONF_OPEN)
- : trace_result(dctx,fdlconf,fdcwd,lconf,0);
+ : trace_result(dctx,fdlconf,fdcwd,lconf,0,lconfpath);
if (trace_fstat(dctx,fdlconfdir,".",&stcwd) < 0)
return SLBT_SYSTEM_ERROR(dctx,0);
@@ -594,14 +604,14 @@ static int slbt_lconf_open(
}
if (stparent.st_dev != stcwd.st_dev) {
- trace_result(dctx,fdparent,fdparent,".",EXDEV);
+ trace_result(dctx,fdparent,fdparent,".",EXDEV,lconfpath);
close(fdparent);
return SLBT_CUSTOM_ERROR(
dctx,SLBT_ERR_LCONF_OPEN);
}
if (stparent.st_ino == stinode) {
- trace_result(dctx,fdparent,fdparent,".",ELOOP);
+ trace_result(dctx,fdparent,fdparent,".",ELOOP,lconfpath);
close(fdparent);
return SLBT_CUSTOM_ERROR(
dctx,SLBT_ERR_LCONF_OPEN);
@@ -612,7 +622,7 @@ static int slbt_lconf_open(
stinode = stparent.st_ino;
}
- trace_result(dctx,fdlconf,fdlconfdir,lconf,0);
+ trace_result(dctx,fdlconf,fdlconfdir,lconf,0,lconfpath);
slbt_lconf_close(fdcwd,fdlconfdir);
@@ -730,7 +740,11 @@ slbt_hidden int slbt_get_lconf_flags(
ctx = slbt_get_driver_ictx(dctx);
/* open relative libtool script */
- if ((fdlconf = slbt_lconf_open(dctx,lconf)) < 0)
+ if ((fdlconf = slbt_lconf_open(dctx,lconf,&val)) < 0)
+ return SLBT_NESTED_ERROR(dctx);
+
+ /* cache the configuration in library friendly form) */
+ if (slbt_lib_get_txtfile_ctx(dctx,val,&ctx->lconfctx) < 0)
return SLBT_NESTED_ERROR(dctx);
/* map relative libtool script */