coff keep_relocs and keep_contents
authorAlan Modra <amodra@gmail.com>
Thu, 9 Feb 2023 01:38:10 +0000 (12:08 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 9 Feb 2023 09:37:55 +0000 (20:07 +1030)
commitc920e5cc604c5b20f9af7c75402eea94aa1e11c6
treee587f40d85d4a84aa9390b60744dcfb1b74f5811
parent0d78a4c40eaa1b709e482044c17ce6d0f05b2f9c
coff keep_relocs and keep_contents

keep_relocs is set by pe_ILF_save_relocs but not used anywhere in the
coff/pe code.  It is tested by the xcoff backend but not set.

keep_contents is only used by the xcoff backend when dealing with
the .loader section, and it's easy enough to dispense with it there.
keep_contents is set in various places but that's fairly useless when
the contents aren't freed anyway until later linker support functions,
add_dynamic_symbols and check_dynamic_ar_symbols.  There the contents
were freed if keep_contents wasn't set.  I reckon we can free them
unconditionally.

* coff-bfd.h (struct coff_section_tdata): Delete keep_relocs
and keep_contents.
* peicode.h (pe_ILF_save_relocs): Don't set keep_relocs.
* xcofflink.c (xcoff_get_section_contents): Cache contents.
Return the contents.  Update callers.
(_bfd_xcoff_canonicalize_dynamic_symtab): Don't set
keep_contents for .loader.
(xcoff_link_add_dynamic_symbols): Free .loader contents
unconditionally.
(xcoff_link_check_dynamic_ar_symbols): Likewise.
bfd/coff-bfd.h
bfd/peicode.h
bfd/xcofflink.c