ld: bfd: sframe: KEEP .sframe sections and support gc-sections

Fix PR ld/32769

Currently, specifying --gc-sections causes the linker to discard all
input .sframe sections.  Fix this behaviour by adding KEEP for .sframe
sections, like it is being done for .eh_frame sections, in the default
ELF linker script.

Additionally, add logic in the linker to gc mark .sframe sections.
_bfd_elf_gc_mark () now is aware of SFrame sections. It relies on
elf_section_sframe () to get the SFrame section associated with the
text section.

Also, the _bfd_elf_parse_sframe is changed to return TRUE when the
input sframe section is already parsed. It fixes calling
_bfd_elf_discard_section_sframe function in bfd_elf_discard_info,
enabling correct behavior for discarding unneeded sframe sections.

ld/
	PR ld/32769
	* scripttempl/elf.sc: KEEP .sframe sections.
bfd/
	* elf-bfd.h (struct elf_obj_tdata): Add sframe section pointer.
	(elf_sframe_section): New macro.
	* elflink.c (_bfd_elf_gc_mark): Handle SFrame sections.
	(bfd_elf_gc_sections): Likewise.
	(bfd_elf_discard_info): Update for handling gc operations.
	* elf-sframe.c (_bfd_elf_parse_sframe): Return TRUE for already
	parsed sframe sections.

Co-authored-by: Indu Bhagat <indu.bhagat@oracle.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
4 files changed