diff options
| author | Mark Wielaard <[email protected]> | 2016-08-07 22:13:46 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-08-15 09:58:12 +0200 |
| commit | e93f2d801fccbe5a4ffd71f07baed66453b8a56c (patch) | |
| tree | faf2178368ee667d7d94846f0ad58a5ffd8749f6 /libelf/libelfP.h | |
| parent | 6ff6c215bfa4153874751cdc0bae26acfbba4a81 (diff) | |
libelf: Fix memory leak in elf_compress for mmapped ELF files.
The testcase added to run-strip-reloc.sh for strip-compressed.o showed
a memory leak when ran under valgrind (configure --enable-valgrind).
For a mmapped ELF file when existing section data was compressed
elf_end would fail to release the new compressed data buffer assigned
to rawdata_base. For non-mapped files rawdata_base is always freed.
For decompressed data rawdata_base is released together with zdata_base.
Use the Elf_Scn flag ELF_T_MALLOCED to track whether rawdata_base
points to malloced memory and free it in elf_end even for mmapped
ELF files.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf/libelfP.h')
| -rw-r--r-- | libelf/libelfP.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libelf/libelfP.h b/libelf/libelfP.h index 57ccbce4..44599827 100644 --- a/libelf/libelfP.h +++ b/libelf/libelfP.h @@ -1,5 +1,5 @@ /* Internal interfaces for libelf. - Copyright (C) 1998-2010, 2015 Red Hat, Inc. + Copyright (C) 1998-2010, 2015, 2016 Red Hat, Inc. This file is part of elfutils. Contributed by Ulrich Drepper <[email protected]>, 1998. @@ -233,7 +233,13 @@ struct Elf_Scn } shdr; unsigned int shdr_flags; /* Section header modified? */ - unsigned int flags; /* Section changed in size? */ + unsigned int flags; /* Section changed in size? + ELF_F_MALLOCED for a Elf_Data_Chunk + dummy_scn means the rawchunks + data.d.d_buf was malloced. For normal + sections it means rawdata_base was + malloced (by elf_compress) even if + the Elf was mmapped. */ char *rawdata_base; /* The unmodified data of the section. */ char *data_base; /* The converted data of the section. */ |
