diff options
author | Alan Modra <amodra@gmail.com> | 2014-11-07 20:18:25 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2014-11-07 20:40:41 +1030 |
commit | 7c53fd1ca357a5f6d0dcb3fcc6d06a38de48cd09 (patch) | |
tree | ff803eb2eebbbe861e82a0acdac9a7ddb36f922d /bfd/aoutx.h | |
parent | 67be31e5aae5075a99068e752b138a0934bde83c (diff) | |
download | gdb-7c53fd1ca357a5f6d0dcb3fcc6d06a38de48cd09.zip gdb-7c53fd1ca357a5f6d0dcb3fcc6d06a38de48cd09.tar.gz gdb-7c53fd1ca357a5f6d0dcb3fcc6d06a38de48cd09.tar.bz2 |
aoutx.h tidy
Save a multiplication, and any concern that the buffer allocation
might be smaller than the amount read (as it could be if the header
size isn't a multiple of EXTERNAL_NLIST_SIZE).
* aoutx.h (aout_get_external_symbols): Tidy allocation of symbol buffer.
Diffstat (limited to 'bfd/aoutx.h')
-rw-r--r-- | bfd/aoutx.h | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/bfd/aoutx.h b/bfd/aoutx.h index bef59b4..9385a98 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -1300,14 +1300,14 @@ aout_get_external_symbols (bfd *abfd) { bfd_size_type count; struct external_nlist *syms; + bfd_size_type amt = exec_hdr (abfd)->a_syms; - count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE; + count = amt / EXTERNAL_NLIST_SIZE; if (count == 0) return TRUE; /* Nothing to do. */ #ifdef USE_MMAP - if (! bfd_get_file_window (abfd, obj_sym_filepos (abfd), - exec_hdr (abfd)->a_syms, + if (! bfd_get_file_window (abfd, obj_sym_filepos (abfd), amt, &obj_aout_sym_window (abfd), TRUE)) return FALSE; syms = (struct external_nlist *) obj_aout_sym_window (abfd).data; @@ -1315,20 +1315,16 @@ aout_get_external_symbols (bfd *abfd) /* We allocate using malloc to make the values easy to free later on. If we put them on the objalloc it might not be possible to free them. */ - syms = (struct external_nlist *) bfd_malloc (count * EXTERNAL_NLIST_SIZE); + syms = (struct external_nlist *) bfd_malloc (amt); if (syms == NULL) return FALSE; - { - bfd_size_type amt; - amt = exec_hdr (abfd)->a_syms; - if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 - || bfd_bread (syms, amt, abfd) != amt) - { - free (syms); - return FALSE; - } - } + if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 + || bfd_bread (syms, amt, abfd) != amt) + { + free (syms); + return FALSE; + } #endif obj_aout_external_syms (abfd) = syms; |