lbr.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. /* Alpha VMS external format of Libraries.
  2. Copyright (C) 2010-2022 Free Software Foundation, Inc.
  3. Written by Tristan Gingold <gingold@adacore.com>, AdaCore.
  4. This file is part of BFD, the Binary File Descriptor library.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. #ifndef _VMS_LBR_H
  18. #define _VMS_LBR_H
  19. /* Libray HeaDer. */
  20. /* Magic numbers. Should match the major version. */
  21. #define LHD_SANEID_DCX 319232342
  22. #define LHD_SANEID3 233579905
  23. #define LHD_SANEID6 233579911
  24. /* Library type. */
  25. #define LBR__C_TYP_UNK 0 /* Unknown / unspecified. */
  26. #define LBR__C_TYP_OBJ 1 /* Vax object. */
  27. #define LBR__C_TYP_MLB 2 /* Macro. */
  28. #define LBR__C_TYP_HLP 3 /* Help. */
  29. #define LBR__C_TYP_TXT 4 /* Text. */
  30. #define LBR__C_TYP_SHSTB 5 /* Vax shareable image. */
  31. #define LBR__C_TYP_NCS 6 /* NCS. */
  32. #define LBR__C_TYP_EOBJ 7 /* Alpha object. */
  33. #define LBR__C_TYP_ESHSTB 8 /* Alpha shareable image. */
  34. #define LBR__C_TYP_IOBJ 9 /* IA-64 object. */
  35. #define LBR__C_TYP_ISHSTB 10 /* IA-64 shareable image. */
  36. struct vms_lhd
  37. {
  38. /* Type of the library. See above. */
  39. unsigned char type;
  40. /* Number of indexes. Generally 1, 2 for object libraries. */
  41. unsigned char nindex;
  42. unsigned char fill_1[2];
  43. /* Sanity Id. */
  44. unsigned char sanity[4];
  45. /* Version. */
  46. unsigned char majorid[2];
  47. unsigned char minorid[2];
  48. /* Tool name. */
  49. unsigned char lbrver[32];
  50. /* Create time. */
  51. unsigned char credat[8];
  52. /* Update time. */
  53. unsigned char updtim[8];
  54. /* Size of the MHD. */
  55. unsigned char mhdusz;
  56. unsigned char idxblkf[2]; /* Unused. */
  57. unsigned char fill_2;
  58. unsigned char closerror[2];
  59. unsigned char spareword[2];
  60. /* First free block, and number of free blocks. */
  61. unsigned char freevbn[4];
  62. unsigned char freeblk[4];
  63. unsigned char nextrfa[6];
  64. unsigned char nextvbn[4];
  65. /* Free pre-allocated index block. */
  66. /* Number of free blocks. */
  67. unsigned char freidxblk[4];
  68. /* VBN of a simply linked list of free blocks. The list is terminated by a
  69. nul VBN. */
  70. unsigned char freeidx[4];
  71. /* Highest pre-allocated index block and in use. */
  72. unsigned char hipreal[4];
  73. unsigned char hiprusd[4];
  74. /* Number of index blocks in use. */
  75. unsigned char idxblks[4];
  76. /* Number of index entries. */
  77. unsigned char idxcnt[4];
  78. /* Number of modules entries. */
  79. unsigned char modcnt[4];
  80. unsigned char fill_3[2];
  81. /* Number of module headers. */
  82. unsigned char modhdrs[4];
  83. /* Overhead index pointers. */
  84. unsigned char idxovh[4];
  85. /* Update history records. */
  86. unsigned char maxluhrec[2];
  87. unsigned char numluhrec[2];
  88. unsigned char begluhrfa[6];
  89. unsigned char endluhrfa[6];
  90. /* DCX map. */
  91. unsigned char dcxmapvbn[4];
  92. unsigned char fill_4[4 * 13];
  93. };
  94. /* Known major ids. */
  95. #define LBR_MAJORID 3 /* Alpha libraries. */
  96. #define LBR_ELFMAJORID 6 /* Elf libraries (new index, new data). */
  97. /* Offset of the first IDD. */
  98. #define LHD_IDXDESC 196
  99. /* InDex Description. */
  100. struct vms_idd
  101. {
  102. unsigned char flags[2];
  103. /* Max length of the key. */
  104. unsigned char keylen[2];
  105. /* First index block. */
  106. unsigned char vbn[4];
  107. };
  108. /* IDD flags. */
  109. #define IDD__FLAGS_ASCII 1
  110. #define IDD__FLAGS_LOCKED 2
  111. #define IDD__FLAGS_VARLENIDX 4
  112. #define IDD__FLAGS_NOCASECMP 8
  113. #define IDD__FLAGS_NOCASENTR 16
  114. #define IDD__FLAGS_UPCASNTRY 32
  115. #define IDD_LENGTH 8
  116. /* Index block. */
  117. #define INDEXDEF__LENGTH 512
  118. #define INDEXDEF__BLKSIZ 500
  119. struct vms_indexdef
  120. {
  121. /* Number of bytes used. */
  122. unsigned char used[2];
  123. /* VBN of the parent. */
  124. unsigned char parent[4];
  125. unsigned char fill_1[6];
  126. /* The key field contains vms_idx/vms_elfidx structures, which are
  127. simply a key (= a string) and a rfa. */
  128. unsigned char keys[INDEXDEF__BLKSIZ];
  129. };
  130. /* An offset in a file. */
  131. struct vms_rfa
  132. {
  133. /* Logical block number, 1 based.
  134. 0 means that the field is absent. Block size is 512. */
  135. unsigned char vbn[4];
  136. /* Offset within the block. */
  137. unsigned char offset[2];
  138. };
  139. /* Index keys. For version 3. */
  140. struct vms_idx
  141. {
  142. /* Offset from the start of the vbn, so minimum should be
  143. DATA__DATA (ie 6). */
  144. struct vms_rfa rfa;
  145. unsigned char keylen;
  146. /* The length of this field is in fact keylen. */
  147. unsigned char keyname[256];
  148. };
  149. /* Index keys, for version 4 and later. */
  150. struct vms_elfidx
  151. {
  152. struct vms_rfa rfa;
  153. unsigned char keylen[2];
  154. unsigned char flags;
  155. unsigned char keyname[256];
  156. };
  157. /* Flags of elfidx. */
  158. #define ELFIDX__WEAK 0x01 /* Weak symbol. */
  159. #define ELFIDX__GROUP 0x02 /* Group symbol. */
  160. #define ELFIDX__LISTRFA 0x04 /* RFA field points to an LHS. */
  161. #define ELFIDX__SYMESC 0x08 /* Long symbol. */
  162. #define RFADEF__C_INDEX 0xffff
  163. /* List head structure. That's what is pointed by rfa when LISTRFA flag
  164. is set in elfidx. */
  165. struct vms_lhs
  166. {
  167. struct vms_rfa ng_g_rfa; /* Non-group global. */
  168. struct vms_rfa ng_wk_rfa; /* Non-group weak. */
  169. struct vms_rfa g_g_rfa; /* Group global. */
  170. struct vms_rfa g_wk_rfa; /* Group weak. */
  171. unsigned char flags;
  172. };
  173. /* List node structure. Fields of LHS point to this structure. */
  174. struct vms_lns
  175. {
  176. /* Next node in the list. */
  177. struct vms_rfa nxtrfa;
  178. /* Module associated with the key. */
  179. struct vms_rfa modrfa;
  180. };
  181. struct vms_datadef
  182. {
  183. /* Number of records in this block. */
  184. unsigned char recs;
  185. unsigned char fill_1;
  186. /* Next vbn. */
  187. unsigned char link[4];
  188. /* Data. The first word is the record length, followed by record
  189. data and a possible pad byte so that record length is always aligned. */
  190. unsigned char data[506];
  191. };
  192. #define DATA__LENGTH 512
  193. #define DATA__DATA 6
  194. /* Key name block. This is used for keys longer than 128 bytes. */
  195. struct vms_kbn
  196. {
  197. /* Length of the key chunk. */
  198. unsigned char keylen[2];
  199. /* RFA of the next chunk. */
  200. struct vms_rfa rfa;
  201. /* Followed by the key chunk. */
  202. };
  203. /* Module header. */
  204. struct vms_mhd
  205. {
  206. /* Fixed part. */
  207. unsigned char lbrflag;
  208. unsigned char id;
  209. unsigned char fill_1[2];
  210. unsigned char refcnt[4];
  211. unsigned char datim[8];
  212. unsigned char objstat;
  213. /* Ident or GSMATCH. */
  214. unsigned char objidlng;
  215. unsigned char objid[31];
  216. unsigned char pad1[3];
  217. unsigned char otherefcnt[4];
  218. unsigned char modsize[4];
  219. unsigned char pad2[4];
  220. };
  221. #define MHD__C_MHDID 0xad /* Value for id. */
  222. #define MHD__C_MHDLEN 16 /* Fixed part length. */
  223. #define MHD__C_USRDAT 16
  224. /* Flags for objstat. */
  225. #define MHD__M_SELSRC 0x1 /* Selective search. */
  226. #define MHD__M_OBJTIR 0x2
  227. #define MHD__M_WKSYM 0x4
  228. struct vms_luh
  229. {
  230. unsigned char nxtluhblk[4];
  231. unsigned char spare[2];
  232. unsigned char data[506];
  233. };
  234. struct vms_luhdef
  235. {
  236. unsigned char rechdr[2];
  237. unsigned char reclen[2];
  238. };
  239. #define LUH__RECHDRLEN 4
  240. #define LUH__RECHDRMRK 0xabba
  241. #define LUH__DATAFLDLEN 506
  242. /* Entry in the history. */
  243. struct vms_leh
  244. {
  245. unsigned char date[8];
  246. unsigned char nbr_units[2];
  247. unsigned char action[2]; /* 1: delete, 2: insert, 3: replaced. */
  248. unsigned char idlen;
  249. /* username
  250. modules... */
  251. };
  252. #endif /* _VMS_LBR_H */