x86: Free the symbol buffer and the relocation buffer after use
When --no-keep-memory is used, the symbol buffer and the relocation
buffer aren't cached. When packing relative relocations, we may
allocate a new symbol buffer and a new relocation buffer for each
eligible section in an object file. If there are many sections,
memory may be exhausted. In this case, we should free the symbol
buffer and the relocation buffer after use. If symbol buffer entries
are used to track relative relocations against local symbols for later
use, the symbol buffer should be cached.
PR ld/30566
* elfxx-x86.c (elf_x86_relative_reloc_record_add): Add an
argument to inform caller if the symbol buffer should be kept.
(_bfd_x86_elf_link_relax_section): Call
_bfd_elf_link_info_read_relocs instead of
_bfd_elf_link_read_relocs. Free the symbol buffer and the
relocation buffer after use. Cache the symbol buffer if it
is used.