as_fatal (_("libbfd ABI mismatch"));
obstack_begin (¬es, chunksize);
- xatexit (free_notes);
+ if (ENABLE_LEAK_CHECK)
+ xatexit (free_notes);
myname = **argvp;
xmalloc_set_program_name (myname);
/* Define if you want run-time sanity checks. */
#undef ENABLE_CHECKING
+/* Define if you want memory to be freed before exit. */
+#undef ENABLE_LEAK_CHECK
+
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
void
oav1_attr_info_exit (void)
{
- oav1_attr_info_free (recorded_attributes);
+ if (ENABLE_LEAK_CHECK)
+ oav1_attr_info_free (recorded_attributes);
}
/* Record that we have seen an explicit specification of attribute TAG
void
elf_end (void)
{
+ if (!ENABLE_LEAK_CHECK)
+ return;
while (section_stack)
{
struct section_stack *top = section_stack;
void
arc_md_end (void)
{
+ if (!ENABLE_LEAK_CHECK)
+ return;
htab_delete (arc_opcode_hash);
htab_delete (arc_reg_hash);
htab_delete (arc_aux_hash);
void
i386_md_end (void)
{
+ if (!ENABLE_LEAK_CHECK)
+ return;
htab_delete (op_hash);
htab_delete (reg_hash);
GOT_symbol = NULL;
void
loongarch_md_end (void)
{
- htab_delete (align_hash);
+ if (ENABLE_LEAK_CHECK)
+ htab_delete (align_hash);
}
unsigned long
void
ppc_md_end (void)
{
+ if (!ENABLE_LEAK_CHECK)
+ return;
if (ppc_hash)
{
htab_delete (ppc_hash);
void
pru_md_end (void)
{
+ if (!ENABLE_LEAK_CHECK)
+ return;
htab_delete (pru_opcode_hash);
htab_delete (pru_reg_hash);
}
void
riscv_md_end (void)
{
- htab_delete (riscv_pcrel_hi_fixup_hash);
+ if (ENABLE_LEAK_CHECK)
+ htab_delete (riscv_pcrel_hi_fixup_hash);
}
/* Adjust the symbol table. */
void
tic54x_md_end (void)
{
+ if (!ENABLE_LEAK_CHECK)
+ return;
htab_delete (stag_hash);
htab_delete (subsym_recurse_hash);
while (macro_level != -1)
enable_largefile
enable_targets
enable_checking
+enable_leak_check
enable_compressed_debug_sections
enable_default_compressed_debug_sections_algorithm
enable_x86_tls_check
--disable-largefile omit support for large files
--enable-targets alternative target configurations besides the primary
--enable-checking enable run-time checks
+ --enable-leak-check enable freeing memory before exit
--enable-compressed-debug-sections={all,gas,none}
compress debug sections by default
--enable-default-compressed-debug-sections-algorithm={zlib,zstd}
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11153 "configure"
+#line 11155 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11259 "configure"
+#line 11261 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
fi
+ac_leak_check=BFD_ASAN
+# Check whether --enable-leak_check was given.
+if test "${enable_leak_check+set}" = set; then :
+ enableval=$enable_leak_check; case "${enableval}" in
+ no) ac_leak_check=0 ;;
+ *) ac_leak_check=1 ;;
+esac
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define ENABLE_LEAK_CHECK ${ac_leak_check}
+_ACEOF
+
+
# PR gas/19109
# Decide the default method for compressing debug sections.
ac_default_compressed_debug_sections=unset
AC_DEFINE(ENABLE_CHECKING, 1, [Define if you want run-time sanity checks.])
fi
+ac_leak_check=BFD_ASAN
+AC_ARG_ENABLE(leak_check,
+[ --enable-leak-check enable freeing memory before exit],
+[case "${enableval}" in
+ no) ac_leak_check=0 ;;
+ *) ac_leak_check=1 ;;
+esac])dnl
+AC_DEFINE_UNQUOTED(ENABLE_LEAK_CHECK, ${ac_leak_check}, [Define if you want memory to be freed before exit.])
+
# PR gas/19109
# Decide the default method for compressing debug sections.
ac_default_compressed_debug_sections=unset
void
expr_end (void)
{
- for (size_t i = 0; i < ARRAY_SIZE (seen); i++)
- free (seen[i]);
+ if (ENABLE_LEAK_CHECK)
+ for (size_t i = 0; i < ARRAY_SIZE (seen); i++)
+ free (seen[i]);
}
\f
/* Return the encoding for the operator at INPUT_LINE_POINTER, and
void
macro_end (void)
{
- htab_delete (macro_hash);
+ if (ENABLE_LEAK_CHECK)
+ htab_delete (macro_hash);
}
/* Read input lines till we get to a TO string.
which will call xexit() which may call this function again... */
stdoutput = NULL;
- /* We can't free obstacks attached to the output bfd sections before
- closing the output bfd since data in those obstacks may need to
- be accessed, but we can't access anything in the output bfd after
- it is closed.. */
- for (sec = obfd->sections; sec; sec = sec->next)
- stash_frchain_obs (sec);
- stash_frchain_obs (reg_section);
- stash_frchain_obs (expr_section);
- stash_frchain_obs (bfd_abs_section_ptr);
- stash_frchain_obs (bfd_und_section_ptr);
- obstack_ptr_grow (¬es, NULL);
- obs = obstack_finish (¬es);
+ if (ENABLE_LEAK_CHECK)
+ {
+ /* We can't free obstacks attached to the output bfd sections before
+ closing the output bfd since data in those obstacks may need to
+ be accessed, but we can't access anything in the output bfd after
+ it is closed.. */
+ for (sec = obfd->sections; sec; sec = sec->next)
+ stash_frchain_obs (sec);
+ stash_frchain_obs (reg_section);
+ stash_frchain_obs (expr_section);
+ stash_frchain_obs (bfd_abs_section_ptr);
+ stash_frchain_obs (bfd_und_section_ptr);
+ obstack_ptr_grow (¬es, NULL);
+ obs = obstack_finish (¬es);
+ }
+ else
+ obs = NULL;
/* Close the bfd. */
if (!flag_always_generate_output && had_errors ())
void
read_end (void)
{
+ if (!ENABLE_LEAK_CHECK)
+ return;
stabs_end ();
poend ();
_obstack_free (&cond_obstack, NULL);
static void
poend (void)
{
- htab_delete (po_hash);
+ if (ENABLE_LEAK_CHECK)
+ htab_delete (po_hash);
}
\f
#define HANDLE_CONDITIONAL_ASSEMBLY(num_read) \
void
stabs_end (void)
{
+ if (!ENABLE_LEAK_CHECK)
+ return;
free ((char *) current_function_label);
free (last_asm_file);
free (prev_line_file);
void
subsegs_end (struct obstack **obs)
{
+ if (!ENABLE_LEAK_CHECK)
+ return;
for (; *obs; obs++)
_obstack_free (*obs, NULL);
_obstack_free (&frchains, NULL);
void
symbol_end (void)
{
- htab_delete (sy_hash);
+ if (ENABLE_LEAK_CHECK)
+ htab_delete (sy_hash);
}
void