AR archive file (.a) layout
AR archive file (.a) layout
I am working on my own linker/archiver and I have some trouble finding any definitive description of .a file format. There are few known .a file variants so I decided to use System V/GNU one. Normally .a files are capable of storing only 15 (+ '/' terminator) file name characters. Longer filenames are stored in separate pseudo-file (named "//") and referenced by archived files that need long names. GNU tools seem to always store that long file name pseudo-file before any regular files. So does my linker/archiver. But I wonder if it is guaranteed to be like that. Or can long file name pseudo-file exist anywhere in the archive? Do I have to deal with such case? Doing so would complicate things a little bit.
Re: AR archive file (.a) layout
I quote from Levine "Linkers & Loaders":
In UNIX archives, the // member ... follows the symbol table."
Re: AR archive file (.a) layout
Ok… I assume that by "symbol table" he means symbol index (which is BTW optional). So, that's +1 for "do nothing" option. I would add another +1 for "do nothing" because I'm lazy.
But the question is still open.
But the question is still open.
Re: AR archive file (.a) layout
Hi,
Our AR files are compatible with MSVC but it sounds like it does it similarly. That is, the first member is always \ ("first linker member") followed by \ ("second linker member") and another \\ ("long file names") then the file list. File names that are "/<digits>" are looked up via the long file name table. There is no way to differentiate between the first and second linker member entries with just looking at the file header alone so I would expect them to always have to be the first three members in that specific order. If requested....I can generate an AR file with the members out of order to see what happens. Am betting the linker won't like it though.
Our AR files are compatible with MSVC but it sounds like it does it similarly. That is, the first member is always \ ("first linker member") followed by \ ("second linker member") and another \\ ("long file names") then the file list. File names that are "/<digits>" are looked up via the long file name table. There is no way to differentiate between the first and second linker member entries with just looking at the file header alone so I would expect them to always have to be the first three members in that specific order. If requested....I can generate an AR file with the members out of order to see what happens. Am betting the linker won't like it though.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: AR archive file (.a) layout
The same book from which I qouted says indeed that the long filename entry is always the third in Windows archives.neon wrote:Hi,
Our AR files are compatible with MSVC but it sounds like it does it similarly. That is, the first member is always \ ("first linker member") followed by \ ("second linker member") and another \\ ("long file names") then the file list. File names that are "/<digits>" are looked up via the long file name table. There is no way to differentiate between the first and second linker member entries with just looking at the file header alone so I would expect them to always have to be the first three members in that specific order. If requested....I can generate an AR file with the members out of order to see what happens. Am betting the linker won't like it though.
Re: AR archive file (.a) layout
If that's the case, I am going for "do nothing" option. And thanks for letting me know about the book.
Re: AR archive file (.a) layout
There's a wiki page on a.out. As for AR, normal wikipedia, but I think your best bet would be to read binutil's ar source for aout AR and see how that does it. The bfd source is actually full of comments.
Also check out include/aout/aout64.h and include/aout/ar.h (again, lots of comments)
Cheers,
bzt
Also check out include/aout/aout64.h and include/aout/ar.h (again, lots of comments)
Cheers,
bzt
Re: AR archive file (.a) layout
Hi,
We can always provide our archive utility source if needed -- it just sounded like from the original post that you have already written one and was just inquiring on the ordering of its special files. If you think it might be helpful though or would like to compare, please feel free to let me know.
We can always provide our archive utility source if needed -- it just sounded like from the original post that you have already written one and was just inquiring on the ordering of its special files. If you think it might be helpful though or would like to compare, please feel free to let me know.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}