gas: only free on exit when --enable-leak-check

Adds a new --enable-leak-check option, controlling whether memory is
freed before exit in order to find memory leaks.  The default is to
free memory if BFD_ASAN is non-zero.

	* configure.ac: Add new --enable-leak-check..
	(ENABLE_LEAK_CHECK): ..defining this.
	* as.c (gas_early_init): free_notes on exit only if ENABLE_LEAK_CHECK.
	* expr.c (expr_end): Nothing to do when !ENABLE_LEAK_CHECK.
	* macro.c (macro_end): Likewise.
	* output-file.c (output_file_close): Don't stash frchain obstacks
	when !ENABLE_LEAK_CHECK.
	* read.c (read_end): Nothing to do when !ENABLE_LEAK_CHECK.
	(poend): Likewise.
	* stabs.c (stabs_end): Likewise.
	* subsegs.c (subsegs_end): Likewise.
	* symbols.c (symbol_end): Likewise.
	* config/obj-elf-attr.c (oav1_attr_info_exit): Likewise.
	* config/obj-elf.c (elf_end): Likewise.
	* config/tc-arc.c (arc_md_end): Likewise.
	* config/tc-i386.c (i386_md_end): Likewise.
	* config/tc-loongarch.c (loongarch_md_end): Likewise.
	* config/tc-ppc.c (ppc_md_end): Likewise.
	* config/tc-pru.c (pru_md_end): Likewise.
	* config/tc-riscv.c (riscv_md_end): Likewise.
	* config/tc-tic54x.c (tic54x_md_end): Likewise.
	* configure: Regenerate.
	* config.in: Regenerate.
20 files changed