diff options
author | midipix <writeonce@midipix.org> | 2024-03-03 21:49:15 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-03-04 03:28:57 +0000 |
commit | 93e38b3566a587e0aec3c46de85abf28f82614ac (patch) | |
tree | 3a77ce8c94a2f6fffc1606def23b88a859e42c9b /src/logic/linkcmd | |
parent | a3e2d3ae686409f59f7470ae1898f96e1c9df453 (diff) | |
download | slibtool-93e38b3566a587e0aec3c46de85abf28f82614ac.tar.bz2 slibtool-93e38b3566a587e0aec3c46de85abf28f82614ac.tar.xz |
link mode: unless created for the current .la, mark the .a or .so as disabled.
Diffstat (limited to 'src/logic/linkcmd')
-rw-r--r-- | src/logic/linkcmd/slbt_linkcmd_archive.c | 19 | ||||
-rw-r--r-- | src/logic/linkcmd/slbt_linkcmd_dsolib.c | 32 |
2 files changed, 46 insertions, 5 deletions
diff --git a/src/logic/linkcmd/slbt_linkcmd_archive.c b/src/logic/linkcmd/slbt_linkcmd_archive.c index a8002fb..9b002f6 100644 --- a/src/logic/linkcmd/slbt_linkcmd_archive.c +++ b/src/logic/linkcmd/slbt_linkcmd_archive.c @@ -57,17 +57,26 @@ static int slbt_exec_link_remove_file( const char * target) { int fdcwd; - - (void)ectx; + char * mark; + char * sbuf; /* fdcwd */ fdcwd = slbt_driver_fdcwd(dctx); /* remove target (if any) */ - if (!unlinkat(fdcwd,target,0) || (errno == ENOENT)) - return 0; + if (unlinkat(fdcwd,target,0) && (errno != ENOENT)) + return SLBT_SYSTEM_ERROR(dctx,0); + + /* remove a previous .disabled placeholder */ + sbuf = (slbt_get_exec_ictx(ectx))->sbuf; + mark = sbuf; + mark += sprintf(mark,"%s",target); + strcpy(mark,".disabled"); - return SLBT_SYSTEM_ERROR(dctx,0); + if (unlinkat(fdcwd,sbuf,0) && (errno != ENOENT)) + return SLBT_SYSTEM_ERROR(dctx,0); + + return 0; } slbt_hidden int slbt_exec_link_create_archive( diff --git a/src/logic/linkcmd/slbt_linkcmd_dsolib.c b/src/logic/linkcmd/slbt_linkcmd_dsolib.c index dd5bf64..b740a00 100644 --- a/src/logic/linkcmd/slbt_linkcmd_dsolib.c +++ b/src/logic/linkcmd/slbt_linkcmd_dsolib.c @@ -55,6 +55,34 @@ static int slbt_exec_link_remove_file( return SLBT_SYSTEM_ERROR(dctx,0); } +static int slbt_exec_link_remove_dso_files( + const struct slbt_driver_ctx * dctx, + struct slbt_exec_ctx * ectx, + const char * target) +{ + int fdcwd; + char * mark; + char * sbuf; + + /* fdcwd */ + fdcwd = slbt_driver_fdcwd(dctx); + + /* remove target (if any) */ + if (unlinkat(fdcwd,target,0) && (errno != ENOENT)) + return SLBT_SYSTEM_ERROR(dctx,0); + + /* remove a previous .disabled placeholder */ + sbuf = (slbt_get_exec_ictx(ectx))->sbuf; + mark = sbuf; + mark += sprintf(mark,"%s",target); + strcpy(mark,".disabled"); + + if (unlinkat(fdcwd,sbuf,0) && (errno != ENOENT)) + return SLBT_SYSTEM_ERROR(dctx,0); + + return 0; +} + slbt_hidden int slbt_exec_link_create_library( const struct slbt_driver_ctx * dctx, struct slbt_exec_ctx * ectx, @@ -85,6 +113,10 @@ slbt_hidden int slbt_exec_link_create_library( /* fdcwd */ fdcwd = slbt_driver_fdcwd(dctx); + /* remove previous libfoo.so, libfoo.so.disabled */ + if (slbt_exec_link_remove_dso_files(dctx,ectx,ectx->dsofilename) < 0) + return SLBT_NESTED_ERROR(dctx); + /* input argument adjustment */ for (parg=ectx->cargv; *parg; parg++) slbt_adjust_object_argument(*parg,true,false,fdcwd); |