hppa64: Improve relocation handling for local symbols and add gc_section support

With this patch, gcc-16 can be built and there are significant
improvements in test results.  I spent a lot of time trying to
fix the EH exception support.  While there are still issues with
handling relocations in linkonce sessions, exception handling
mostly works if pc-relative and text relative encoding is used
in .eh_frame.  The main problems are the HP-UX dynamic linker
relocates the text and data segements indpendently, and it does
not support unaligned dynamic relocations.

Due to a configure bug in libstdc++-v3, the lack of gc_section
support caused many test failures, so I added the gc_section
support form elf32-hppa.c.

I also move the HP_LOAD_MAP scratchpad to the end of the .bss
section and fixed a number of issues with the linker scripts.

2026-01-20  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

	* elf64-hppa.c (elf64_hppa_check_relocs): Drop NEED_PLT
	from R_PARISC_LTOFF_FPTR relocations.  Revise R_PARISC_FPTR64
	relocation to use maybe_dynamic.  Add support for
	R_PARISC_GNU_VTINHERIT and R_PARISC_GNU_VTENTRY relocations.
	Add code to handle dynamic relocations of local symbols.
	(elf64_hppa_gc_mark_hook): New.
	(ensure_undef_dynamic): New.
	(allocate_dynrel_entries): Revise checks to determine when
	to discard relocs.
	(elf64_hppa_late_size_sections): Revise allocation of local
	PLT, DLT and OPD entries.
	(elf64_hppa_finalize_opd): Remove assert.
	(elf64_hppa_finalize_dlt): Change type of dynindx to long.
	(elf64_hppa_finalize_dynreloc): Likewise.  Add check for
	discarded sections.  Correct handling of  R_PARISC_FPTR64
	relocation.  Remove assert.  Add new assert to check that
	we don't allocate more relocs in .rela.data than it can
	hold.
	(elf64_hppa_finish_dynamic_sections): Move allocation for
	DT_HP_LOAD_MAP to end of .bss section.  Only allocate on
	HP-UX.
	(elf_hppa_dlt_dynrel_reloc): Add dynrel_type argument.
	Change type of dynindx.  Drop use of value.  Remove assert.
	(elf_hppa_opd_dynrel_relocs): Rename to elf_hppa_opd_eplt_reloc.
	Drop code to to emit R_PARISC_FPTR64 relocation.
	(elf_hppa_opd_fptr_reloc): New.
	(elf_hppa_final_link_relocate): Add SYM arguement.  Move
	check for SEC_DEBUGGING.  Rework DLT, LTOFF, FPTR and DIR64
	relocation handling.
	(elf64_hppa_relocate_section): Add asserts to ensure symbol
	isn't undefined and input_section hasn't been discarded.
	(elf_backend_gc_mark_hook): Define.
	(elf_backend_can_gc_sections): Define.

ld/ChangeLog:

	* emulparams/elf64hppa.sh (DATA_ADDR): Revise value to match
	HP-UX 11 value.
	(SHLIB_DATA_ADDR): Likewise.
	(NOP): Define.
	(OTHER_READONLY_SECTIONS): Add .data.rel, .HP.init, .preinit,
	.init and .fini sections to list.
	(__SYSTEM_ID_D, __TLS_SIZE_D, __FPU_REVISION, __FPU_MODEL,
	__CPU_REVISION, __CPU_KEYBITS_1, __LOAD_INFO, __ARGC, __ARGV,
	__ENVP, __libdl_jmp_tbl, __systab): Provide.
	(DATA_START_SYMBOLS, OTHER_SYMBOLS, INIT_START): Delete.
	(PREINIT_START, PREINIT_END, INIT_START): Define.
	emulparams/hppa64linux.sh (NOP): Define.
	(DATA_START_SYMBOLS): Delete.
	scripttempl/elf64hppa.sc: Delete .init and .fini sections
	from script.  Allocate 16 bytes at end of .bss for HP_LOAD_MAP.
4 files changed