IT한 것/unix

AIX: ar command

lovian 2012. 10. 22. 20:54

AIX에서 연관되어있는 모듈 관계를 보면 shared object인 .so파일 보다는 .a 파일이 많이 나온다.

과연 왜 이럴까? 라는 물음에서 남길만한 것을 찾았다.


아래의 내용은 man ar 명령으로 본 것이다.


The ar command maintains the indexed libraries used by the linkage editor. The ar command combines one or more named files into a single

       archive file written in ar archive format. When the ar command creates a library, it creates headers in a transportable format; when it

       creates or updates a library, it rebuilds the symbol table. See the ar file format entry for information on the format and structure of

       indexed archives and symbol tables.


       There are two file formats that the ar command recognizes. The Big Archive Format, ar_big, is the default file format and supports both 32-bit

       and 64-bit object files. The Small Archive Format can be used to create archives that are recognized on versions older than AIX(R) 4.3, see

       the -g flag. If a 64-bit object is added to a small format archive, ar first converts it to the big format, unless -g is specified. By

       default, ar only handles 32-bit object files; any 64-bit object files in an archive are silently ignored. To change this behavior, use the -X

       flag or set the OBJECT_MODE environment variable.


두꺼운 부분을보면.


ar 명령어가 인식하는 두 개의 파일 형식이 있다. ar_big인 Big Archive 형식은 기본 형식으로 32bit와 64bit 오브젝트 파일들을 지원한다. Smart Archive 형식은 -g 옵션에 따라서 AIX 4.3 이전의 구 버전에서 인식하는 형식으로 만들어준다.. 만일 -g 옵션이 설정되어 있지 않다면 64비트 오브젝트가 small 형식에 추가되면, ar은 우선적으로 big 형식으로 변환하고,  기본적으로 ar은 32비트 오브젝트만  관리하게 되어 있다.; 어떠한 64비트 파일들이 있다면 아무런 알림 없이 무시한다. 이러한 작동을 변경하려면, -X 옵션을 사용하거나 환경변수 OBJECT_MODE를 설정하면 된다.



결론적으로는,

Mac OSX의 Universal Binary 와 비슷한 녀석이  Big Archive Format 인것 같다. 또한 기본이라니 이걸 쓰는 것이 일반적인지도 모르겠다.