diff options
author | Alan Modra <amodra@gmail.com> | 2025-01-22 07:49:56 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2025-01-23 11:40:40 +1030 |
commit | 40c7f80788e28f3dd638a3d0d7ff1554c73dbbc0 (patch) | |
tree | 6a82edbcbf56ce44763eb8aeb33f550d42dacf22 | |
parent | a62e0f8597b13b48c16a889a3afb993bfce75f24 (diff) | |
download | binutils-40c7f80788e28f3dd638a3d0d7ff1554c73dbbc0.zip binutils-40c7f80788e28f3dd638a3d0d7ff1554c73dbbc0.tar.gz binutils-40c7f80788e28f3dd638a3d0d7ff1554c73dbbc0.tar.bz2 |
unusual eh_frame memory leak
This one happens with --gc-sections and a linker script that either
discards some or all .eh_frame sections (eg. ld-elf/pr14265 test) or
maps an input .eh_frame to some other named output section. In that
case the discarded/renamed .eh_frame won't have local_cies freed.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Correct comment.
* elf.c (_bfd_elf_free_cached_info): Free eh_frame cies.
-rw-r--r-- | bfd/elf-eh-frame.c | 4 | ||||
-rw-r--r-- | bfd/elf.c | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c index dd6802b..08ffc5f 100644 --- a/bfd/elf-eh-frame.c +++ b/bfd/elf-eh-frame.c @@ -606,7 +606,9 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info, || (sec->flags & SEC_HAS_CONTENTS) == 0 || sec->sec_info_type != SEC_INFO_TYPE_NONE) { - /* This file does not contain .eh_frame information. */ + /* This file does not contain .eh_frame information or + .eh_frame has already been parsed, as can happen with + --gc-sections. */ return; } @@ -10134,6 +10134,12 @@ _bfd_elf_free_cached_info (bfd *abfd) } free (elf_section_data (sec)->relocs); elf_section_data (sec)->relocs = NULL; + if (sec->sec_info_type == SEC_INFO_TYPE_EH_FRAME) + { + struct eh_frame_sec_info *sec_info + = elf_section_data (sec)->sec_info; + free (sec_info->cies); + } } free (tdata->symtab_hdr.contents); tdata->symtab_hdr.contents = NULL; |