/* BFD back-end for VMS archive files.
- Copyright 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2010-2017 Free Software Foundation, Inc.
Written by Tristan Gingold <gingold@adacore.com>, AdaCore.
This file is part of BFD, the Binary File Descriptor library.
#include "libbfd.h"
#include "safe-ctype.h"
#include "bfdver.h"
+#include "libiberty.h"
#include "vms.h"
#include "vms/lbr.h"
#include "vms/dcx.h"
err:
bfd_release (abfd, tdata);
- abfd->tdata.any = (void *)tdata_hold;;
+ abfd->tdata.any = (void *)tdata_hold;
return NULL;
}
struct lib_tdata *tdata = bfd_libdata (abfd);
bfd *res;
file_ptr file_off;
+ char *name;
/* Sanity check. */
if (modidx >= tdata->nbr_modules)
res = _bfd_create_empty_archive_element_shell (abfd);
if (res == NULL)
return NULL;
- arelt = bfd_zalloc (res, sizeof (*arelt));
+ arelt = bfd_zmalloc (sizeof (*arelt));
if (arelt == NULL)
return NULL;
res->arelt_data = arelt;
res->origin = file_off + tdata->mhd_size;
}
- res->filename = tdata->modules[modidx].name;
+ /* Set filename. */
+ name = tdata->modules[modidx].name;
+ switch (tdata->type)
+ {
+ case LBR__C_TYP_IOBJ:
+ case LBR__C_TYP_EOBJ:
+ /* For object archives, append .obj to mimic standard behaviour. */
+ {
+ size_t namelen = strlen (name);
+ char *name1 = bfd_alloc (res, namelen + 4 + 1);
+ memcpy (name1, name, namelen);
+ strcpy (name1 + namelen, ".obj");
+ name = name1;
+ }
+ break;
+ default:
+ break;
+ }
+ res->filename = xstrdup (name);
tdata->cache[modidx] = res;
if (res == NULL)
{
- (*_bfd_error_handler)(_("could not open shared image '%s' from '%s'"),
- filename, archive->filename);
+ /* xgettext:c-format */
+ _bfd_error_handler(_("could not open shared image '%s' from '%s'"),
+ filename, archive->filename);
bfd_release (archive, filename);
return NULL;
}
/* Write it to the disk (if there is one). */
if (kbn_vbn != 0)
{
- if (vms_write_block (abfd, kbn_vbn, kbn_blk) != TRUE)
+ if (!vms_write_block (abfd, kbn_vbn, kbn_blk))
return FALSE;
}
else
if (abfd != NULL)
{
bfd_putl16 (blk[j].len + blk[j].lastlen, rblk[j]->used);
- if (vms_write_block (abfd, blk[j].vbn, rblk[j]) != TRUE)
+ if (!vms_write_block (abfd, blk[j].vbn, rblk[j]))
return FALSE;
}
{
/* Write this block on the disk. */
bfd_putl16 (blk[j].len + blk[j].lastlen, rblk[j]->used);
- if (vms_write_block (abfd, blk[j].vbn, rblk[j]) != TRUE)
+ if (!vms_write_block (abfd, blk[j].vbn, rblk[j]))
return FALSE;
free (rblk[j]);
/* Write the last kbn (if any). */
if (kbn_vbn != 0)
{
- if (vms_write_block (abfd, kbn_vbn, kbn_blk) != TRUE)
+ if (!vms_write_block (abfd, kbn_vbn, kbn_blk))
return FALSE;
free (kbn_blk);
}
/* Write the indexes. */
vbn = 2;
- if (vms_write_index (arch, modules, nbr_modules, &vbn, &mod_idx_vbn,
- is_elfidx) != TRUE)
+ if (!vms_write_index (arch, modules, nbr_modules, &vbn, &mod_idx_vbn,
+ is_elfidx))
return FALSE;
- if (vms_write_index (arch, symbols, nbr_symbols, &vbn, &sym_idx_vbn,
- is_elfidx) != TRUE)
+ if (!vms_write_index (arch, symbols, nbr_symbols, &vbn, &sym_idx_vbn,
+ is_elfidx))
return FALSE;
/* Write libary header. */
bfd_putl16 (sym_idx_vbn, idd->vbn);
idd++;
- if (vms_write_block (arch, 1, blk) != TRUE)
+ if (!vms_write_block (arch, 1, blk))
return FALSE;
}
return TRUE;
input_err:
- bfd_set_error (bfd_error_on_input, current, bfd_get_error ());
+ bfd_set_input_error (current, bfd_get_error ());
return FALSE;
}
/* Add a target for text library. This costs almost nothing and is useful to
read VMS library on the host. */
-const bfd_target vms_lib_txt_vec =
+const bfd_target alpha_vms_lib_txt_vec =
{
"vms-libtxt", /* Name. */
bfd_target_unknown_flavour,
NULL,
- (PTR) 0
+ NULL
};