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