aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf-m10200.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2001-09-18 09:57:26 +0000
committerAlan Modra <amodra@gmail.com>2001-09-18 09:57:26 +0000
commitdc810e3900d47ab2eea86d50231ff2e70b596847 (patch)
tree13fc3d267fb99c450380f08a0775b2dff076b8d7 /bfd/elf-m10200.c
parent417412a27c87b0e738a21122a38d48aa35317eb8 (diff)
downloadgdb-dc810e3900d47ab2eea86d50231ff2e70b596847.zip
gdb-dc810e3900d47ab2eea86d50231ff2e70b596847.tar.gz
gdb-dc810e3900d47ab2eea86d50231ff2e70b596847.tar.bz2
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become bfd_bread and bfd_bwrite. o bfd_*alloc now all take a bfd_size_type arg, and will error if size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files or bugs in linker scripts etc. o file_ptr becomes a bfd_signed_vma. Besides matching sizes with various other types involved in handling sections, this should make it easier for bfd to support a 64 bit off_t on 32 bit hosts that provide it. o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*) generally available. They now cast their args to bfd_vma and bfd_byte * as appropriate, which removes a swag of casts from the source. o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and aout-encap.c. o Zillions of formatting and -Wconversion fixes.
Diffstat (limited to 'bfd/elf-m10200.c')
-rw-r--r--bfd/elf-m10200.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c
index cde5641..9caf1bb 100644
--- a/bfd/elf-m10200.c
+++ b/bfd/elf-m10200.c
@@ -605,14 +605,13 @@ mn10200_elf_relax_section (abfd, sec, link_info, again)
else
{
/* Go get them off disk. */
- extsyms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_size));
+ bfd_size_type amt = symtab_hdr->sh_size;
+ extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
if (extsyms == NULL)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
- != symtab_hdr->sh_size))
+ || bfd_bread (extsyms, amt, abfd) != amt)
goto error_return;
}
}
@@ -1279,7 +1278,8 @@ mn10200_elf_relax_delete_bytes (abfd, sec, addr, count)
irelend = irel + sec->reloc_count;
/* Actually delete the bytes. */
- memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ memmove (contents + addr, contents + addr + count,
+ (size_t) (toaddr - addr - count));
sec->_cooked_size -= count;
/* Adjust all the relocs. */
@@ -1411,7 +1411,7 @@ mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
memcpy (data, elf_section_data (input_section)->this_hdr.contents,
- input_section->_raw_size);
+ (size_t) input_section->_raw_size);
if ((input_section->flags & SEC_RELOC) != 0
&& input_section->reloc_count > 0)
@@ -1419,20 +1419,19 @@ mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
Elf_Internal_Sym *isymp;
asection **secpp;
Elf32_External_Sym *esym, *esymend;
+ bfd_size_type size;
if (symtab_hdr->contents != NULL)
external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
- external_syms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf32_External_Sym)));
- if (external_syms == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (Elf32_External_Sym);
+ external_syms = (Elf32_External_Sym *) bfd_malloc (size);
+ if (external_syms == NULL && size != 0)
goto error_return;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
- symtab_hdr->sh_info, input_bfd)
- != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ || bfd_bread (external_syms, size, input_bfd) != size)
goto error_return;
}
@@ -1442,15 +1441,16 @@ mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
if (internal_relocs == NULL)
goto error_return;
- internal_syms = ((Elf_Internal_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf_Internal_Sym)));
- if (internal_syms == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (Elf_Internal_Sym);
+ internal_syms = (Elf_Internal_Sym *) bfd_malloc (size);
+ if (internal_syms == NULL && size != 0)
goto error_return;
- sections = (asection **) bfd_malloc (symtab_hdr->sh_info
- * sizeof (asection *));
- if (sections == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (asection *);
+ sections = (asection **) bfd_malloc (size);
+ if (sections == NULL && size != 0)
goto error_return;
isymp = internal_syms;