|
 |
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 |
|
|
 |
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 {
|
|
 |
906422 |
const struct pe_driver_ctx * dctx;
|
|
 |
906422 |
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;
|
|
 |
906422 |
struct pe_txtfile_ctx * nminfo;
|
|
 |
906422 |
struct pe_archive_meta armeta;
|
|
 |
906422 |
};
|
|
 |
906422 |
|
|
 |
906422 |
struct ar_meta_member_info * pe_archive_member_from_offset(
|
|
 |
906422 |
struct pe_archive_meta_impl * meta,
|
|
 |
906422 |
off_t offset);
|
|
 |
906422 |
|
|
 |
906422 |
int pe_ar_parse_primary_armap_bsd_32(
|
|
 |
906422 |
const struct pe_driver_ctx * dctx,
|
|
 |
906422 |
struct pe_archive_meta_impl * m);
|
|
 |
906422 |
|
|
 |
906422 |
int pe_ar_parse_primary_armap_bsd_64(
|
|
 |
906422 |
const struct pe_driver_ctx * dctx,
|
|
 |
906422 |
struct pe_archive_meta_impl * m);
|
|
 |
906422 |
|
|
 |
906422 |
int pe_ar_parse_primary_armap_sysv_32(
|
|
 |
906422 |
const struct pe_driver_ctx * dctx,
|
|
 |
906422 |
struct pe_archive_meta_impl * m);
|
|
 |
906422 |
|
|
 |
906422 |
int pe_ar_parse_primary_armap_sysv_64(
|
|
 |
906422 |
const struct pe_driver_ctx * dctx,
|
|
 |
906422 |
struct pe_archive_meta_impl * m);
|
|
 |
906422 |
|
|
 |
906422 |
int pe_update_mapstrv(
|
|
 |
906422 |
const struct pe_driver_ctx * dctx,
|
|
 |
906422 |
struct pe_archive_meta_impl * m);
|
|
 |
906422 |
|
|
 |
906422 |
int pe_ar_update_syminfo(
|
|
 |
906422 |
struct pe_archive_ctx * actx);
|
|
 |
906422 |
|
|
 |
906422 |
int pe_ar_update_syminfo_ex(
|
|
 |
906422 |
struct pe_archive_ctx * actx,
|
|
 |
906422 |
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
|