8

I need to access an ar created file, but I cannot find a specification document defining the format. Can someone point me in the right direction?

D. A.
  • 3,369
  • 3
  • 31
  • 34

3 Answers3

6

From Wikipedia:

The ar format has never been standardized; modern archives are based on a common format with two known variants, BSD and GNU.

More information is there, too.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
2

Where to find information

It seems that GNU binutils does not have documentation for the file format.

I believe the best reference out there is in the ar(5) manual page from FreeBSD. The ar utility was removed in version 5.0 but the manpage for 4.11 is still available.

As usual, the header details can be found in the header files:

Also, the Wikipedia page for the AR file format has a nice diagram that describes the file format (it is from a .deb package which is also an ar file).

File format

This file has a very simple structure:

  • File signature (the one that identifies this as an ar file).
  • For every file in the archive we have:
    • A header that contains file name, owner, group, size, and permissions (see header file).
    • The file contents
    • And optionally padding (\n).
Iñigo González
  • 3,735
  • 1
  • 11
  • 27
  • "It seems that GNU binutils does not have documentation for the file format." -- that's my concern here; how can someone maintain code to work properly if there is no spec? – Jason S Apr 04 '22 at 21:42
  • To be honest, 'ar' is a dying format. Debian (.deb) packages are `.ar`files and they implemented their own ar encoder/decoder instead of using the `ar` utility see [DPKG ar.c](https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/ar.c) – Iñigo González Apr 07 '22 at 06:55
  • 1
    "To be honest, 'ar' is a dying format." So if I'm programming in C for embedded systems, what format would you expect me to use in the future for statically-linked libraries? I would have to disagree with you. – Jason S Apr 08 '22 at 13:41
0

Some information on IBM website: http://pic.dhe.ibm.com/infocenter/aix/v7r1/index.jsp?topic=%2Fcom.ibm.aix.files%2Fdoc%2Faixfiles%2Far_big.htm

  • This is valid for AIX Big Format, which has a different magic marker and probably a different structure. AIX global header is much more complicated than GNU/BSD format documented on Wikipedia. – Adi Roiban Dec 08 '13 at 11:27