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?
-
Why do you want to do that? Is the `ar` a static library? You might perhaps use `libbfd` .... – Basile Starynkevitch Mar 20 '13 at 20:17
-
I'm using ar to package arbitrary files. I'm not trying to access something output by a linker. ar gives me a simple way to bundle files together. – D. A. Mar 21 '13 at 16:17
-
I then would use some more usual format, like `tar` .... See `tar(5)` man page or `
` header for its description. – Basile Starynkevitch Mar 21 '13 at 16:40
3 Answers
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.

- 219,201
- 40
- 422
- 469
-
1Thanks! My google-skills failed me on this one. Glad yours had better success. – D. A. Mar 20 '13 at 21:04
-
This doesn't answer the question. The OP is asking for the GNU ar format. – Jason S Mar 28 '22 at 23:11
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:
- GNU Binutils - ar.h
- FreeBSD - src/usrbin/ar.h (it was removed some time ago, but it is still in the version control).
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).

- 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
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