[Home]Binutils/Ar

ec2-18-219-112-111.us-east-2.compute.amazonaws.com | ToothyWiki | Binutils | RecentChanges | Login | Webcomic

An archive .a file is a simple catenation of the files placed in it, each prefixed with a standard header.

Add files to an archive (replacing existing files with the same name):
   ar -r <archive.a> <object1.o> <object2.o> ... 

List the contents of an archive:
   ar -t <archive.a>

Extract files from an archive:
   ar -x <archive.a>

File format


The first line identifies the file as an archive file:
   !<arch>

Each entry in the archive has a 60 character archive header containing the following parts:
   <filename [16 bytes]> <timestamp> <uid> <gid> <access mask> <length in bytes>   '

The file data immediately follows the header, running for the number of bytes specified in the header.  This is followed by the next archive header (if there are further entries in the archive).

Special sections


If a filename exceeds 16 bytes, the filename is replaced by an escape code and an integer in the form /1234.  This integer represents an offset into a special section named "//" the long filename is stored here.

Additionally the archive may have an index section named "/" containing the symbol table for the archive.  This section is updated each time an object file is added.  It can also be created by running ranlib over the archive.

ec2-18-219-112-111.us-east-2.compute.amazonaws.com | ToothyWiki | Binutils | RecentChanges | Login | Webcomic
This page is read-only | View other revisions | Recently used referrers
Last edited February 15, 2010 9:53 pm (viewing revision 1, which is the newest) (diff)
Search: