diff options
-rw-r--r-- | src/arbits/slbt_archive_meta.c | 26 | ||||
-rw-r--r-- | src/internal/slibtool_ar_impl.h | 4 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/arbits/slbt_archive_meta.c b/src/arbits/slbt_archive_meta.c index 9a5d542..bf7efb0 100644 --- a/src/arbits/slbt_archive_meta.c +++ b/src/arbits/slbt_archive_meta.c @@ -698,6 +698,32 @@ static int slbt_ar_parse_primary_armap( return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_FLOW_ERROR); } +struct ar_meta_member_info * slbt_archive_member_from_offset( + struct slbt_archive_meta_impl * meta, + off_t offset) +{ + intptr_t l,r,m; + off_t * offsetv; + + l = 0; + r = meta->nentries - 1; + + offsetv = meta->offsetv; + + while (l != r) { + m = (l + r) / 2; + m += (l + 2) % 2; + + if (offsetv[m] > offset) { + r = --m; + } else { + l = m; + } + } + + return (offsetv[l] == offset) ? meta->memberv[l] : 0; +} + int slbt_get_archive_meta( const struct slbt_driver_ctx * dctx, const struct slbt_raw_archive * archive, diff --git a/src/internal/slibtool_ar_impl.h b/src/internal/slibtool_ar_impl.h index 22fe0e3..bdaa3e5 100644 --- a/src/internal/slibtool_ar_impl.h +++ b/src/internal/slibtool_ar_impl.h @@ -30,6 +30,10 @@ struct slbt_archive_meta_impl { struct slbt_archive_meta armeta; }; +struct ar_meta_member_info * slbt_archive_member_from_offset( + struct slbt_archive_meta_impl * meta, + off_t offset); + static inline struct slbt_archive_meta_impl * slbt_archive_meta_ictx(const struct slbt_archive_meta * meta) { uintptr_t addr; |