binary outsymbols

This fixes leaks of outsymbols for various targets that use the
generic linker.  The key fix here is to not generate output symbols
for targets that won't ever write symbols, and of course to free
outsymbols after they've been written in targets that do.  Target
vector object_flags and section_flags are updated to better reflect
target capabilities, in particular not setting HAS_SYMS or SEC_RELOC
when the target does not support symbols or relocs.

	* binary.c (binary_vec): Update section_flags.
	* linker.c (generic_add_output_symbol): Don't add to
	outsymbols if !HAS_SYMS.
	* srec.c (srec_write_symbols): Free outsymbols on return.
	(srec_vec): Update object_flags and section_flags.
	(symbolsrec_vec): Likewise.
	* tekhex.c (tekhex_write_object_contents): Free outsymbols on
	return.
	(tekhex_vec): Update object_flags and section_flags.
	* verilog.c (verilog_vec): Likewise.
This commit is contained in:
Alan Modra
2025-01-16 14:51:56 +10:30
parent 394a3f4f8d
commit 6ca01b0bdd
5 changed files with 33 additions and 24 deletions

View File

@@ -384,11 +384,9 @@ const bfd_target verilog_vec =
bfd_target_verilog_flavour,
BFD_ENDIAN_UNKNOWN, /* Target byte order. */
BFD_ENDIAN_UNKNOWN, /* Target headers byte order. */
(HAS_RELOC | EXEC_P | /* Object flags. */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
EXEC_P, /* Object flags. */
(SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
| SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */
| SEC_ALLOC | SEC_LOAD), /* Section flags. */
0, /* Leading underscore. */
' ', /* AR_pad_char. */
16, /* AR_max_namelen. */