summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-03-04 23:38:03 +0000
committermidipix <writeonce@midipix.org>2024-03-05 00:15:44 +0000
commite06cc0e4519405cb1d1475045f3acfaeb91226ba (patch)
tree24d425eabf9a812ed2fc24b621d887abf922e084 /src
parenta06474266cbd66d534cd2b3a7736a2961cd62ed3 (diff)
downloadslibtool-e06cc0e4519405cb1d1475045f3acfaeb91226ba.tar.bz2
slibtool-e06cc0e4519405cb1d1475045f3acfaeb91226ba.tar.xz
archiver api: added slbt_ar_get_varchive_ctx() (signature-only virtual archive).
Diffstat (limited to 'src')
-rw-r--r--src/arbits/slbt_archive_merge.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/arbits/slbt_archive_merge.c b/src/arbits/slbt_archive_merge.c
index 82eaed5..dfa8f52 100644
--- a/src/arbits/slbt_archive_merge.c
+++ b/src/arbits/slbt_archive_merge.c
@@ -31,6 +31,9 @@
/* file size format specifier */
#define PPRIU64 "%"PRIu64
+/* dlopen self/force */
+static const char slbt_ar_self_dlunit[] = "@PROGRAM@";
+
struct armap_buffer_32 {
uint32_t moffset;
const char * symname;
@@ -695,3 +698,37 @@ int slbt_ar_merge_archives(
return 0;
}
+
+
+int slbt_ar_get_varchive_ctx(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_archive_ctx ** pctx)
+{
+ struct slbt_archive_ctx * ctx;
+ struct slbt_archive_ctx_impl * ictx;
+ void * base;
+ size_t size;
+
+ size = sizeof(struct ar_raw_signature);
+
+ if (slbt_create_anonymous_archive_ctx(dctx,size,&ctx) < 0)
+ return SLBT_NESTED_ERROR(dctx);
+
+ ictx = slbt_get_archive_ictx(ctx);
+
+ base = ctx->map->map_addr;
+ memcpy(base,ar_signature,size);
+
+ if (slbt_ar_get_archive_meta(dctx,ctx->map,&ictx->meta) < 0) {
+ slbt_ar_free_archive_ctx(ctx);
+ return SLBT_NESTED_ERROR(dctx);
+ }
+
+ ictx->path = slbt_ar_self_dlunit;
+ ictx->actx.meta = ictx->meta;
+ ictx->actx.path = &ictx->path;
+
+ *pctx = ctx;
+
+ return 0;
+}