Blame src/internal/perk_ar_impl.h

906422
/***************************************************************/
906422
/*  perk: PE Resource Kit                                      */
906422
/*  Copyright (C) 2015--2025  SysDeer Technologies, LLC        */
906422
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
906422
/***************************************************************/
906422
906422
#ifndef SLIBTOOL_AR_IMPL_H
906422
#define SLIBTOOL_AR_IMPL_H
906422
906422
#include "argv/argv.h"
906422
#include <perk/perk.h>
906422
#include <perk/perk_arbits.h>
906422
906422
/* decimal values in archive header are right padded with ascii spaces */
906422
#define AR_DEC_PADDING (0x20)
906422
906422
/* archive file members are right padded as needed with ascii newline */
906422
#define AR_OBJ_PADDING (0x0A)
906422
906422
/* initial number of elements in the transient, on-stack vector */
906422
# define AR_STACK_VECTOR_ELEMENTS   (0x200)
906422
c5c707
/* bit mask to indicate that the first non-option argument is <posname> */
c5c707
#define AR_POSNAME_MASK   (PERK_DRIVER_AR_POSITION_AFTER \
c5c707
	                  |PERK_DRIVER_AR_POSITION_BEFORE)
c5c707
663098
#define AR_UPDATE_MASK    (PERK_DRIVER_AR_UPDATE_MEMBERS \
663098
	                  |PERK_DRIVER_AR_REPLACE_MEMBERS)
663098
663098
#define AR_ACTION_MASK    (PERK_DRIVER_AR_LIST_MEMBERS  \
663098
	                  |PERK_DRIVER_AR_MOVE_MEMBERS   \
663098
	                  |PERK_DRIVER_AR_UPDATE_MEMBERS  \
663098
	                  |PERK_DRIVER_AR_DELETE_MEMBERS  \
663098
	                  |PERK_DRIVER_AR_APPEND_MEMBERS  \
663098
	                  |PERK_DRIVER_AR_REPLACE_MEMBERS \
663098
	                  |PERK_DRIVER_AR_EXTRACT_MEMBERS \
8ba1bc
	                  |PERK_DRIVER_AR_PRINT_MEMBERS)
663098
906422
extern const struct argv_option pe_ar_options[];
906422
906422
struct ar_armaps_impl {
906422
	struct ar_meta_armap_ref_32 *   armap_symrefs_32;
906422
	struct ar_meta_armap_ref_64 *   armap_symrefs_64;
906422
	struct ar_raw_armap_bsd_32      armap_bsd_32;
906422
	struct ar_raw_armap_bsd_64      armap_bsd_64;
906422
	struct ar_raw_armap_sysv_32     armap_sysv_32;
906422
	struct ar_raw_armap_sysv_64     armap_sysv_64;
906422
	struct ar_meta_armap_common_32  armap_common_32;
906422
	struct ar_meta_armap_common_64  armap_common_64;
906422
	uint64_t                        armap_nsyms;
906422
};
906422
906422
struct pe_archive_meta_impl {
4a0ccb
	const struct pe_driver_ctx *    dctx;
4a0ccb
	struct pe_archive_ctx *         actx;
906422
	size_t                          ofmtattr;
906422
	size_t                          nentries;
906422
	void *                          hdrinfov;
906422
	char *                          namestrs;
906422
	const char *                    symstrs;
906422
	const char **                   symstrv;
906422
	const char **                   mapstrv;
906422
	off_t *                         offsetv;
906422
	struct ar_meta_symbol_info *    syminfo;
906422
	struct ar_meta_symbol_info **   syminfv;
906422
	struct ar_meta_member_info **   memberv;
906422
	struct ar_meta_member_info *    members;
906422
	struct ar_armaps_impl           armaps;
4a0ccb
	struct pe_txtfile_ctx *         nminfo;
4a0ccb
	struct pe_archive_meta          armeta;
906422
};
906422
906422
struct ar_meta_member_info * pe_archive_member_from_offset(
4a0ccb
	struct pe_archive_meta_impl *   meta,
906422
	off_t                           offset);
906422
906422
int pe_ar_parse_primary_armap_bsd_32(
4a0ccb
	const struct pe_driver_ctx *    dctx,
4a0ccb
	struct pe_archive_meta_impl *   m);
906422
906422
int pe_ar_parse_primary_armap_bsd_64(
4a0ccb
	const struct pe_driver_ctx *    dctx,
4a0ccb
	struct pe_archive_meta_impl *   m);
906422
906422
int pe_ar_parse_primary_armap_sysv_32(
4a0ccb
	const struct pe_driver_ctx *    dctx,
4a0ccb
	struct pe_archive_meta_impl *   m);
906422
906422
int pe_ar_parse_primary_armap_sysv_64(
4a0ccb
	const struct pe_driver_ctx *    dctx,
4a0ccb
	struct pe_archive_meta_impl *   m);
906422
906422
int pe_update_mapstrv(
4a0ccb
	const struct pe_driver_ctx *    dctx,
4a0ccb
	struct pe_archive_meta_impl *   m);
906422
906422
int pe_ar_update_syminfo(
4a0ccb
	struct pe_archive_ctx *         actx);
906422
906422
int pe_ar_update_syminfo_ex(
4a0ccb
	struct pe_archive_ctx *         actx,
4a0ccb
	int                             fdout);
906422
906422
static inline struct pe_archive_meta_impl * pe_archive_meta_ictx(const struct pe_archive_meta * meta)
906422
{
906422
	uintptr_t addr;
906422
906422
	if (meta) {
906422
		addr = (uintptr_t)meta - offsetof(struct pe_archive_meta_impl,armeta);
906422
		return (struct pe_archive_meta_impl *)addr;
906422
	}
906422
906422
	return 0;
906422
}
906422
906422
#endif