1
0

ar 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. .TH AR 6
  2. .SH NAME
  3. ar \- archive (library) file format
  4. .SH SYNOPSIS
  5. .B #include <ar.h>
  6. .SH DESCRIPTION
  7. The archive command
  8. .IR ar (1)
  9. is used to combine several files into
  10. one.
  11. Archives are used mainly as libraries to be searched
  12. by the loaders
  13. .IR 8l (1)
  14. .I et al.
  15. .PP
  16. A file produced by
  17. .I ar
  18. has a magic string at the start,
  19. followed by the constituent files, each preceded by a file header.
  20. The magic number and header layout as described in the
  21. include file are:
  22. .IP
  23. .EX
  24. .ta \w'#define 'u +\w'SAR_HDR 'u
  25. .ec %
  26. #define ARMAG "!<arch>\n"
  27. #define SARMAG 8
  28. #define ARFMAG "`\n"
  29. struct ar_hdr {
  30. char name[16];
  31. char date[12];
  32. char uid[6];
  33. char gid[6];
  34. char mode[8];
  35. char size[10];
  36. char fmag[2];
  37. };
  38. #define SAR_HDR 60
  39. .ec \
  40. .EE
  41. .LP
  42. The
  43. .B name
  44. is a blank-padded string.
  45. The
  46. .L fmag
  47. field contains
  48. .L ARFMAG
  49. to help verify the presence of a header.
  50. The other fields are left-adjusted, blank-padded numbers.
  51. They are decimal except for
  52. .LR mode ,
  53. which is octal.
  54. The date is the modification date of the file (see
  55. .IR stat (2))
  56. at the time of its insertion into the archive.
  57. The mode is the low 9 bits of the file permission mode.
  58. The length of the header is
  59. .LR SAR_HDR .
  60. Because the
  61. .L ar_hdr
  62. structure is padded in an architecture-dependent manner,
  63. the structure should never be read or written as a unit;
  64. instead, each field should be read or written independently.
  65. .PP
  66. Each file begins on an even (0 mod 2) boundary;
  67. a newline is inserted between files if necessary.
  68. Nevertheless
  69. .B size
  70. reflects the
  71. actual size of the file exclusive of padding.
  72. .PP
  73. When all members of an archive are object files of
  74. the same architecture,
  75. .B ar
  76. automatically adds an extra file, named
  77. .BR __.SYMDEF ,
  78. as the first member of the archive. This file
  79. contains an index used by the loaders to locate all
  80. externally defined text and data symbols in the archive.
  81. .PP
  82. There is no provision for empty areas in an archive
  83. file.
  84. .SH "SEE ALSO"
  85. .IR ar (1),
  86. .IR 8l (1),
  87. .IR nm (1),
  88. .IR stat (2)
  89. .SH BUGS
  90. The
  91. .B uid
  92. and
  93. .B gid
  94. fields are unused in Plan 9.
  95. They provide compatibility with Unix
  96. .I ar
  97. format.