/* BFD back-end for VERSAdos-E objects.
- Copyright (C) 1995-2014 Free Software Foundation, Inc.
+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
Versados is a Motorola trademark.
{
asection *section; /* Ptr to bfd version. */
unsigned char *contents; /* Used to build image. */
+ bfd_size_type content_size; /* The size of the contents buffer. */
int pc;
int relocs; /* Reloc count, valid end of pass 1. */
int donerel; /* Have relocs been translated. */
break;
case ESD_XDEF_IN_ABS:
sec = bfd_abs_section_ptr;
+ /* Fall through. */
case ESD_XDEF_IN_SEC:
{
int snum = VDATA (abfd)->def_idx++;
| (otr->map[2] << 8)
| (otr->map[3] << 0);
- struct esdid *esdid = &EDATA (abfd, otr->esdid - 1);
+ struct esdid *esdid;
unsigned char *contents;
bfd_boolean need_contents = FALSE;
unsigned int dst_idx;
/* PR 17512: file: ac7da425. */
if (otr->esdid == 0)
return;
-
+
+ esdid = &EDATA (abfd, otr->esdid - 1);
contents = esdid->contents;
dst_idx = esdid->pc;
-
+
for (shift = ((unsigned long) 1 << 31); shift && srcp < endp; shift >>= 1)
{
if (bits & shift)
if (pass == 1)
need_contents = TRUE;
- else if (contents && dst_idx < esdid->section->size - sizeinwords * 2)
+ else if (contents && dst_idx < esdid->content_size - sizeinwords * 2)
for (j = 0; j < sizeinwords * 2; j++)
{
contents[dst_idx + (sizeinwords * 2) - j - 1] = val;
{
need_contents = TRUE;
- if (esdid->section && contents && dst_idx < esdid->section->size)
+ if (esdid->section && contents && dst_idx < esdid->content_size - 1)
if (pass == 2)
{
/* Absolute code, comes in 16 bit lumps. */
size = esdid->section->size;
esdid->contents = bfd_alloc (abfd, size);
+ esdid->content_size = size;
}
else
esdid->contents = NULL;
file_ptr offset,
bfd_size_type count)
{
+ struct esdid *esdid;
+
if (!versados_pass_2 (abfd))
return FALSE;
- memcpy (location,
- EDATA (abfd, section->target_index).contents + offset,
- (size_t) count);
+ esdid = &EDATA (abfd, section->target_index);
+
+ if (esdid->contents == NULL
+ || offset < 0
+ || (bfd_size_type) offset > esdid->content_size
+ || offset + count > esdid->content_size)
+ return FALSE;
+
+ memcpy (location, esdid->contents + offset, (size_t) count);
return TRUE;
}
_bfd_generic_copy_link_hash_symbol_type
#define versados_bfd_final_link _bfd_generic_final_link
#define versados_bfd_link_split_section _bfd_generic_link_split_section
+#define versados_bfd_link_check_relocs _bfd_generic_link_check_relocs
const bfd_target m68k_versados_vec =
{