|
|
1f1fa3 |
/*******************************************************************/
|
|
|
eac61a |
/* slibtool: a strong libtool implementation, written in C */
|
|
|
1f1fa3 |
/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */
|
|
|
1f1fa3 |
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
|
|
|
1f1fa3 |
/*******************************************************************/
|
|
|
1f1fa3 |
|
|
|
11f3c7 |
#ifndef SLIBTOOL_AR_IMPL_H
|
|
|
11f3c7 |
#define SLIBTOOL_AR_IMPL_H
|
|
|
11f3c7 |
|
|
|
11f3c7 |
#include "argv/argv.h"
|
|
|
d4473b |
#include <slibtool/slibtool.h>
|
|
|
d4473b |
#include <slibtool/slibtool_arbits.h>
|
|
|
11f3c7 |
|
|
|
f188e8 |
/* decimal values in archive header are right padded with ascii spaces */
|
|
|
f188e8 |
#define AR_DEC_PADDING (0x20)
|
|
|
f188e8 |
|
|
|
f188e8 |
/* archive file members are right padded as needed with ascii newline */
|
|
|
f188e8 |
#define AR_OBJ_PADDING (0x0A)
|
|
|
f188e8 |
|
|
|
f188e8 |
/* initial number of elements in the transient, on-stack vector */
|
|
|
f188e8 |
# define AR_STACK_VECTOR_ELEMENTS (0x200)
|
|
|
f188e8 |
|
|
|
11f3c7 |
extern const struct argv_option slbt_ar_options[];
|
|
|
11f3c7 |
|
|
|
d4473b |
struct ar_armaps_impl {
|
|
|
7fe83d |
struct ar_meta_armap_ref_32 * armap_symrefs_32;
|
|
|
7fe83d |
struct ar_meta_armap_ref_64 * armap_symrefs_64;
|
|
|
d4473b |
struct ar_raw_armap_bsd_32 armap_bsd_32;
|
|
|
d4473b |
struct ar_raw_armap_bsd_64 armap_bsd_64;
|
|
|
d4473b |
struct ar_raw_armap_sysv_32 armap_sysv_32;
|
|
|
d4473b |
struct ar_raw_armap_sysv_64 armap_sysv_64;
|
|
|
d4473b |
struct ar_meta_armap_common_32 armap_common_32;
|
|
|
d4473b |
struct ar_meta_armap_common_64 armap_common_64;
|
|
|
d4473b |
uint64_t armap_nsyms;
|
|
|
d4473b |
};
|
|
|
d4473b |
|
|
|
d4473b |
struct slbt_archive_meta_impl {
|
|
|
244523 |
const struct slbt_driver_ctx * dctx;
|
|
|
0006f7 |
size_t ofmtattr;
|
|
|
562b43 |
size_t nentries;
|
|
|
d4473b |
void * hdrinfov;
|
|
|
d4473b |
char * namestrs;
|
|
|
d4473b |
const char * symstrs;
|
|
|
d4473b |
const char ** symstrv;
|
|
|
df2627 |
const char ** mapstrv;
|
|
|
405946 |
off_t * offsetv;
|
|
|
bbf27c |
struct ar_meta_symbol_info * syminfo;
|
|
|
bbf27c |
struct ar_meta_symbol_info ** syminfv;
|
|
|
d4473b |
struct ar_meta_member_info ** memberv;
|
|
|
d4473b |
struct ar_meta_member_info * members;
|
|
|
d4473b |
struct ar_armaps_impl armaps;
|
|
|
bbf27c |
struct slbt_txtfile_ctx * nminfo;
|
|
|
d4473b |
struct slbt_archive_meta armeta;
|
|
|
d4473b |
};
|
|
|
d4473b |
|
|
|
8567ec |
struct ar_meta_member_info * slbt_archive_member_from_offset(
|
|
|
8567ec |
struct slbt_archive_meta_impl * meta,
|
|
|
8567ec |
off_t offset);
|
|
|
8567ec |
|
|
|
5658da |
int slbt_ar_parse_primary_armap_bsd_32(
|
|
|
5658da |
const struct slbt_driver_ctx * dctx,
|
|
|
5658da |
struct slbt_archive_meta_impl * m);
|
|
|
5658da |
|
|
|
dc33d4 |
int slbt_ar_parse_primary_armap_bsd_64(
|
|
|
dc33d4 |
const struct slbt_driver_ctx * dctx,
|
|
|
dc33d4 |
struct slbt_archive_meta_impl * m);
|
|
|
dc33d4 |
|
|
|
dfb348 |
int slbt_ar_parse_primary_armap_sysv_32(
|
|
|
dfb348 |
const struct slbt_driver_ctx * dctx,
|
|
|
dfb348 |
struct slbt_archive_meta_impl * m);
|
|
|
dfb348 |
|
|
|
b5595d |
int slbt_ar_parse_primary_armap_sysv_64(
|
|
|
b5595d |
const struct slbt_driver_ctx * dctx,
|
|
|
b5595d |
struct slbt_archive_meta_impl * m);
|
|
|
b5595d |
|
|
|
df2627 |
int slbt_update_mapstrv(
|
|
|
df2627 |
const struct slbt_driver_ctx * dctx,
|
|
|
df2627 |
struct slbt_archive_meta_impl * m);
|
|
|
df2627 |
|
|
|
bbf27c |
int slbt_ar_update_syminfo(
|
|
|
bbf27c |
struct slbt_archive_ctx * actx,
|
|
|
bbf27c |
struct slbt_exec_ctx * ectx);
|
|
|
bbf27c |
|
|
|
d4473b |
static inline struct slbt_archive_meta_impl * slbt_archive_meta_ictx(const struct slbt_archive_meta * meta)
|
|
|
d4473b |
{
|
|
|
d4473b |
uintptr_t addr;
|
|
|
d4473b |
|
|
|
d4473b |
if (meta) {
|
|
|
d4473b |
addr = (uintptr_t)meta - offsetof(struct slbt_archive_meta_impl,armeta);
|
|
|
d4473b |
return (struct slbt_archive_meta_impl *)addr;
|
|
|
d4473b |
}
|
|
|
d4473b |
|
|
|
d4473b |
return 0;
|
|
|
d4473b |
}
|
|
|
d4473b |
|
|
|
11f3c7 |
#endif
|