From e06cc0e4519405cb1d1475045f3acfaeb91226ba Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 4 Mar 2024 23:38:03 +0000 Subject: archiver api: added slbt_ar_get_varchive_ctx() (signature-only virtual archive). --- src/arbits/slbt_archive_merge.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src') 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; +} -- cgit v1.2.3