mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-15 22:00:47 +08:00
Re: ld plugin bfd_make_readable leak
Commit 3097045a18 runs into an abort in objalloc_free_block when the
memory being bfd_release'd wasn't bfd_alloc'd. Fix that.
* coffgen.c (_bfd_coff_free_cached_info): Don't release
raw_syments when obj_coff_keep_raw_syms.
* libcoff-in.h (obj_coff_keep_raw_syms): Define.
(struct coff_tdata): Add keep_raw_syms.
* peicode.h (pe_ILF_build_a_bfd): Set obj_coff_keep_raw_syms.
* libcoff.h: Regenerate.
This commit is contained in:
@@ -3299,11 +3299,13 @@ _bfd_coff_free_cached_info (bfd *abfd)
|
|||||||
|
|
||||||
/* Free raw syms, and any other data bfd_alloc'd after raw syms
|
/* Free raw syms, and any other data bfd_alloc'd after raw syms
|
||||||
are read. */
|
are read. */
|
||||||
if (obj_raw_syments (abfd))
|
if (!obj_coff_keep_raw_syms (abfd) && obj_raw_syments (abfd))
|
||||||
bfd_release (abfd, obj_raw_syments (abfd));
|
{
|
||||||
obj_raw_syments (abfd) = NULL;
|
bfd_release (abfd, obj_raw_syments (abfd));
|
||||||
obj_symbols (abfd) = NULL;
|
obj_raw_syments (abfd) = NULL;
|
||||||
obj_convert (abfd) = NULL;
|
obj_symbols (abfd) = NULL;
|
||||||
|
obj_convert (abfd) = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _bfd_generic_bfd_free_cached_info (abfd);
|
return _bfd_generic_bfd_free_cached_info (abfd);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ extern "C" {
|
|||||||
#define obj_relocbase(bfd) (coff_data (bfd)->relocbase)
|
#define obj_relocbase(bfd) (coff_data (bfd)->relocbase)
|
||||||
#define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments)
|
#define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments)
|
||||||
#define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count)
|
#define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count)
|
||||||
|
#define obj_coff_keep_raw_syms(bfd) (coff_data (bfd)->keep_raw_syms)
|
||||||
#define obj_convert(bfd) (coff_data (bfd)->conversion_table)
|
#define obj_convert(bfd) (coff_data (bfd)->conversion_table)
|
||||||
#define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size)
|
#define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size)
|
||||||
#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
|
#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
|
||||||
@@ -91,6 +92,8 @@ typedef struct coff_tdata
|
|||||||
backend flag _bfd_coff_long_section_names. */
|
backend flag _bfd_coff_long_section_names. */
|
||||||
bool long_section_names;
|
bool long_section_names;
|
||||||
|
|
||||||
|
/* If this is TRUE, raw_syments may not be released. */
|
||||||
|
bool keep_raw_syms;
|
||||||
/* If this is TRUE, the external_syms may not be freed. */
|
/* If this is TRUE, the external_syms may not be freed. */
|
||||||
bool keep_syms;
|
bool keep_syms;
|
||||||
/* If this is TRUE, the strings may not be freed. */
|
/* If this is TRUE, the strings may not be freed. */
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ extern "C" {
|
|||||||
#define obj_relocbase(bfd) (coff_data (bfd)->relocbase)
|
#define obj_relocbase(bfd) (coff_data (bfd)->relocbase)
|
||||||
#define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments)
|
#define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments)
|
||||||
#define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count)
|
#define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count)
|
||||||
|
#define obj_coff_keep_raw_syms(bfd) (coff_data (bfd)->keep_raw_syms)
|
||||||
#define obj_convert(bfd) (coff_data (bfd)->conversion_table)
|
#define obj_convert(bfd) (coff_data (bfd)->conversion_table)
|
||||||
#define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size)
|
#define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size)
|
||||||
#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
|
#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
|
||||||
@@ -95,6 +96,8 @@ typedef struct coff_tdata
|
|||||||
backend flag _bfd_coff_long_section_names. */
|
backend flag _bfd_coff_long_section_names. */
|
||||||
bool long_section_names;
|
bool long_section_names;
|
||||||
|
|
||||||
|
/* If this is TRUE, raw_syments may not be released. */
|
||||||
|
bool keep_raw_syms;
|
||||||
/* If this is TRUE, the external_syms may not be freed. */
|
/* If this is TRUE, the external_syms may not be freed. */
|
||||||
bool keep_syms;
|
bool keep_syms;
|
||||||
/* If this is TRUE, the strings may not be freed. */
|
/* If this is TRUE, the strings may not be freed. */
|
||||||
|
|||||||
@@ -1154,6 +1154,7 @@ pe_ILF_build_a_bfd (bfd * abfd,
|
|||||||
|
|
||||||
obj_raw_syments (abfd) = vars.native_syms;
|
obj_raw_syments (abfd) = vars.native_syms;
|
||||||
obj_raw_syment_count (abfd) = vars.sym_index;
|
obj_raw_syment_count (abfd) = vars.sym_index;
|
||||||
|
obj_coff_keep_raw_syms (abfd) = true;
|
||||||
|
|
||||||
obj_coff_external_syms (abfd) = (void *) vars.esym_table;
|
obj_coff_external_syms (abfd) = (void *) vars.esym_table;
|
||||||
obj_coff_keep_syms (abfd) = true;
|
obj_coff_keep_syms (abfd) = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user