/* GNU PIC archive functions
Copyright 2001-2005 Craig Franklin
*/
#pragma once
#include "gpreadobj.h"
/* gputils uses Microchip's library file format. It is basically a coff
archive with a few exceptions.
- There are no user id and mode entries in the header.
- The archive member name has been increased from 16 to 256 characters.
- The strings for data and size are terminated with "l"
- The first member in the archive is not a symbol table.
The first 8 bytes in the archive are ARMAG. This is followed by the
archive members. Each member starts with an ar_hdr. This is followed
by the complete object file.
gputils uses the complete object filename for the member name.
The only intentional deviation from Microchip's format, is a symbol
index. This index provides all global symbols names from the archive.
This simplifies the task of determining which archive members are
required for linking.
The symbol index is always the first coff member in the archive. It
can be identified because ar_name[0] == '/'.
*/
/* Note that the usual '\n' in magic strings may translate to different
characters, as allowed by ANSI. '\012' has a fixed value. */
#define ARMAG "!<arch>\012"
#define SARMAG 8
#define ARFMAG "`\012"
#define AR_MEM_NAME_SIZ 256
#define AR_MEM_DATE_SIZ 12
#define AR_MEM_FSIZE_SIZ 10
#define AR_MEM_FMAG_SIZ 2
/* archive file member header */
typedef struct ar_hdr {
char ar_name[AR_MEM_NAME_SIZ]; /* name of this member */
char ar_date[AR_MEM_DATE_SIZ]; /* file mtime */
char ar_size[AR_MEM_FSIZE_SIZ]; /* file size, printed as decimal */
char ar_fmag[AR_MEM_FMAG_SIZ]; /* should contain ARFMAG */
} ar_hdr_t;
#define AR_HDR_SIZ (AR_MEM_NAME_SIZ + AR_MEM_DATE_SIZ + AR_MEM_FSIZE_SIZ + AR_MEM_FMAG_SIZ)
typedef struct gp_archive {
ar_hdr_t header; /* archive header file */
gp_binary_t data; /* binary data */
unsigned offset; /* offset from the beginning of the archive */
struct gp_archive *next; /* next file in linked list */
} gp_archive_t;
/* symbol index data */
#define AR_INDEX_NUMBER_SIZ 4 /* number of symbols is 4 bytes long */
#define AR_INDEX_OFFSET_SIZ 4 /* symbol index offsets are 4 bytes long */
extern unsigned gp_archive_count_members(const gp_archive_t *Archive);
FUNC(char*) gp_archive_member_name(const gp_archive_t *Archive);
FUNC(void) gp_archive_list_members(const gp_archive_t *Archive);
FUNC(gp_archive_t*) gp_archive_find_member(gp_archive_t *Archive, const char *Object_name);
extern void gp_archive_free_member(gp_archive_t *Archive);
FUNC(gp_archive_t*) gp_archive_delete_member(gp_archive_t *Archive, const char *Object_name);
extern bool gp_archive_rename_member(gp_archive_t *Archive, const char *Object_name_old,
const char *Object_name_new);
FUNC(gp_archive_t*) gp_archive_add_member(gp_archive_t *Archive, const char *File_name,
const char *Object_name);
FUNC(bool) gp_archive_extract_member(gp_archive_t *Archive, const char *Object_name);
FUNC(bool) gp_archive_write(gp_archive_t *Archive, const char *Archive_name);
extern void gp_archive_update_offsets(gp_archive_t *Archive);
FUNC(gp_archive_t*) gp_archive_read(const char *File_name);
FUNC(bool) gp_archive_have_index(const gp_archive_t *Archive);
FUNC(gp_archive_t*) gp_archive_remove_index(gp_archive_t *Archive);
FUNC(void) gp_archive_make_index(gp_archive_t *Archive, symbol_table_t *Definition);
FUNC(gp_archive_t*) gp_archive_add_index(symbol_table_t *Table, gp_archive_t *Archive);
extern bool gp_archive_add_symbol(symbol_table_t *Table, const char *Name, gp_archive_t *Member);
FUNC(void) gp_archive_read_index(symbol_table_t *Table, gp_archive_t *Archive);
FUNC(void) gp_archive_print_table(const symbol_table_t *Table);
Vorgefundene Kodierung: UTF-8 | 0
|