struct vms_private_data_struct
{
- /* If true, relocs have been read. */
- bool reloc_done;
+ /* If 1, relocs have been read successfully, if 0 they have yet to be
+ read, if -1 reading relocs failed. */
+ int reloc_done;
/* Record input buffer. */
struct vms_rec_rd recrd;
/* Place sections. */
for (sec = abfd->sections; sec; sec = sec->next)
{
- if (!(sec->flags & SEC_HAS_CONTENTS))
+ if (!(sec->flags & SEC_HAS_CONTENTS)
+ || sec->contents == NULL)
continue;
eisd = vms_section_data (sec)->eisd;
unsigned char blk[VMS_BLOCK_SIZE];
bfd_size_type len;
- if (sec->size == 0 || !(sec->flags & SEC_HAS_CONTENTS))
+ if (sec->size == 0 || !(sec->flags & SEC_HAS_CONTENTS)
+ || sec->contents == NULL)
continue;
if (bfd_bwrite (sec->contents, sec->size, abfd) != sec->size)
return false;
vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
/* We slurp relocs only once, for all sections. */
- if (PRIV (reloc_done))
- return true;
- PRIV (reloc_done) = true;
+ if (PRIV (reloc_done) != 0)
+ return PRIV (reloc_done) == 1;
if (alpha_vms_canonicalize_symtab (abfd, NULL) < 0)
- return false;
+ goto fail;
if (bfd_seek (abfd, 0, SEEK_SET) != 0)
- return false;
+ goto fail;
while (1)
{
/* Skip non-ETIR records. */
type = _bfd_vms_get_object_record (abfd);
+ if (type < 0)
+ goto fail;
if (type == EOBJ__C_EEOM)
break;
if (type != EOBJ__C_ETIR)
/* xgettext:c-format */
(_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd),
_bfd_vms_etir_name (cmd));
- return false;
+ goto fail;
}
cur_psect = cur_psidx;
vaddr = cur_addend;
/* xgettext:c-format */
(_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd),
_bfd_vms_etir_name (ETIR__C_STA_LW));
- return false;
+ goto fail;
}
}
cur_addend = bfd_getl32 (ptr + 4);
/* xgettext:c-format */
(_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd),
_bfd_vms_etir_name (ETIR__C_STA_QW));
- return false;
+ goto fail;
}
cur_addend = bfd_getl64 (ptr + 4);
prev_cmd = cmd;
_bfd_error_handler (_("unknown reloc %s + %s"),
_bfd_vms_etir_name (prev_cmd),
_bfd_vms_etir_name (ETIR__C_STO_LW));
- return false;
+ goto fail;
}
reloc_code = BFD_RELOC_32;
break;
_bfd_error_handler (_("unknown reloc %s + %s"),
_bfd_vms_etir_name (prev_cmd),
_bfd_vms_etir_name (ETIR__C_STO_QW));
- return false;
+ goto fail;
}
reloc_code = BFD_RELOC_64;
break;
_bfd_error_handler (_("unknown reloc %s + %s"),
_bfd_vms_etir_name (prev_cmd),
_bfd_vms_etir_name (ETIR__C_STO_OFF));
- return false;
+ goto fail;
}
reloc_code = BFD_RELOC_64;
break;
_bfd_error_handler (_("unknown reloc %s + %s"),
_bfd_vms_etir_name (prev_cmd),
_bfd_vms_etir_name (ETIR__C_OPR_ADD));
- return false;
+ goto fail;
}
prev_cmd = ETIR__C_OPR_ADD;
continue;
default:
_bfd_error_handler (_("unknown reloc %s"),
_bfd_vms_etir_name (cmd));
- return false;
+ goto fail;
}
{
if (cur_psect < 0 || cur_psect > (int)PRIV (section_count))
{
_bfd_error_handler (_("invalid section index in ETIR"));
- return false;
+ goto fail;
}
if (PRIV (sections) == NULL)
- return false;
+ goto fail;
sec = PRIV (sections)[cur_psect];
if (sec == bfd_abs_section_ptr)
{
_bfd_error_handler (_("relocation for non-REL psect"));
- return false;
+ goto fail;
}
vms_sec = vms_section_data (sec);
sec->relocation = bfd_realloc_or_free
(sec->relocation, vms_sec->reloc_max * sizeof (arelent));
if (sec->relocation == NULL)
- return false;
+ goto fail;
}
}
reloc = &sec->relocation[sec->reloc_count];
else if (cur_psidx >= 0)
{
if (PRIV (sections) == NULL || cur_psidx >= (int) PRIV (section_count))
- return false;
+ goto fail;
reloc->sym_ptr_ptr =
PRIV (sections)[cur_psidx]->symbol_ptr_ptr;
}
}
}
vms_debug2 ((3, "alpha_vms_slurp_relocs: result = true\n"));
-
+ PRIV (reloc_done) = 1;
return true;
+
+fail:
+ PRIV (reloc_done) = -1;
+ return false;
}
/* Return the number of bytes required to store the relocation
static long
alpha_vms_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, asection *section)
{
- alpha_vms_slurp_relocs (abfd);
+ if (!alpha_vms_slurp_relocs (abfd))
+ return -1;
return (section->reloc_count + 1L) * sizeof (arelent *);
}