[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4 Files Reference

ar File Format (Small)

Purpose

Describes the small indexed archive file format, in use prior to AIX 4.3. This format is recognized by AIX commands for backward compatability purposes only. See ar File Format (Big) for the current archive file format.

Description

The ar (archive) command combines several files into one. The ar command creates an archive file. The ld (link editor) command searches archive files to resolve program linkage. The /usr/include/ar.h file describes the archive file format. This archive format only handles 32-bit XCOFF members. The ar File Format (Big) handles both 32-bit and 64-bit XCOFF members

Fixed-Length Header

Each archive begins with a fixed-length header that contains offsets to special archive file members. The fixed-length header also contains the magic number, which identifies the archive file. The fixed-length header has the following format:

#define AIAMAG "<aiaff>\n"      /* Magic string */
#define SAIAMAG 8               /* Length of magic string */
struct fl_hdr                   /* Fixed-length header */
{
char fl_magic[SAIAMAG];  /* Archive magic string */
char fl_memoff[12];      /* Offset to member table */
char fl_gstoff[12];      /* Offset to global symbol table */
char fl_fstmoff[12];     /* Offset to first archive member */
char fl_lstmoff[12];     /* Offset to last archive member */
char fl_freeoff[12];     /* Offset to first mem on free list */
};

The indexed archive file format uses a double-linked list within the archive file to order the file members. Therefore, file members may not be sequentially ordered within the archive. The offsets contained in the fixed-length header locate the first and last file members of the archive. Member order is determined by the linked list.

The fixed-length header also contains the offsets to the member table, the global symbol table, and the free list. Both the member table and the global symbol table exist as members of the archive and are kept at the end of the archive file. The free list contains file members that have been deleted from the archive. When adding new file members to the archive, free list space is used before the archive file size is expanded. A zero offset in the fixed-length header indicates that the member is not present in the archive file.

File Member Header

Each archive file member is preceded by a file member header, which contains the following information about the file member:

#define AIAFMAG "`\n"           /* Header trailer string */
struct ar_hdr                   /* File member header */
{
        char ar_size[12];       /* File member size - decimal */
        char ar_nxtmem[12];     /* Next member offset - decimal*/
        char ar_prvmem[12];     /* Previous member offset - dec */
        char ar_date[12];       /* File member date - decimal */
        char ar_uid[12];        /* File member user id - decimal */
        char ar_gid[12];        /* File member group id - decimal */
        char ar_mode[12];       /* File member mode - octal */
        char ar_namlen[4];      /* File member name length - dec */
        union
                {
                char ar_name[2];      /* Start of member name */
                char ar_fmag[2];      /* AIAFMAG - string to end */
                };
        _ar_name;                     /* Header and member name */
};

The member header provides support for member names up to 255 characters long. The ar_namlen field contains the length of the member name. The character string containing the member name begins at the _ar_name field. The AIAFMAG string is cosmetic only.

Each archive member header begins on an even-byte boundary. The total length of a member header is:

sizeof (struct ar_hdr) + ar_namlen 

The actual data for a file member begins at the first even-byte boundary beyond the member header and continues for the number of bytes specified by the ar_size field. The ar command inserts null bytes for padding where necessary.

All information in the fixed-length header and archive members is in printable ASCII format. Numeric information, with the exception of the ar_mode field, is stored as decimal numbers; the ar_mode field is stored in octal format. Thus, if the archive file contains only printable files, you can print the archive.

Member Table

A member table is always present in an indexed archive file. This table quickly locates members of the archive. The fl_memoff field in the fixed-length header contains the offset to the member table. The member table member has a zero-length name. The ar command automatically creates and updates (but does not list) the member table. A member table contains the following information:

Global Symbol Table

If an archive file contains XCOFF object-file members that are not stripped, the archive file will contain a global symbol-table member. This global symbol table locates file members that define global symbols. The strip command deletes the global symbol table from the archive. The fl_gstoff field in the fixed-length header contains the offset to the global symbol table. The global symbol table member has a zero-length name. The ar command automatically creates and updates, but does not list the global symbol table. A global symbol table contains the following information:

Related Information

The a.out file format.

The ar command, ld command, strip command.

The sgetl or sputl subroutine.

The Header Files Overview in AIX Version 4.3 Files Reference.


[ Previous | Next | Contents | Glossary | Home | Search ]