1166124Srafan/* Alpha VMS external format of Libraries. 2174993Srafan 3166124Srafan Copyright 2010 Free Software Foundation, Inc. 4166124Srafan Written by Tristan Gingold <gingold@adacore.com>, AdaCore. 5166124Srafan 6166124Srafan This file is part of BFD, the Binary File Descriptor library. 7166124Srafan 8166124Srafan This program is free software; you can redistribute it and/or modify 9166124Srafan it under the terms of the GNU General Public License as published by 10166124Srafan the Free Software Foundation; either version 3 of the License, or 11166124Srafan (at your option) any later version. 12166124Srafan 13166124Srafan This program is distributed in the hope that it will be useful, 14166124Srafan but WITHOUT ANY WARRANTY; without even the implied warranty of 15166124Srafan MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16166124Srafan GNU General Public License for more details. 17166124Srafan 18166124Srafan You should have received a copy of the GNU General Public License 19166124Srafan along with this program; if not, write to the Free Software 20166124Srafan Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 21166124Srafan MA 02110-1301, USA. */ 22166124Srafan 23166124Srafan#ifndef _VMS_LBR_H 24166124Srafan#define _VMS_LBR_H 25166124Srafan 26166124Srafan/* Libray HeaDer. */ 27166124Srafan 28166124Srafan/* Magic numbers. Should match the major version. */ 29166124Srafan 30174993Srafan#define LHD_SANEID_DCX 319232342 31166124Srafan#define LHD_SANEID3 233579905 32166124Srafan#define LHD_SANEID6 233579911 33166124Srafan 34166124Srafan/* Library type. */ 35166124Srafan#define LBR__C_TYP_UNK 0 /* Unknown / unspecified. */ 36166124Srafan#define LBR__C_TYP_OBJ 1 /* Vax object. */ 37166124Srafan#define LBR__C_TYP_MLB 2 /* Macro. */ 38166124Srafan#define LBR__C_TYP_HLP 3 /* Help. */ 39166124Srafan#define LBR__C_TYP_TXT 4 /* Text. */ 40166124Srafan#define LBR__C_TYP_SHSTB 5 /* Vax shareable image. */ 41174993Srafan#define LBR__C_TYP_NCS 6 /* NCS. */ 42166124Srafan#define LBR__C_TYP_EOBJ 7 /* Alpha object. */ 43174993Srafan#define LBR__C_TYP_ESHSTB 8 /* Alpha shareable image. */ 44174993Srafan#define LBR__C_TYP_IOBJ 9 /* IA-64 object. */ 45174993Srafan#define LBR__C_TYP_ISHSTB 10 /* IA-64 shareable image. */ 46166124Srafan 47166124Srafanstruct vms_lhd 48166124Srafan{ 49166124Srafan /* Type of the library. See above. */ 50166124Srafan unsigned char type; 51166124Srafan 52166124Srafan /* Number of indexes. Generally 1, 2 for object libraries. */ 53166124Srafan unsigned char nindex; 54174993Srafan 55166124Srafan unsigned char fill_1[2]; 56174993Srafan 57174993Srafan /* Sanity Id. */ 58174993Srafan unsigned char sanity[4]; 59166124Srafan 60166124Srafan /* Version. */ 61166124Srafan unsigned char majorid[2]; 62166124Srafan unsigned char minorid[2]; 63166124Srafan 64174993Srafan /* Tool name. */ 65166124Srafan unsigned char lbrver[32]; 66166124Srafan 67166124Srafan /* Create time. */ 68166124Srafan unsigned char credat[8]; 69166124Srafan 70166124Srafan /* Update time. */ 71166124Srafan unsigned char updtim[8]; 72166124Srafan 73166124Srafan /* Size of the MHD. */ 74166124Srafan unsigned char mhdusz; 75166124Srafan 76174993Srafan unsigned char idxblkf[2]; /* Unused. */ 77166124Srafan unsigned char fill_2; 78166124Srafan unsigned char closerror[2]; 79166124Srafan 80166124Srafan unsigned char spareword[2]; 81166124Srafan 82166124Srafan /* First free block, and number of free blocks. */ 83174993Srafan unsigned char freevbn[4]; 84174993Srafan unsigned char freeblk[4]; 85166124Srafan 86166124Srafan unsigned char nextrfa[6]; 87166124Srafan unsigned char nextvbn[4]; 88166124Srafan 89166124Srafan /* Free pre-allocated index block. */ 90166124Srafan unsigned char freidxblk[4]; 91166124Srafan unsigned char freeidx[4]; 92174993Srafan 93174993Srafan /* Highest pre-allocated index block and in use. */ 94166124Srafan unsigned char hipreal[4]; 95174993Srafan unsigned char hiprusd[4]; 96166124Srafan 97166124Srafan /* Number of index blocks in use. */ 98166124Srafan unsigned char idxblks[4]; 99166124Srafan 100166124Srafan /* Number of index entries. */ 101166124Srafan unsigned char idxcnt[4]; 102166124Srafan 103166124Srafan /* Number of modules entries. */ 104166124Srafan unsigned char modcnt[4]; 105174993Srafan 106174993Srafan unsigned char fill_3[2]; 107174993Srafan 108166124Srafan /* Number of module headers. */ 109166124Srafan unsigned char modhdrs[4]; 110174993Srafan 111166124Srafan /* Overhead index pointers. */ 112174993Srafan unsigned char idxovh[4]; 113166124Srafan 114166124Srafan /* Update history records. */ 115166124Srafan unsigned char maxluhrec[2]; 116166124Srafan unsigned char numluhrec[2]; 117166124Srafan unsigned char begluhrfa[6]; 118166124Srafan unsigned char endluhrfa[6]; 119166124Srafan 120166124Srafan /* DCX map. */ 121166124Srafan unsigned char dcxmapvbn[4]; 122166124Srafan 123166124Srafan unsigned char fill_4[4 * 13]; 124166124Srafan}; 125174993Srafan 126166124Srafan/* Known major ids. */ 127174993Srafan#define LBR_MAJORID 3 /* Alpha libraries. */ 128166124Srafan#define LBR_ELFMAJORID 6 /* Elf libraries (new index, new data). */ 129166124Srafan 130166124Srafan/* Offset of the first IDD. */ 131166124Srafan#define LHD_IDXDESC 196 132166124Srafan 133166124Srafan/* InDex Description. */ 134166124Srafanstruct vms_idd 135166124Srafan{ 136166124Srafan unsigned char flags[2]; 137166124Srafan 138166124Srafan /* Max length of the key. */ 139166124Srafan unsigned char keylen[2]; 140166124Srafan 141166124Srafan /* First index block. */ 142166124Srafan unsigned char vbn[4]; 143166124Srafan}; 144166124Srafan 145166124Srafan/* IDD flags. */ 146166124Srafan#define IDD__FLAGS_ASCII 1 147166124Srafan#define IDD__FLAGS_LOCKED 2 148166124Srafan#define IDD__FLAGS_VARLENIDX 4 149166124Srafan#define IDD__FLAGS_NOCASECMP 8 150166124Srafan#define IDD__FLAGS_NOCASENTR 16 151166124Srafan#define IDD__FLAGS_UPCASNTRY 32 152166124Srafan 153166124Srafan#define IDD_LENGTH 8 154174993Srafan 155166124Srafan/* Index block. */ 156166124Srafan#define INDEXDEF__LENGTH 512 157166124Srafan#define INDEXDEF__BLKSIZ 500 158166124Srafan 159166124Srafanstruct vms_indexdef 160166124Srafan{ 161166124Srafan /* Number of bytes used. */ 162166124Srafan unsigned char used[2]; 163166124Srafan 164166124Srafan /* VBN of the parent. */ 165166124Srafan unsigned char parent[4]; 166166124Srafan 167166124Srafan unsigned char fill_1[6]; 168166124Srafan 169166124Srafan /* The key field contains vms_idx/vms_elfidx structures, which are 170166124Srafan simply a key (= a string) and a rfa. */ 171166124Srafan unsigned char keys[INDEXDEF__BLKSIZ]; 172166124Srafan}; 173166124Srafan 174166124Srafan/* An offset in a file. */ 175166124Srafan 176166124Srafanstruct vms_rfa 177166124Srafan{ 178166124Srafan /* Logical block number, 1 based. 179166124Srafan 0 means that the field is absent. Block size is 512. */ 180166124Srafan unsigned char vbn[4]; 181166124Srafan 182166124Srafan /* Offset within the block. */ 183166124Srafan unsigned char offset[2]; 184166124Srafan}; 185166124Srafan 186166124Srafan/* Index keys. For version 3. */ 187166124Srafan 188166124Srafanstruct vms_idx 189166124Srafan{ 190166124Srafan /* Offset from the start of the vbn, so minimum should be 191166124Srafan DATA__DATA (ie 6). */ 192166124Srafan struct vms_rfa rfa; 193166124Srafan 194166124Srafan unsigned char keylen; 195166124Srafan /* The length of this field is in fact keylen. */ 196166124Srafan unsigned char keyname[256]; 197166124Srafan}; 198166124Srafan 199166124Srafan/* Index keys, for version 4 and later. */ 200166124Srafan 201166124Srafanstruct vms_elfidx 202166124Srafan{ 203166124Srafan struct vms_rfa rfa; 204166124Srafan 205166124Srafan unsigned char keylen[2]; 206166124Srafan unsigned char flags; 207166124Srafan unsigned char keyname[256]; 208166124Srafan}; 209166124Srafan 210166124Srafan/* Flags of elfidx. */ 211166124Srafan 212166124Srafan#define ELFIDX__WEAK 0x01 /* Weak symbol. */ 213166124Srafan#define ELFIDX__GROUP 0x02 /* Group symbol. */ 214166124Srafan#define ELFIDX__LISTRFA 0x04 /* RFA field points to an LHS. */ 215166124Srafan#define ELFIDX__SYMESC 0x08 /* Long symbol. */ 216166124Srafan 217166124Srafan#define RFADEF__C_INDEX 0xffff 218166124Srafan 219166124Srafan/* List head structure. That's what is pointed by rfa when LISTRFA flag 220166124Srafan is set in elfidx. */ 221166124Srafan 222166124Srafanstruct vms_lhs 223166124Srafan{ 224166124Srafan struct vms_rfa ng_g_rfa; /* Non-group global. */ 225166124Srafan struct vms_rfa ng_wk_rfa; /* Non-group weak. */ 226 struct vms_rfa g_g_rfa; /* Group global. */ 227 struct vms_rfa g_wk_rfa; /* Group weak. */ 228 unsigned char flags; 229}; 230 231/* List node structure. Fields of LHS point to this structure. */ 232 233struct vms_lns 234{ 235 /* Next node in the list. */ 236 struct vms_rfa nxtrfa; 237 238 /* Module associated with the key. */ 239 struct vms_rfa modrfa; 240}; 241 242struct vms_datadef 243{ 244 /* Number of records in this block. */ 245 unsigned char recs; 246 unsigned char fill_1; 247 248 /* Next vbn. */ 249 unsigned char link[4]; 250 251 /* Data. The first word is the record length, followed by record 252 data and a possible pad byte so that record length is always aligned. */ 253 unsigned char data[506]; 254}; 255#define DATA__LENGTH 512 256#define DATA__DATA 6 257 258/* Key name block. This is used for keys longer than 128 bytes. */ 259 260struct vms_kbn 261{ 262 /* Length of the key chunk. */ 263 unsigned char keylen[2]; 264 265 /* RFA of the next chunk. */ 266 struct vms_rfa rfa; 267 268 /* Followed by the key chunk. */ 269}; 270 271/* Module header. */ 272struct vms_mhd 273{ 274 /* Fixed part. */ 275 unsigned char lbrflag; 276 unsigned char id; 277 unsigned char fill_1[2]; 278 unsigned char refcnt[4]; 279 unsigned char datim[8]; 280 281 unsigned char objstat; 282 /* Ident or GSMATCH. */ 283 unsigned char objidlng; 284 unsigned char objid[31]; 285 286 unsigned char pad1[3]; 287 unsigned char otherefcnt[4]; 288 unsigned char modsize[4]; 289 unsigned char pad2[4]; 290}; 291 292#define MHD__C_MHDID 0xad /* Value for id. */ 293#define MHD__C_MHDLEN 16 /* Fixed part length. */ 294#define MHD__C_USRDAT 16 295 296/* Flags for objstat. */ 297#define MHD__M_SELSRC 0x1 /* Selective search. */ 298#define MHD__M_OBJTIR 0x2 299#define MHD__M_WKSYM 0x4 300 301struct vms_luh 302{ 303 unsigned char nxtluhblk[4]; 304 unsigned char spare[2]; 305 unsigned char data[506]; 306}; 307 308struct vms_luhdef 309{ 310 unsigned char rechdr[2]; 311 unsigned char reclen[2]; 312}; 313#define LUH__RECHDRLEN 4 314#define LUH__RECHDRMRK 0xabba 315#define LUH__DATAFLDLEN 506 316 317/* Entry in the history. */ 318 319struct vms_leh 320{ 321 unsigned char date[8]; 322 unsigned char nbr_units[2]; 323 unsigned char action[2]; /* 1: delete, 2: insert, 3: replaced. */ 324 unsigned char idlen; 325 /* username 326 modules... */ 327}; 328 329#endif /* _VMS_LBR_H */ 330