/* BFD back-end for PDP-11 a.out binaries.
- Copyright (C) 2001-2019 Free Software Foundation, Inc.
+ Copyright (C) 2001-2020 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
&& N_MAGIC(x) != ZMAGIC)
#include "sysdep.h"
+#include <limits.h>
#include "bfd.h"
#define external_exec pdp11_external_exec
abort ();
}
- bfd_get_start_address (abfd) = execp->a_entry;
+ abfd->start_address = execp->a_entry;
obj_aout_symbols (abfd) = NULL;
- bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist);
+ abfd->symcount = execp->a_syms / sizeof (struct external_nlist);
/* The default relocation entry size is that of traditional V7 Unix. */
obj_reloc_entry_size (abfd) = RELOC_SIZE;
to another. */
sym_pointer->e_type[0] &= ~N_TYPE;
- sec = bfd_get_section (cache_ptr);
+ sec = bfd_asymbol_section (cache_ptr);
off = 0;
if (sec == NULL)
return FALSE;
}
- bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd);
+ abfd->symcount = obj_aout_external_sym_count (abfd);
obj_aout_symbols (abfd) = cached;
long
NAME (aout, get_reloc_upper_bound) (bfd *abfd, sec_ptr asect)
{
+ bfd_size_type count;
+
if (bfd_get_format (abfd) != bfd_object)
{
bfd_set_error (bfd_error_invalid_operation);
}
if (asect->flags & SEC_CONSTRUCTOR)
- return (sizeof (arelent *) * (asect->reloc_count + 1));
-
- if (asect == obj_datasec (abfd))
- return (sizeof (arelent *)
- * ((exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd))
- + 1));
-
- if (asect == obj_textsec (abfd))
- return (sizeof (arelent *)
- * ((exec_hdr (abfd)->a_trsize / obj_reloc_entry_size (abfd))
- + 1));
-
- /* TODO: why are there two if statements for obj_bsssec()? */
-
- if (asect == obj_bsssec (abfd))
- return sizeof (arelent *);
-
- if (asect == obj_bsssec (abfd))
- return 0;
+ count = asect->reloc_count;
+ else if (asect == obj_datasec (abfd))
+ count = exec_hdr (abfd)->a_drsize / obj_reloc_entry_size (abfd);
+ else if (asect == obj_textsec (abfd))
+ count = exec_hdr (abfd)->a_trsize / obj_reloc_entry_size (abfd);
+ else if (asect == obj_bsssec (abfd))
+ count = 0;
+ else
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
+ if (count >= LONG_MAX / sizeof (arelent *))
+ {
+ bfd_set_error (bfd_error_file_too_big);
+ return -1;
+ }
+ return (count + 1) * sizeof (arelent *);
}
\f
break;
case N_TEXT | N_EXT:
section = obj_textsec (abfd);
- value -= bfd_get_section_vma (abfd, section);
+ value -= bfd_section_vma (section);
break;
case N_DATA | N_EXT:
/* Treat N_SETV symbols as N_DATA symbol; see comment in
translate_from_native_sym_flags. */
section = obj_datasec (abfd);
- value -= bfd_get_section_vma (abfd, section);
+ value -= bfd_section_vma (section);
break;
case N_BSS | N_EXT:
section = obj_bsssec (abfd);
- value -= bfd_get_section_vma (abfd, section);
+ value -= bfd_section_vma (section);
break;
}
(*flaginfo->info->callbacks->reloc_overflow)
(flaginfo->info, NULL,
(p->type == bfd_section_reloc_link_order
- ? bfd_section_name (flaginfo->output_bfd,
- pr->u.section)
+ ? bfd_section_name (pr->u.section)
: pr->u.name),
howto->name, pr->addend, NULL,
(asection *) NULL, (bfd_vma) 0);
asection *s;
s = aout_reloc_type_to_section (input_bfd, r_type);
- name = bfd_section_name (input_bfd, s);
+ name = bfd_section_name (s);
}
(*flaginfo->info->callbacks->reloc_overflow)
(flaginfo->info, (h ? &h->root : NULL), name, howto->name,
return FALSE;
PUT_WORD (output_bfd, strtab_index, outsym->e_strx);
PUT_WORD (output_bfd,
- (bfd_get_section_vma (output_bfd,
- obj_textsec (input_bfd)->output_section)
+ (bfd_section_vma (obj_textsec (input_bfd)->output_section)
+ obj_textsec (input_bfd)->output_offset),
outsym->e_value);
++obj_aout_external_sym_count (output_bfd);
BFD_ASSERT (bfd_is_abs_section (output_section)
|| output_section->owner == output_bfd);
val = (hresolve->root.u.def.value
- + bfd_get_section_vma (output_bfd, output_section)
+ + bfd_section_vma (output_section)
+ input_section->output_offset);
/* Get the correct type based on the section. If