struct lib_tdata
{
+ /* Standard tdata for an archive. But we don't use many fields. */
+ struct artdata artdata;
+
/* Major version. */
unsigned char ver;
/* Total size of the mhd (element header). */
unsigned int mhd_size;
+ /* Creation date. */
+ unsigned int credat_lo;
+ unsigned int credat_hi;
+
/* Vector of modules (archive elements), already sorted. */
unsigned int nbr_modules;
struct carsym *modules;
bfd **cache;
- /* Vector of symbols (archive map), already sorted. */
- unsigned int nbr_syms;
- struct carsym *syms;
-
/* DCX (decompression) data. */
unsigned int nbr_dcxsbm;
struct dcxsbm_desc *dcxsbm;
static const unsigned char eotdesc[] = { 0x03, 0x00, 0x77, 0x00, 0x77, 0x00 };
+/* Describe the current state of carsym entries while building the archive
+ table of content. Things are simple with Alpha archives as the number
+ of entries is known, but with IA64 archives a entry can make a reference
+ to severals members. Therefore we must be able to extend the table on the
+ fly, but it should be allocated on the bfd - which doesn't support realloc.
+ To reduce the overhead, the table is initially allocated in the BFD's
+ objalloc and extended if necessary on the heap. In the later case, it
+ is finally copied to the BFD's objalloc so that it will automatically be
+ freed. */
+
+struct carsym_mem
+{
+ /* The table of content. */
+ struct carsym *idx;
+
+ /* Number of entries used in the table. */
+ unsigned int nbr;
+
+ /* Maximum number of entries. */
+ unsigned int max;
+
+ /* If true, the table was reallocated on the heap. If false, it is still
+ in the BFD's objalloc. */
+ bfd_boolean realloced;
+};
+
+/* Simply add a name to the index. */
+
+static bfd_boolean
+vms_add_index (struct carsym_mem *cs, char *name,
+ unsigned int idx_vbn, unsigned int idx_off)
+{
+ if (cs->nbr == cs->max)
+ {
+ struct carsym *n;
+
+ cs->max = 2 * cs->max + 32;
+
+ if (!cs->realloced)
+ {
+ n = bfd_malloc2 (cs->max, sizeof (struct carsym));
+ if (n == NULL)
+ return FALSE;
+ memcpy (n, cs->idx, cs->nbr * sizeof (struct carsym));
+ /* And unfortunately we can't free cs->idx. */
+ }
+ else
+ {
+ n = bfd_realloc_or_free (cs->idx, cs->nbr * sizeof (struct carsym));
+ if (n == NULL)
+ return FALSE;
+ }
+ cs->idx = n;
+ cs->realloced = TRUE;
+ }
+ cs->idx[cs->nbr].file_offset = (idx_vbn - 1) * VMS_BLOCK_SIZE + idx_off;
+ cs->idx[cs->nbr].name = name;
+ cs->nbr++;
+ return TRUE;
+}
+
+/* Follow all member of a lns list (pointed by RFA) and add indexes for
+ NAME. Return FALSE in case of error. */
+
+static bfd_boolean
+vms_add_indexes_from_list (bfd *abfd, struct carsym_mem *cs, char *name,
+ struct vms_rfa *rfa)
+{
+ struct vms_lns lns;
+ unsigned int vbn;
+ file_ptr off;
+
+ while (1)
+ {
+ vbn = bfd_getl32 (rfa->vbn);
+ if (vbn == 0)
+ return TRUE;
+
+ /* Read the LHS. */
+ off = (vbn - 1) * VMS_BLOCK_SIZE + bfd_getl16 (rfa->offset);
+ if (bfd_seek (abfd, off, SEEK_SET) != 0
+ || bfd_bread (&lns, sizeof (lns), abfd) != sizeof (lns))
+ return FALSE;
+
+ if (!vms_add_index (cs, name,
+ bfd_getl32 (lns.modrfa.vbn),
+ bfd_getl16 (lns.modrfa.offset)))
+ return FALSE;
+
+ rfa = &lns.nxtrfa;
+ }
+}
+
+/* Read block VBN from ABFD and store it into BLK. Return FALSE in case of error. */
+
+static bfd_boolean
+vms_read_block (bfd *abfd, unsigned int vbn, void *blk)
+{
+ file_ptr off;
+
+ off = (vbn - 1) * VMS_BLOCK_SIZE;
+ if (bfd_seek (abfd, off, SEEK_SET) != 0
+ || bfd_bread (blk, VMS_BLOCK_SIZE, abfd) != VMS_BLOCK_SIZE)
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Write the content of BLK to block VBN of ABFD. Return FALSE in case of error. */
+
+static bfd_boolean
+vms_write_block (bfd *abfd, unsigned int vbn, void *blk)
+{
+ file_ptr off;
+
+ off = (vbn - 1) * VMS_BLOCK_SIZE;
+ if (bfd_seek (abfd, off, SEEK_SET) != 0
+ || bfd_bwrite (blk, VMS_BLOCK_SIZE, abfd) != VMS_BLOCK_SIZE)
+ return FALSE;
+
+ return TRUE;
+}
+
/* Read index block VBN and put the entry in **IDX (which is updated).
If the entry is indirect, recurse. */
static bfd_boolean
-vms_traverse_index (bfd *abfd, unsigned int vbn, struct carsym **idx)
+vms_traverse_index (bfd *abfd, unsigned int vbn, struct carsym_mem *cs)
{
struct vms_indexdef indexdef;
- unsigned int used;
file_ptr off;
- unsigned int i;
+ unsigned char *p;
+ unsigned char *endp;
/* Read the index block. */
- off = (vbn - 1) * VMS_BLOCK_SIZE;
- if (bfd_seek (abfd, off, SEEK_SET) != 0
- || bfd_bread (&indexdef, sizeof (indexdef), abfd) != sizeof (indexdef))
+ BFD_ASSERT (sizeof (indexdef) == VMS_BLOCK_SIZE);
+ if (!vms_read_block (abfd, vbn, &indexdef))
return FALSE;
/* Traverse it. */
- used = bfd_getl16 (indexdef.used);
- for (i = 0; i < used;)
+ p = &indexdef.keys[0];
+ endp = p + bfd_getl16 (indexdef.used);
+ while (p < endp)
{
unsigned int idx_vbn;
unsigned int idx_off;
unsigned int keylen;
unsigned char *keyname;
- unsigned char *ridx = (unsigned char *)&indexdef.keys[i];
- unsigned int len;
-
- idx_vbn = bfd_getl32 (ridx);
- idx_off = bfd_getl16 (ridx + 4);
-
- /* Illegal value. */
- if (idx_vbn == 0)
- return FALSE;
+ unsigned int flags;
/* Extract key length. */
- if (bfd_libdata (abfd)->ver == 3)
+ if (bfd_libdata (abfd)->ver == LBR_MAJORID)
{
- keylen = ridx[6];
- len = 7;
+ struct vms_idx *ridx = (struct vms_idx *)p;
+
+ idx_vbn = bfd_getl32 (ridx->rfa.vbn);
+ idx_off = bfd_getl16 (ridx->rfa.offset);
+
+ keylen = ridx->keylen;
+ flags = 0;
+ keyname = ridx->keyname;
}
- else if (bfd_libdata (abfd)->ver == 4)
+ else if (bfd_libdata (abfd)->ver == LBR_ELFMAJORID)
{
- keylen = bfd_getl16 (ridx + 6);
- len = 9;
+ struct vms_elfidx *ridx = (struct vms_elfidx *)p;
+
+ idx_vbn = bfd_getl32 (ridx->rfa.vbn);
+ idx_off = bfd_getl16 (ridx->rfa.offset);
+
+ keylen = bfd_getl16 (ridx->keylen);
+ flags = ridx->flags;
+ keyname = ridx->keyname;
}
else
return FALSE;
- keyname = ridx + len;
- i += len + keylen;
+ /* Illegal value. */
+ if (idx_vbn == 0)
+ return FALSE;
if (idx_off == RFADEF__C_INDEX)
{
/* Indirect entry. Recurse. */
- if (!vms_traverse_index (abfd, idx_vbn, idx))
+ if (!vms_traverse_index (abfd, idx_vbn, cs))
return FALSE;
}
else
/* Add a new entry. */
char *name;
- name = bfd_alloc (abfd, keylen + 1);
- if (name == NULL)
- return FALSE;
- memcpy (name, keyname, keylen);
+ if (flags & ELFIDX__SYMESC)
+ {
+ /* Extended key name. */
+ unsigned int noff = 0;
+ unsigned int koff;
+ unsigned int kvbn;
+ struct vms_kbn *kbn;
+ unsigned char kblk[VMS_BLOCK_SIZE];
+
+ /* Sanity check. */
+ if (keylen != sizeof (struct vms_kbn))
+ return FALSE;
+
+ kbn = (struct vms_kbn *)keyname;
+ keylen = bfd_getl16 (kbn->keylen);
+
+ name = bfd_alloc (abfd, keylen + 1);
+ if (name == NULL)
+ return FALSE;
+ kvbn = bfd_getl32 (kbn->rfa.vbn);
+ koff = bfd_getl16 (kbn->rfa.offset);
+
+ /* Read the key, chunk by chunk. */
+ do
+ {
+ unsigned int klen;
+
+ if (!vms_read_block (abfd, kvbn, kblk))
+ return FALSE;
+ kbn = (struct vms_kbn *)(kblk + koff);
+ klen = bfd_getl16 (kbn->keylen);
+ kvbn = bfd_getl32 (kbn->rfa.vbn);
+ koff = bfd_getl16 (kbn->rfa.offset);
+
+ memcpy (name + noff, kbn + 1, klen);
+ noff += klen;
+ }
+ while (kvbn != 0);
+
+ /* Sanity check. */
+ if (noff != keylen)
+ return FALSE;
+ }
+ else
+ {
+ /* Usual key name. */
+ name = bfd_alloc (abfd, keylen + 1);
+ if (name == NULL)
+ return FALSE;
+
+ memcpy (name, keyname, keylen);
+ }
name[keylen] = 0;
- (*idx)->file_offset = (idx_vbn - 1) * VMS_BLOCK_SIZE + idx_off;
- (*idx)->name = name;
- (*idx)++;
+
+ if (flags & ELFIDX__LISTRFA)
+ {
+ struct vms_lhs lhs;
+
+ /* Read the LHS. */
+ off = (idx_vbn - 1) * VMS_BLOCK_SIZE + idx_off;
+ if (bfd_seek (abfd, off, SEEK_SET) != 0
+ || bfd_bread (&lhs, sizeof (lhs), abfd) != sizeof (lhs))
+ return FALSE;
+
+ /* FIXME: this adds extra entries that were not accounted. */
+ if (!vms_add_indexes_from_list (abfd, cs, name, &lhs.ng_g_rfa))
+ return FALSE;
+ if (!vms_add_indexes_from_list (abfd, cs, name, &lhs.ng_wk_rfa))
+ return FALSE;
+ if (!vms_add_indexes_from_list (abfd, cs, name, &lhs.g_g_rfa))
+ return FALSE;
+ if (!vms_add_indexes_from_list (abfd, cs, name, &lhs.g_wk_rfa))
+ return FALSE;
+ }
+ else
+ {
+ if (!vms_add_index (cs, name, idx_vbn, idx_off))
+ return FALSE;
+ }
}
+
+ /* Point to the next index entry. */
+ p = keyname + keylen;
}
return TRUE;
/* Read index #IDX, which must have NBREL entries. */
static struct carsym *
-vms_lib_read_index (bfd *abfd, int idx, unsigned int nbrel)
+vms_lib_read_index (bfd *abfd, int idx, unsigned int *nbrel)
{
- struct carsym *res;
- struct carsym *el;
struct vms_idd idd;
unsigned int flags;
unsigned int vbn;
+ struct carsym *csbuf;
+ struct carsym_mem csm;
/* Read index desription. */
if (bfd_seek (abfd, LHD_IDXDESC + idx * IDD_LENGTH, SEEK_SET) != 0
|| !(flags & IDD__FLAGS_VARLENIDX))
return NULL;
- res = bfd_alloc (abfd, nbrel * sizeof (struct carsym));
- if (res == NULL)
+ csbuf = bfd_alloc (abfd, *nbrel * sizeof (struct carsym));
+ if (csbuf == NULL)
return NULL;
- el = res;
+ csm.max = *nbrel;
+ csm.nbr = 0;
+ csm.realloced = FALSE;
+ csm.idx = csbuf;
/* Note: if the index is empty, there is no block to traverse. */
vbn = bfd_getl32 (idd.vbn);
- if (vbn != 0 && !vms_traverse_index (abfd, vbn, &el))
+ if (vbn != 0 && !vms_traverse_index (abfd, vbn, &csm))
{
- bfd_release (abfd, res);
+ if (csm.realloced && csm.idx != NULL)
+ free (csm.idx);
+
+ /* Note: in case of error, we can free what was allocated on the
+ BFD's objalloc. */
+ bfd_release (abfd, csbuf);
return NULL;
}
- if ((unsigned int)(el - res) != nbrel)
+ if (csm.realloced)
{
- /* Inconsistency between the number of modules declared and the number
- of modules found in the index. */
- bfd_release (abfd, res);
- return NULL;
+ /* There are more entries than the first estimate. Allocate on
+ the BFD's objalloc. */
+ csbuf = bfd_alloc (abfd, csm.nbr * sizeof (struct carsym));
+ if (csbuf == NULL)
+ return NULL;
+ memcpy (csbuf, csm.idx, csm.nbr * sizeof (struct carsym));
+ free (csm.idx);
+ *nbrel = csm.nbr;
}
- return res;
+ return csbuf;
}
/* Standard function. */
{
struct vms_lhd lhd;
unsigned int sanity;
+ unsigned int majorid;
struct lib_tdata *tdata_hold;
struct lib_tdata *tdata;
unsigned int dcxvbn;
+ unsigned int nbr_ent;
/* Read header. */
if (bfd_bread (&lhd, sizeof (lhd), abfd) != sizeof (lhd))
/* Check sanity (= magic) number. */
sanity = bfd_getl32 (lhd.sanity);
if (!(sanity == LHD_SANEID3
- || sanity == LHD_SANEID4
+ || sanity == LHD_SANEID6
|| sanity == LHD_SANEID_DCX))
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
+ majorid = bfd_getl32 (lhd.majorid);
/* Check archive kind. */
switch (kind)
{
case vms_lib_alpha:
if ((lhd.type != LBR__C_TYP_EOBJ && lhd.type != LBR__C_TYP_ESHSTB)
- || bfd_getl32 (lhd.majorid) != 3
+ || majorid != LBR_MAJORID
+ || lhd.nindex != 2)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+ break;
+ case vms_lib_ia64:
+ if ((lhd.type != LBR__C_TYP_IOBJ && lhd.type != LBR__C_TYP_ISHSTB)
+ || majorid != LBR_ELFMAJORID
|| lhd.nindex != 2)
{
bfd_set_error (bfd_error_wrong_format);
if ((lhd.type != LBR__C_TYP_TXT
&& lhd.type != LBR__C_TYP_MLB
&& lhd.type != LBR__C_TYP_HLP)
- || bfd_getl32 (lhd.majorid) != 3
+ || majorid != LBR_MAJORID
|| lhd.nindex != 1)
{
bfd_set_error (bfd_error_wrong_format);
if (tdata == NULL)
return NULL;
abfd->tdata.any = (void *)tdata;
- tdata->ver = bfd_getl32 (lhd.majorid);
+ tdata->ver = majorid;
tdata->mhd_size = MHD__C_USRDAT + lhd.mhdusz;
tdata->type = lhd.type;
tdata->kind = kind;
+ tdata->credat_lo = bfd_getl32 (lhd.credat + 0);
+ tdata->credat_hi = bfd_getl32 (lhd.credat + 4);
/* Read indexes. */
tdata->nbr_modules = bfd_getl32 (lhd.modcnt);
- tdata->nbr_syms = bfd_getl32 (lhd.idxcnt) - tdata->nbr_modules;
- tdata->modules = vms_lib_read_index (abfd, 0, tdata->nbr_modules);
- if (tdata->modules == NULL)
+ tdata->artdata.symdef_count = bfd_getl32 (lhd.idxcnt) - tdata->nbr_modules;
+ nbr_ent = tdata->nbr_modules;
+ tdata->modules = vms_lib_read_index (abfd, 0, &nbr_ent);
+ if (tdata->modules == NULL || nbr_ent != tdata->nbr_modules)
goto err;
if (lhd.nindex == 2)
{
- tdata->syms = vms_lib_read_index (abfd, 1, tdata->nbr_syms);
- if (tdata->syms == NULL)
+ nbr_ent = tdata->artdata.symdef_count;
+ tdata->artdata.symdefs = vms_lib_read_index (abfd, 1, &nbr_ent);
+ if (tdata->artdata.symdefs == NULL)
goto err;
+ /* Only IA64 archives may have more entries in the index that what
+ was declared. */
+ if (nbr_ent != tdata->artdata.symdef_count
+ && kind != vms_lib_ia64)
+ goto err;
+ tdata->artdata.symdef_count = nbr_ent;
}
tdata->cache = bfd_zalloc (abfd, sizeof (bfd *) * tdata->nbr_modules);
if (tdata->cache == NULL)
struct dcxsbm_desc *sbmdesc = &tdata->dcxsbm[i];
unsigned int sbm_len;
unsigned int sbm_sz;
+ unsigned int off;
unsigned char *data = (unsigned char *)sbm;
unsigned char *buf1;
unsigned int l, j;
sbmdesc->max_char = sbm->max_char;
sbm_len = sbmdesc->max_char - sbmdesc->min_char + 1;
l = (2 * sbm_len + 7) / 8;
- BFD_ASSERT (sbm_sz >= sizeof (struct vms_dcxsbm) + l + 3 * sbm_len);
+ BFD_ASSERT
+ (sbm_sz >= sizeof (struct vms_dcxsbm) + l + 3 * sbm_len
+ || (tdata->nbr_dcxsbm == 1
+ && sbm_sz >= sizeof (struct vms_dcxsbm) + l + sbm_len));
sbmdesc->flags = (unsigned char *)bfd_alloc (abfd, l);
memcpy (sbmdesc->flags, data + bfd_getl16 (sbm->flags), l);
sbmdesc->nodes = (unsigned char *)bfd_alloc (abfd, 2 * sbm_len);
memcpy (sbmdesc->nodes, data + bfd_getl16 (sbm->nodes), 2 * sbm_len);
- sbmdesc->next = (unsigned short *)bfd_alloc
- (abfd, sbm_len * sizeof (unsigned short));
- buf1 = data + bfd_getl16 (sbm->next);
- for (j = 0; j < sbm_len; j++)
- sbmdesc->next[j] = bfd_getl16 (buf1 + j * 2);
+ off = bfd_getl16 (sbm->next);
+ if (off != 0)
+ {
+ /* Read the 'next' array. */
+ sbmdesc->next = (unsigned short *)bfd_alloc
+ (abfd, sbm_len * sizeof (unsigned short));
+ buf1 = data + off;
+ for (j = 0; j < sbm_len; j++)
+ sbmdesc->next[j] = bfd_getl16 (buf1 + j * 2);
+ }
+ else
+ {
+ /* There is no next array if there is only one submap. */
+ BFD_ASSERT (tdata->nbr_dcxsbm == 1);
+ sbmdesc->next = NULL;
+ }
}
free (buf);
}
/* The map is always present. Also mark shared image library. */
abfd->has_armap = TRUE;
- if (tdata->type == LBR__C_TYP_ESHSTB)
+ if (tdata->type == LBR__C_TYP_ESHSTB || tdata->type == LBR__C_TYP_ISHSTB)
abfd->is_thin_archive = TRUE;
return abfd->xvec;
return _bfd_vms_lib_archive_p (abfd, vms_lib_alpha);
}
+/* Standard function for ia64 libraries. */
+
+const bfd_target *
+_bfd_vms_lib_ia64_archive_p (bfd *abfd)
+{
+ return _bfd_vms_lib_archive_p (abfd, vms_lib_ia64);
+}
+
/* Standard function for text libraries. */
static const bfd_target *
/* Standard bfd function. */
-bfd_boolean
-_bfd_vms_lib_mkarchive (bfd *abfd)
+static bfd_boolean
+_bfd_vms_lib_mkarchive (bfd *abfd, enum vms_lib_kind kind)
{
struct lib_tdata *tdata;
return FALSE;
abfd->tdata.any = (void *)tdata;
- tdata->ver = 3;
- tdata->mhd_size = sizeof (struct vms_mhd);
- tdata->type = LBR__C_TYP_EOBJ;
+ vms_get_time (&tdata->credat_hi, &tdata->credat_lo);
+
+ tdata->kind = kind;
+ switch (kind)
+ {
+ case vms_lib_alpha:
+ tdata->ver = LBR_MAJORID;
+ tdata->mhd_size = offsetof (struct vms_mhd, pad1);
+ tdata->type = LBR__C_TYP_EOBJ;
+ break;
+ case vms_lib_ia64:
+ tdata->ver = LBR_ELFMAJORID;
+ tdata->mhd_size = sizeof (struct vms_mhd);
+ tdata->type = LBR__C_TYP_IOBJ;
+ break;
+ default:
+ abort ();
+ }
tdata->nbr_modules = 0;
- tdata->nbr_syms = 0;
+ tdata->artdata.symdef_count = 0;
tdata->modules = NULL;
- tdata->syms = NULL;
+ tdata->artdata.symdefs = NULL;
tdata->cache = NULL;
return TRUE;
}
+bfd_boolean
+_bfd_vms_lib_alpha_mkarchive (bfd *abfd)
+{
+ return _bfd_vms_lib_mkarchive (abfd, vms_lib_alpha);
+}
+
+bfd_boolean
+_bfd_vms_lib_ia64_mkarchive (bfd *abfd)
+{
+ return _bfd_vms_lib_mkarchive (abfd, vms_lib_ia64);
+}
+
/* Find NAME in the symbol index. Return the index. */
symindex
_bfd_vms_lib_find_symbol (bfd *abfd, const char *name)
{
struct lib_tdata *tdata = bfd_libdata (abfd);
+ carsym *syms = tdata->artdata.symdefs;
int lo, hi;
/* Open-coded binary search for speed. */
lo = 0;
- hi = tdata->nbr_syms - 1;
+ hi = tdata->artdata.symdef_count - 1;
while (lo <= hi)
{
int mid = lo + (hi - lo) / 2;
int diff;
- diff = (char)(name[0] - tdata->syms[mid].name[0]);
+ diff = (char)(name[0] - syms[mid].name[0]);
if (diff == 0)
- diff = strcmp (name, tdata->syms[mid].name);
+ diff = strcmp (name, syms[mid].name);
if (diff == 0)
- return tdata->syms[mid].file_offset;
+ return mid;
else if (diff < 0)
hi = mid - 1;
else
lo = mid + 1;
}
- return 0;
+ return BFD_NO_MORE_SYMBOLS;
}
/* IO vector for archive member. Need that because members are not linearly
if (!vms_lib_read_block (abfd))
return -1;
+ /* Do not read past the data block, do not read more than requested. */
l = DATA__LENGTH - vec->blk_off;
if (l > nbytes)
l = nbytes;
return 0;
if (buf != NULL)
{
+ /* Really read into BUF. */
if (bfd_bread (buf, l, abfd->my_archive) != l)
return -1;
}
else
{
+ /* Make as if we are reading. */
if (bfd_seek (abfd->my_archive, l, SEEK_CUR) != 0)
return -1;
}
{
unsigned char v = sbm->nodes[offset];
- sbm = vec->dcxsbms + sbm->next[v];
+ if (sbm->next != NULL)
+ sbm = vec->dcxsbms + sbm->next[v];
offset = 0;
res++;
if (vec->rec_rem == 0)
{
+ /* End of record reached. */
if (bfd_libdata (abfd->my_archive)->kind == vms_lib_txt)
{
if ((vec->rec_len & 1) == 1
/* Read Record length + MHD + align byte. */
len = tdata->mhd_size;
if (vms_lib_bread_raw (el, buf, 2) != 2)
- return -1;
+ return FALSE;
if (bfd_getl16 (buf) != len)
- return -1;
+ return FALSE;
len = (len + 1) & ~1;
BFD_ASSERT (len <= sizeof (buf));
if (vms_lib_bread_raw (el, buf, len) != len)
- return -1;
+ return FALSE;
/* Get info from mhd. */
mhd = (struct vms_mhd *)buf;
- if (len >= sizeof (struct vms_mhd))
+ /* Check id. */
+ if (mhd->id != MHD__C_MHDID)
+ return FALSE;
+ if (len >= MHD__C_MHDLEN + 1)
el->selective_search = (mhd->objstat & MHD__M_SELSRC) ? 1 : 0;
el->mtime = vms_rawtime_to_time_t (mhd->datim);
el->mtime_set = TRUE;
return TRUE;
}
-/* Standard function: get member at IDX. */
+/* Get member MODIDX. Return NULL in case of error. */
-bfd *
-_bfd_vms_lib_get_elt_at_index (bfd *abfd, symindex idx)
+static bfd *
+_bfd_vms_lib_get_module (bfd *abfd, unsigned int modidx)
{
struct lib_tdata *tdata = bfd_libdata (abfd);
bfd *res;
- unsigned int i;
+ file_ptr file_off;
- /* Linear-scan. */
- for (i = 0; i < tdata->nbr_modules; i++)
- {
- if (tdata->modules[i].file_offset == (file_ptr)idx)
- break;
- }
-
- /* Invalid index. */
- if (i >= tdata->nbr_modules)
+ /* Sanity check. */
+ if (modidx >= tdata->nbr_modules)
return NULL;
/* Already loaded. */
- if (tdata->cache[i])
- return tdata->cache[i];
+ if (tdata->cache[modidx])
+ return tdata->cache[modidx];
/* Build it. */
- res = _bfd_create_empty_archive_element_shell (abfd);
- if (!vms_lib_bopen (res, idx))
- return NULL;
- res->filename = tdata->modules[i].name;
+ file_off = tdata->modules[modidx].file_offset;
+ if (tdata->type != LBR__C_TYP_IOBJ)
+ {
+ res = _bfd_create_empty_archive_element_shell (abfd);
+ if (res == NULL)
+ return NULL;
+
+ /* Special reader to deal with data blocks. */
+ if (!vms_lib_bopen (res, file_off))
+ return NULL;
+ }
+ else
+ {
+ char buf[256];
+ struct vms_mhd *mhd;
+ struct areltdata *arelt;
+
+ /* Sanity check. The MHD must be big enough to contain module size. */
+ if (tdata->mhd_size < offsetof (struct vms_mhd, modsize) + 4)
+ return NULL;
+
+ /* Read the MHD now. */
+ if (bfd_seek (abfd, file_off, SEEK_SET) != 0)
+ return NULL;
+ if (bfd_bread (buf, tdata->mhd_size, abfd) != tdata->mhd_size)
+ return NULL;
+
+ res = _bfd_create_empty_archive_element_shell (abfd);
+ if (res == NULL)
+ return NULL;
+ arelt = bfd_zalloc (res, sizeof (*arelt));
+ if (arelt == NULL)
+ return NULL;
+ res->arelt_data = arelt;
+
+ /* Get info from mhd. */
+ mhd = (struct vms_mhd *)buf;
+ if (mhd->id != MHD__C_MHDID)
+ return NULL;
+ if (tdata->mhd_size >= offsetof (struct vms_mhd, objstat) + 1)
+ res->selective_search = (mhd->objstat & MHD__M_SELSRC) ? 1 : 0;
+ res->mtime = vms_rawtime_to_time_t (mhd->datim);
+ res->mtime_set = TRUE;
+
+ arelt->parsed_size = bfd_getl32 (mhd->modsize);
+
+ /* No need for a special reader as members are stored linearly.
+ Just skip the MHD. */
+ res->origin = file_off + tdata->mhd_size;
+ }
+
+ res->filename = tdata->modules[modidx].name;
- tdata->cache[i] = res;
+ tdata->cache[modidx] = res;
return res;
}
+/* Standard function: get member at IDX. */
+
+bfd *
+_bfd_vms_lib_get_elt_at_index (bfd *abfd, symindex symidx)
+{
+ struct lib_tdata *tdata = bfd_libdata (abfd);
+ file_ptr file_off;
+ unsigned int modidx;
+
+ /* Check symidx. */
+ if (symidx > tdata->artdata.symdef_count)
+ return NULL;
+ file_off = tdata->artdata.symdefs[symidx].file_offset;
+
+ /* Linear-scan. */
+ for (modidx = 0; modidx < tdata->nbr_modules; modidx++)
+ {
+ if (tdata->modules[modidx].file_offset == file_off)
+ break;
+ }
+ if (modidx >= tdata->nbr_modules)
+ return NULL;
+
+ return _bfd_vms_lib_get_module (abfd, modidx);
+}
+
/* Elements of an imagelib are stubs. You can get the real image with this
function. */
return NULL;
}
- res = _bfd_vms_lib_get_elt_at_index
- (archive, bfd_libdata (archive)->modules[idx].file_offset);
+ res = _bfd_vms_lib_get_module (archive, idx);
if (res == NULL)
return res;
res->proxy_origin = idx;
int
_bfd_vms_lib_generic_stat_arch_elt (bfd *abfd, struct stat *st)
{
- struct vms_lib_iovec *vec = (struct vms_lib_iovec *) abfd->iostream;
+ struct lib_tdata *tdata;
+ /* Sanity check. */
if (abfd->my_archive == NULL)
{
bfd_set_error (bfd_error_invalid_operation);
return -1;
}
- if (vec->file_len == (ufile_ptr)-1)
+ tdata = bfd_libdata (abfd->my_archive);
+ if (tdata->type != LBR__C_TYP_IOBJ)
{
- if (vms_lib_bseek (abfd, 0, SEEK_SET) != 0)
- return -1;
+ struct vms_lib_iovec *vec = (struct vms_lib_iovec *) abfd->iostream;
- /* Compute length. */
- while (vms_lib_bread (abfd, NULL, 1 << 20) > 0)
- ;
+ if (vec->file_len == (ufile_ptr)-1)
+ {
+ if (vms_lib_bseek (abfd, 0, SEEK_SET) != 0)
+ return -1;
+
+ /* Compute length. */
+ while (vms_lib_bread (abfd, NULL, 1 << 20) > 0)
+ ;
+ }
+ st->st_size = vec->file_len;
+ }
+ else
+ {
+ st->st_size = ((struct areltdata *)abfd->arelt_data)->parsed_size;
}
- st->st_size = vec->file_len;
if (abfd->mtime_set)
st->st_mtime = abfd->mtime;
else
/* Internal representation of an index entry. */
-struct vms_index
+struct lib_index
{
/* Corresponding archive member. */
bfd *abfd;
/* Used to sort index entries. */
static int
-vms_index_cmp (const void *lv, const void *rv)
+lib_index_cmp (const void *lv, const void *rv)
{
- const struct vms_index *l = lv;
- const struct vms_index *r = rv;
+ const struct lib_index *l = lv;
+ const struct lib_index *r = rv;
return strcmp (l->name, r->name);
}
/* Get the size of an index entry. */
static unsigned int
-get_idxlen (struct vms_index *idx)
+get_idxlen (struct lib_index *idx, bfd_boolean is_elfidx)
{
- return 7 + idx->namlen;
+ if (is_elfidx)
+ {
+ if (idx->namlen > MAX_KEYLEN)
+ return 9 + sizeof (struct vms_rfa);
+ else
+ return 9 + idx->namlen;
+ }
+ else
+ return 7 + idx->namlen;
}
/* Write the index. VBN is the first vbn to be used, and will contain
static bfd_boolean
vms_write_index (bfd *abfd,
- struct vms_index *idx, unsigned int nbr, unsigned int *vbn,
- unsigned int *topvbn)
+ struct lib_index *idx, unsigned int nbr, unsigned int *vbn,
+ unsigned int *topvbn, bfd_boolean is_elfidx)
{
unsigned int i;
int j;
unsigned short lastlen;
} blk[MAX_LEVEL];
+ /* The kbn blocks are used to store long symbol names. */
+ unsigned int kbn_sz = 0; /* Number of bytes availble in the kbn block. */
+ unsigned int kbn_vbn = 0; /* VBN of the kbn block. */
+ unsigned char *kbn_blk = NULL; /* Contents of the kbn block. */
+
if (nbr == 0)
{
+ /* No entries. Very easy to handle. */
if (topvbn != NULL)
*topvbn = 0;
return TRUE;
if (abfd == NULL)
{
/* Sort the index the first time this function is called. */
- qsort (idx, nbr, sizeof (struct vms_index), vms_index_cmp);
+ qsort (idx, nbr, sizeof (struct lib_index), lib_index_cmp);
}
/* Allocate first index block. */
for (i = 0; i < nbr; i++, idx++)
{
- unsigned int idxlen = get_idxlen (idx);
- struct vms_idxdef *en;
+ unsigned int idxlen;
int flush = 0;
+ unsigned int key_vbn = 0;
+ unsigned int key_off = 0;
+
+ idxlen = get_idxlen (idx, is_elfidx);
+
+ if (is_elfidx && idx->namlen >= MAX_KEYLEN)
+ {
+ /* If the name is too long, write it in the kbn block. */
+ unsigned int kl = idx->namlen;
+ unsigned int kl_chunk;
+ const char *key = idx->name;
+
+ /* Write the name in the kbn, chunk after chunk. */
+ do
+ {
+ if (kbn_sz < sizeof (struct vms_kbn))
+ {
+ /* Not enough room in the kbn block. */
+ if (abfd != NULL)
+ {
+ /* Write it to the disk (if there is one). */
+ if (kbn_vbn != 0)
+ {
+ if (vms_write_block (abfd, kbn_vbn, kbn_blk) != TRUE)
+ return FALSE;
+ }
+ else
+ {
+ kbn_blk = bfd_malloc (VMS_BLOCK_SIZE);
+ if (kbn_blk == NULL)
+ return FALSE;
+ }
+ *(unsigned short *)kbn_blk = 0;
+ }
+ kbn_vbn = (*vbn)++;
+ kbn_sz = VMS_BLOCK_SIZE - 2;
+ }
+ if (kl + sizeof (struct vms_kbn) > kbn_sz)
+ kl_chunk = kbn_sz - sizeof (struct vms_kbn);
+ else
+ kl_chunk = kl;
+
+ if (kbn_blk != NULL)
+ {
+ struct vms_kbn *kbn;
+
+ kbn = (struct vms_kbn *)(kbn_blk + VMS_BLOCK_SIZE - kbn_sz);
+
+ if (key_vbn == 0)
+ {
+ /* Save the rfa of the first chunk. */
+ key_vbn = kbn_vbn;
+ key_off = VMS_BLOCK_SIZE - kbn_sz;
+ }
+
+ bfd_putl16 (kl_chunk, kbn->keylen);
+ if (kl_chunk == kl)
+ {
+ /* No next chunk. */
+ bfd_putl32 (0, kbn->rfa.vbn);
+ bfd_putl16 (0, kbn->rfa.offset);
+ }
+ else
+ {
+ /* Next chunk will be at the start of the next block. */
+ bfd_putl32 (*vbn, kbn->rfa.vbn);
+ bfd_putl16 (2, kbn->rfa.offset);
+ }
+ memcpy ((char *)(kbn + 1), key, kl_chunk);
+ key += kl_chunk;
+ }
+ kl -= kl_chunk;
+ kl_chunk = (kl_chunk + 1) & ~1; /* Always align. */
+ kbn_sz -= kl_chunk + sizeof (struct vms_kbn);
+ }
+ while (kl > 0);
+ }
/* Check if a block might overflow. In this case we will flush this
block and all the blocks below it. */
/* Update parent block: write the new entry. */
if (abfd != NULL)
{
- en = (struct vms_idxdef *)(rblk[j]->keys + blk[j].len);
- memcpy (rblk[j + 1]->keys + blk[j + 1].len, en,
+ struct vms_rfa *rfa;
+
+ /* Copy the whole entry. */
+ memcpy (rblk[j + 1]->keys + blk[j + 1].len,
+ rblk[j]->keys + blk[j].len,
blk[j].lastlen);
- en = (struct vms_idxdef *)
- (rblk[j + 1]->keys + blk[j + 1].len);
- bfd_putl32 (blk[j].vbn, en->vbn);
- bfd_putl16 (RFADEF__C_INDEX, en->offset);
+ /* Fix the entry (which in always the first field of an entry. */
+ rfa = (struct vms_rfa *)(rblk[j + 1]->keys + blk[j + 1].len);
+ bfd_putl32 (blk[j].vbn, rfa->vbn);
+ bfd_putl16 (RFADEF__C_INDEX, rfa->offset);
}
if (j + 1 == flush)
if (abfd != NULL)
{
bfd_putl16 (blk[j].len + blk[j].lastlen, rblk[j]->used);
- if (bfd_seek (abfd, (blk[j].vbn - 1) * VMS_BLOCK_SIZE,
- SEEK_SET) != 0)
- return FALSE;
- if (bfd_bwrite (rblk[j], sizeof (struct vms_indexdef), abfd)
- != sizeof (struct vms_indexdef))
+ if (vms_write_block (abfd, blk[j].vbn, rblk[j]) != TRUE)
return FALSE;
}
if (abfd != NULL)
{
- en = (struct vms_idxdef *)(rblk[j]->keys + blk[j].len);
+ struct vms_rfa *rfa;
+
+ rfa = (struct vms_rfa *)(rblk[j]->keys + blk[j].len);
bfd_putl32 ((idx->abfd->proxy_origin / VMS_BLOCK_SIZE) + 1,
- en->vbn);
+ rfa->vbn);
bfd_putl16
- ((idx->abfd->proxy_origin % VMS_BLOCK_SIZE) + DATA__DATA,
- en->offset);
- en->keylen = idx->namlen;
- memcpy (en->keyname, idx->name, idx->namlen);
+ ((idx->abfd->proxy_origin % VMS_BLOCK_SIZE)
+ + (is_elfidx ? 0 : DATA__DATA),
+ rfa->offset);
+
+ if (is_elfidx)
+ {
+ /* Use elfidx format. */
+ struct vms_elfidx *en = (struct vms_elfidx *)rfa;
+
+ en->flags = 0;
+ if (key_vbn != 0)
+ {
+ /* Long symbol name. */
+ struct vms_kbn *k = (struct vms_kbn *)(en->keyname);
+ bfd_putl16 (sizeof (struct vms_kbn), en->keylen);
+ bfd_putl16 (idx->namlen, k->keylen);
+ bfd_putl32 (key_vbn, k->rfa.vbn);
+ bfd_putl16 (key_off, k->rfa.offset);
+ en->flags |= ELFIDX__SYMESC;
+ }
+ else
+ {
+ bfd_putl16 (idx->namlen, en->keylen);
+ memcpy (en->keyname, idx->name, idx->namlen);
+ }
+ }
+ else
+ {
+ /* Use idx format. */
+ struct vms_idx *en = (struct vms_idx *)rfa;
+ en->keylen = idx->namlen;
+ memcpy (en->keyname, idx->name, idx->namlen);
+ }
}
}
if (j > 0)
{
/* Update parent block: write the new entry. */
- struct vms_idxdef *en;
- struct vms_idxdef *par;
+ unsigned char *en;
+ unsigned char *par;
+ struct vms_rfa *rfa;
- en = (struct vms_idxdef *)(rblk[j - 1]->keys + blk[j - 1].len);
- par = (struct vms_idxdef *)(rblk[j]->keys + blk[j].len);
+ en = rblk[j - 1]->keys + blk[j - 1].len;
+ par = rblk[j]->keys + blk[j].len;
memcpy (par, en, blk[j - 1].lastlen);
- bfd_putl32 (blk[j - 1].vbn, par->vbn);
- bfd_putl16 (RFADEF__C_INDEX, par->offset);
+ rfa = (struct vms_rfa *)par;
+ bfd_putl32 (blk[j - 1].vbn, rfa->vbn);
+ bfd_putl16 (RFADEF__C_INDEX, rfa->offset);
}
/* Write this block on the disk. */
bfd_putl16 (blk[j].len + blk[j].lastlen, rblk[j]->used);
- if (bfd_seek (abfd, (blk[j].vbn - 1) * VMS_BLOCK_SIZE,
- SEEK_SET) != 0)
- return FALSE;
- if (bfd_bwrite (rblk[j], sizeof (struct vms_indexdef), abfd)
- != sizeof (struct vms_indexdef))
+ if (vms_write_block (abfd, blk[j].vbn, rblk[j]) != TRUE)
return FALSE;
free (rblk[j]);
}
+ if (kbn_vbn != 0)
+ {
+ if (vms_write_block (abfd, kbn_vbn, kbn_blk) != TRUE)
+ return FALSE;
+ }
+
return TRUE;
}
static bfd_boolean
_bfd_vms_lib_build_map (unsigned int nbr_modules,
- struct vms_index *modules,
+ struct lib_index *modules,
unsigned int *res_cnt,
- struct vms_index **res)
+ struct lib_index **res)
{
unsigned int i;
asymbol **syms = NULL;
long syms_max = 0;
- struct vms_index *map = NULL;
+ struct lib_index *map = NULL;
unsigned int map_max = 1024; /* Fine initial default. */
unsigned int map_count = 0;
- map = (struct vms_index *) bfd_malloc (map_max * sizeof (struct vms_index));
+ map = (struct lib_index *) bfd_malloc (map_max * sizeof (struct lib_index));
if (map == NULL)
goto error_return;
|| bfd_is_com_section (sec))
&& ! bfd_is_und_section (sec))
{
- struct vms_index *new_map;
+ struct lib_index *new_map;
/* This symbol will go into the archive header. */
if (map_count == map_max)
{
map_max *= 2;
- new_map = (struct vms_index *)
- bfd_realloc (map, map_max * sizeof (struct vms_index));
+ new_map = (struct lib_index *)
+ bfd_realloc (map, map_max * sizeof (struct lib_index));
if (new_map == NULL)
goto error_return;
map = new_map;
}
map[map_count].abfd = current;
- /* FIXME: check length. */
map[map_count].namlen = strlen (syms[src_count]->name);
map[map_count].name = syms[src_count]->name;
map_count++;
{
bfd *current;
unsigned int nbr_modules;
- struct vms_index *modules;
+ struct lib_index *modules;
unsigned int nbr_symbols;
- struct vms_index *symbols;
+ struct lib_index *symbols;
struct lib_tdata *tdata = bfd_libdata (arch);
unsigned int i;
file_ptr off;
unsigned int vbn;
unsigned int mod_idx_vbn;
unsigned int sym_idx_vbn;
+ bfd_boolean is_elfidx = tdata->kind == vms_lib_ia64;
/* Count the number of modules (and do a first sanity check). */
nbr_modules = 0;
/* Build the modules list. */
BFD_ASSERT (tdata->modules == NULL);
- modules = bfd_alloc (arch, nbr_modules * sizeof (struct vms_index));
+ modules = bfd_alloc (arch, nbr_modules * sizeof (struct lib_index));
if (modules == NULL)
return FALSE;
/* Create the module index. */
vbn = 0;
- if (!vms_write_index (NULL, modules, nbr_modules, &vbn, NULL))
+ if (!vms_write_index (NULL, modules, nbr_modules, &vbn, NULL, is_elfidx))
return FALSE;
nbr_mod_iblk = vbn;
return FALSE;
vbn = 0;
- if (!vms_write_index (NULL, symbols, nbr_symbols, &vbn, NULL))
+ if (!vms_write_index (NULL, symbols, nbr_symbols, &vbn, NULL, is_elfidx))
return FALSE;
nbr_sym_iblk = vbn;
current = modules[i].abfd;
current->proxy_origin = off;
- bfd_putl16 (sizeof (struct vms_mhd), blk);
- mhd = (struct vms_mhd *)(blk + 2);
+ if (is_elfidx)
+ sz = 0;
+ else
+ {
+ /* Write the MHD as a record (ie, size first). */
+ sz = 2;
+ bfd_putl16 (tdata->mhd_size, blk);
+ }
+ mhd = (struct vms_mhd *)(blk + sz);
memset (mhd, 0, sizeof (struct vms_mhd));
mhd->lbrflag = 0;
mhd->id = MHD__C_MHDID;
bfd_putl32 (modules[i].ref, mhd->refcnt);
/* FIXME: datim. */
- sz = (2 + sizeof (struct vms_mhd) + 1) & ~1;
- if (vms_write_data_block (arch, &data, &off, blk, sz, 0) < 0)
- goto input_err;
+ sz += tdata->mhd_size;
+ sz = (sz + 1) & ~1;
+ /* Rewind the member to be put into the archive. */
if (bfd_seek (current, 0, SEEK_SET) != 0)
goto input_err;
- while (1)
- {
- sz = bfd_bread (blk, sizeof (blk), current);
- if (sz == 0)
- break;
+ /* Copy the member into the archive. */
+ if (is_elfidx)
+ {
+ unsigned int modsize = 0;
+ bfd_size_type amt;
+ file_ptr off_hdr = off;
+
+ /* Read to complete the first block. */
+ amt = bfd_bread (blk + sz, VMS_BLOCK_SIZE - sz, current);
+ if (amt == (bfd_size_type)-1)
+ goto input_err;
+ modsize = amt;
+ if (amt < VMS_BLOCK_SIZE - sz)
+ {
+ /* The member size is less than a block. Pad the block. */
+ memset (blk + sz + amt, 0, VMS_BLOCK_SIZE - sz - amt);
+ }
+ bfd_putl32 (modsize, mhd->modsize);
+
+ /* Write the first block (which contains an mhd). */
+ if (bfd_bwrite (blk, VMS_BLOCK_SIZE, arch) != VMS_BLOCK_SIZE)
+ goto input_err;
+ off += VMS_BLOCK_SIZE;
+
+ if (amt == VMS_BLOCK_SIZE - sz)
+ {
+ /* Copy the remaining. */
+ char buffer[DEFAULT_BUFFERSIZE];
+
+ while (1)
+ {
+ amt = bfd_bread (buffer, sizeof (buffer), current);
+ if (amt == (bfd_size_type)-1)
+ goto input_err;
+ if (amt == 0)
+ break;
+ modsize += amt;
+ if (amt != sizeof (buffer))
+ {
+ /* Clear the padding. */
+ memset (buffer + amt, 0, sizeof (buffer) - amt);
+ amt = (amt + VMS_BLOCK_SIZE) & ~(VMS_BLOCK_SIZE - 1);
+ }
+ if (bfd_bwrite (buffer, amt, arch) != amt)
+ goto input_err;
+ off += amt;
+ }
+
+ /* Now that the size is known, write the first block (again). */
+ bfd_putl32 (modsize, mhd->modsize);
+ if (bfd_seek (arch, off_hdr, SEEK_SET) != 0
+ || bfd_bwrite (blk, VMS_BLOCK_SIZE, arch) != VMS_BLOCK_SIZE)
+ goto input_err;
+ if (bfd_seek (arch, off, SEEK_SET) != 0)
+ goto input_err;
+ }
+ }
+ else
+ {
+ /* Write the MHD. */
if (vms_write_data_block (arch, &data, &off, blk, sz, 0) < 0)
goto input_err;
+
+ /* Write the member. */
+ while (1)
+ {
+ sz = bfd_bread (blk, sizeof (blk), current);
+ if (sz == 0)
+ break;
+ if (vms_write_data_block (arch, &data, &off, blk, sz, 0) < 0)
+ goto input_err;
+ }
+
+ /* Write the end of module marker. */
+ if (vms_write_data_block (arch, &data, &off,
+ eotdesc, sizeof (eotdesc), 1) < 0)
+ goto input_err;
}
- if (vms_write_data_block (arch, &data, &off,
- eotdesc, sizeof (eotdesc), 1) < 0)
- goto input_err;
}
/* Write the indexes. */
vbn = 2;
- if (vms_write_index (arch, modules, nbr_modules, &vbn, &mod_idx_vbn) != TRUE)
+ if (vms_write_index (arch, modules, nbr_modules, &vbn, &mod_idx_vbn,
+ is_elfidx) != TRUE)
return FALSE;
- if (vms_write_index (arch, symbols, nbr_symbols, &vbn, &sym_idx_vbn) != TRUE)
+ if (vms_write_index (arch, symbols, nbr_symbols, &vbn, &sym_idx_vbn,
+ is_elfidx) != TRUE)
return FALSE;
/* Write libary header. */
struct vms_lhd *lhd = (struct vms_lhd *)blk;
struct vms_idd *idd = (struct vms_idd *)(blk + sizeof (*lhd));
unsigned int idd_flags;
+ unsigned int saneid;
memset (blk, 0, sizeof (blk));
- lhd->type = LBR__C_TYP_EOBJ;
+ lhd->type = tdata->type;
lhd->nindex = 2;
- bfd_putl32 (LHD_SANEID3, lhd->sanity);
- bfd_putl16 (3, lhd->majorid);
+ switch (tdata->kind)
+ {
+ case vms_lib_alpha:
+ saneid = LHD_SANEID3;
+ break;
+ case vms_lib_ia64:
+ saneid = LHD_SANEID6;
+ break;
+ default:
+ abort ();
+ }
+ bfd_putl32 (saneid, lhd->sanity);
+ bfd_putl16 (tdata->ver, lhd->majorid);
bfd_putl16 (0, lhd->minorid);
snprintf ((char *)lhd->lbrver + 1, sizeof (lhd->lbrver) - 1,
"GNU ar %u.%u.%u",
lhd->lbrver[sizeof (lhd->lbrver) - 1] = 0;
lhd->lbrver[0] = strlen ((char *)lhd->lbrver + 1);
- /* FIXME. */
- bfd_putl64 (0, lhd->credat);
- bfd_putl64 (0, lhd->updtim);
+ bfd_putl32 (tdata->credat_lo, lhd->credat + 0);
+ bfd_putl32 (tdata->credat_hi, lhd->credat + 4);
+ vms_raw_get_time (lhd->updtim);
- lhd->mhdusz = sizeof (struct vms_mhd) - MHD__C_USRDAT;
+ lhd->mhdusz = tdata->mhd_size - MHD__C_USRDAT;
bfd_putl32 (nbr_modules + nbr_symbols, lhd->idxcnt);
bfd_putl32 (nbr_modules, lhd->modcnt);
bfd_putl16 (sym_idx_vbn, idd->vbn);
idd++;
- if (bfd_seek (arch, 0, SEEK_SET) != 0)
- return FALSE;
- if (bfd_bwrite (blk, sizeof (blk), arch) != sizeof (blk))
+ if (vms_write_block (arch, 1, blk) != TRUE)
return FALSE;
}