aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2025-01-19 08:35:22 +1030
committerAlan Modra <amodra@gmail.com>2025-01-20 18:16:15 +1030
commit130bb6bbbdd4c32be067a0c9c2524b669bf6ae04 (patch)
treec882d39721b84943c7c0ea8c9921cd86aee69a3b
parentc99345db064e1bd645bc08db65174bae7ac20b0e (diff)
downloadbinutils-130bb6bbbdd4c32be067a0c9c2524b669bf6ae04.zip
binutils-130bb6bbbdd4c32be067a0c9c2524b669bf6ae04.tar.gz
binutils-130bb6bbbdd4c32be067a0c9c2524b669bf6ae04.tar.bz2
_bfd_elf_get_dynamic_symbols
This fixes an error path in _bfd_elf_get_dynamic_symbols, fixes the minimum size required when reading DT_HASH header, and tidies formatting in a few places. Nit-fixes all. Very likely we shouldn't be trying to mmap DT_DYNAMIC as it won't be large enough for the mmap size threshold. * elf.c (_bfd_elf_get_dynamic_symbols): Use _bfd_munmap_temporary in error return path rather than free. Corrent size passed to offset_from_vma when reading DT_HASH header. Formatting.
-rw-r--r--bfd/elf.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 37b87ee..4fa8a2a 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1746,7 +1746,7 @@ get_hash_table_data (bfd *abfd, bfd_size_type number,
i_data = (bfd_vma *) bfd_malloc (number * sizeof (*i_data));
if (i_data == NULL)
{
- free (e_data);
+ _bfd_munmap_temporary (e_data_addr, e_data_size);
return NULL;
}
@@ -1941,7 +1941,7 @@ _bfd_elf_get_dynamic_symbols (bfd *abfd, Elf_Internal_Phdr *phdr,
break;
}
- filepos = offset_from_vma (phdrs, phnum, dt_hash, sizeof (nb),
+ filepos = offset_from_vma (phdrs, phnum, dt_hash, 2 * hash_ent_size,
NULL);
if (filepos == (file_ptr) -1
|| bfd_seek (abfd, filepos, SEEK_SET) != 0
@@ -2012,8 +2012,7 @@ _bfd_elf_get_dynamic_symbols (bfd *abfd, Elf_Internal_Phdr *phdr,
maxchain -= gnusymidx;
filepos = offset_from_vma (phdrs, phnum,
- (buckets_vma +
- 4 * (ngnubuckets + maxchain)),
+ buckets_vma + 4 * (ngnubuckets + maxchain),
4, NULL);
if (filepos == (file_ptr) -1
|| bfd_seek (abfd, filepos, SEEK_SET) != 0)
@@ -2030,7 +2029,7 @@ _bfd_elf_get_dynamic_symbols (bfd *abfd, Elf_Internal_Phdr *phdr,
while ((bfd_get_32 (abfd, nb) & 1) == 0);
filepos = offset_from_vma (phdrs, phnum,
- (buckets_vma + 4 * ngnubuckets),
+ buckets_vma + 4 * ngnubuckets,
4, NULL);
if (filepos == (file_ptr) -1
|| bfd_seek (abfd, filepos, SEEK_SET) != 0)
@@ -2044,8 +2043,7 @@ _bfd_elf_get_dynamic_symbols (bfd *abfd, Elf_Internal_Phdr *phdr,
if (dt_mips_xhash)
{
filepos = offset_from_vma (phdrs, phnum,
- (buckets_vma
- + 4 * (ngnubuckets + maxchain)),
+ buckets_vma + 4 * (ngnubuckets + maxchain),
4, NULL);
if (filepos == (file_ptr) -1
|| bfd_seek (abfd, filepos, SEEK_SET) != 0)