mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 03:51:15 +08:00
looping in alpha_vms_slurp_relocs
The direct cause for the looping was failing to test for error return from _bfd_vms_get_object_record inside a while(1) loop. Fix that. Also record status of first alpha_vms_slurp_relocs call and return that for all subsequent calls. (The object format has one set of relocation records for all sections.) If the first call fails, all others should too. * vms-alpha.c (struct vms_private_data_struct): Make reloc_done a tri-state int. (alpha_vms_slurp_relocs): Set reloc_done to 1 on success, -1 on failure. Return that status on subsequent calls. Check _bfd_vms_get_object_record return status. (alpha_vms_get_reloc_upper_bound): Return status from alpha_vms_slurp_relocs. (alpha_vms_write_exec): Exclude sections with contents NULL due to previous errors from layout, and don't try to write them.
This commit is contained in:
parent
7f99cbd91f
commit
8c8fa33c20
@ -266,8 +266,9 @@ struct module
|
||||
|
||||
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;
|
||||
@ -3380,7 +3381,8 @@ alpha_vms_write_exec (bfd *abfd)
|
||||
/* 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;
|
||||
@ -3460,7 +3462,8 @@ alpha_vms_write_exec (bfd *abfd)
|
||||
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;
|
||||
@ -5122,15 +5125,14 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
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)
|
||||
{
|
||||
@ -5151,6 +5153,8 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
|
||||
/* 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)
|
||||
@ -5192,7 +5196,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
/* 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;
|
||||
@ -5210,7 +5214,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
/* 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);
|
||||
@ -5225,7 +5229,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
/* 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;
|
||||
@ -5242,7 +5246,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
_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;
|
||||
@ -5255,7 +5259,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
_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;
|
||||
@ -5267,7 +5271,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
_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;
|
||||
@ -5280,7 +5284,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
_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;
|
||||
@ -5334,7 +5338,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
default:
|
||||
_bfd_error_handler (_("unknown reloc %s"),
|
||||
_bfd_vms_etir_name (cmd));
|
||||
return false;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
{
|
||||
@ -5347,16 +5351,16 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
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);
|
||||
@ -5376,7 +5380,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
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];
|
||||
@ -5414,7 +5418,7 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
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;
|
||||
}
|
||||
@ -5438,8 +5442,12 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
}
|
||||
}
|
||||
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
|
||||
@ -5448,7 +5456,8 @@ alpha_vms_slurp_relocs (bfd *abfd)
|
||||
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 *);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user