summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lindsay <alexlindsay239@gmail.com>2017-08-17 11:53:53 +0100
committerYao Qi <yao.qi@linaro.org>2017-08-17 11:53:53 +0100
commitba7139188c75a9c620cadea59158c5ffcab28acf (patch)
tree8c15c3f7a0102dd8bd4c0983fed6993a40db83d8
parent44d0fb3a0a47c00a296f52a045a47dd0f1ccb810 (diff)
downloadbinutils-gdb-ba7139188c75a9c620cadea59158c5ffcab28acf.tar.gz
Synthetic symbol leak in elf_read_minimal_symbols
Detected this leak with valgrind memcheck: ==30840== 194 bytes in 1 blocks are definitely lost in loss record 9,138 of 10,922 ==30840== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==30840== by 0x80DF82: bfd_malloc (libbfd.c:193) ==30840== by 0x80E12D: bfd_zmalloc (libbfd.c:278) ==30840== by 0x819E80: elf_x86_64_get_synthetic_symtab (elf64-x86-64.c:6835) ==30840== by 0x4F7B01: elf_read_minimal_symbols(objfile*, int, elfinfo const*) (elfread.c:1124) ==30840== by 0x4F7CE7: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1182) ==30840== by 0x7557FC: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:861) ==30840== by 0x755EE1: syms_from_objfile_1(objfile*, section_addr_info*, enum_flags<symfile_add_flag>) (symfile.c:1062) We perform a dynamic allocation in elf64-x86-64.c:elf_x86_64_get_synthetic_symtab s = *ret = (asymbol *) bfd_zmalloc (size); that appear to never get freed. gdb: 2017-08-17 Alex Lindsay <alexlindsay239@gmail.com> * elfread.c (elf_read_minimal_symbols): xfree synthsyms.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/elfread.c3
2 files changed, 7 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 10d63b0ee1e..d2c194eff3b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2017-08-17 Alex Lindsay <alexlindsay239@gmail.com> (tiny change)
+
+ * elfread.c (elf_read_minimal_symbols): xfree synthsyms.
+
2017-08-17 Ruslan Kabatsayev <b7.10110111@gmail.com>
* NEWS: Mention new shortcuts for nexti and stepi in TUI
diff --git a/gdb/elfread.c b/gdb/elfread.c
index ece704ca7c4..a6546613350 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1132,6 +1132,9 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
synth_symbol_table[i] = synthsyms + i;
elf_symtab_read (reader, objfile, ST_SYNTHETIC, synthcount,
synth_symbol_table.get (), true);
+
+ xfree (synthsyms);
+ synthsyms = NULL;
}
/* Install any minimal symbols that have been collected as the current