mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-06 12:09:26 +08:00
bfd: Munmap readonly memory after bfd_free_cached_info
Munmap readonly memory after bfd_free_cached_info which may use munmapped readonly memory. PR ld/31608 * opncls.c (_bfd_delete_bfd): Munmap readonly memory after bfd_free_cached_info.
This commit is contained in:
parent
c069de3491
commit
37eac4810b
22
bfd/opncls.c
22
bfd/opncls.c
@ -172,16 +172,6 @@ _bfd_delete_bfd (bfd *abfd)
|
||||
munmap (elf_section_data (sec)->contents_addr,
|
||||
elf_section_data (sec)->contents_size);
|
||||
}
|
||||
|
||||
struct bfd_mmapped *mmapped, *next;
|
||||
for (mmapped = abfd->mmapped; mmapped != NULL; mmapped = next)
|
||||
{
|
||||
struct bfd_mmapped_entry *entries = mmapped->entries;
|
||||
next = mmapped->next;
|
||||
for (unsigned int i = 0; i < mmapped->next_entry; i++)
|
||||
munmap (entries[i].addr, entries[i].size);
|
||||
munmap (mmapped, _bfd_pagesize);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Give the target _bfd_free_cached_info a chance to free memory. */
|
||||
@ -197,6 +187,18 @@ _bfd_delete_bfd (bfd *abfd)
|
||||
else
|
||||
free ((char *) bfd_get_filename (abfd));
|
||||
|
||||
#ifdef USE_MMAP
|
||||
struct bfd_mmapped *mmapped, *next;
|
||||
for (mmapped = abfd->mmapped; mmapped != NULL; mmapped = next)
|
||||
{
|
||||
struct bfd_mmapped_entry *entries = mmapped->entries;
|
||||
next = mmapped->next;
|
||||
for (unsigned int i = 0; i < mmapped->next_entry; i++)
|
||||
munmap (entries[i].addr, entries[i].size);
|
||||
munmap (mmapped, _bfd_pagesize);
|
||||
}
|
||||
#endif
|
||||
|
||||
free (abfd->arelt_data);
|
||||
free (abfd);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user