PR22394, hppa-linux-ld fails to emit dynamic relocations
gcc -mfast-indirect-calls emits a function pointer initialization
without a P% (plabel) modifier. ld does not create the necessary
dynamic relocations for this to work. It turns out that the problem
is caused by the non_got_ref symbol flag. This flag is set for
non-pic by check_relocs to indicate that the symbol might need copy
relocations or dynamic relocations. Later, the backend
adjust_dynamic_symbol clears the flag to indicate dynamic relocations
are needed, but leaves it set when copy relocations were created. The
inversion in meaning is insane, but it's that way because the backend
adjust_dynamic_symbol function doesn't get to look at all symbols..
Anyway, the insanity works for non-function symbols. However, the
flag is left set on any function symbol with a dynamic relocation.
This patch fixes the non_got_ref handling for function symbols, adds
-z nocopyreloc for hppa-elf, reports where textrel occurs, and expands
comments. The check_relocs change just stops creation of dyn_relocs
we always threw away later.
PR 22394
* elf32-hppa.c (elf32_hppa_check_relocs): Don't create dyn_relocs
for plabels when non-pic.
(maybe_set_textrel): New function.
(readonly_dynrelocs): Move and rewrite.
(elf32_hppa_adjust_dynamic_symbol): Use it. Don't create copy
relocs when def_regular or -z nocopyreloc. Handle non_got_ref
for functions. Expand non_got_ref comments.
(elf32_hppa_size_dynamic_sections): Use maybe_set_textrel.