s390: Do not rewrite insns and their relocs in linker if --no-relax

Under certain conditions the linker rewrites:
- GOT access using lgrl to larl, changing the GOTENT to a PC32DBL reloc
- GOT access using lg to larl, changing the GOT20 to a PC32DBL reloc
- Relative long addressing instructions of weak symbols, which
  definitively resolve to zero to either (1) load address of zero,
  (2) a NOP, or (3) a trapping instruction, changing the relocation to
  a NONE reloc.

Suppress rewriting of non-TLS instructions and related relocations in
linker if option --no-relax is specified.  This aligns with LLVM linker
behavior on s390.

Like x86-64 do not actually enable the linker relaxation option by
default, as other targets would do using ENABLE_RELAXATION or
TARGET_ENABLE_RELAXATION in their linker emulation scripts.  Instead
perform linker instruction/relocation rewrites by default unless linker
option --no-relax is explicitly specified by the user.  This ensures no
functional change unless --no-relax is used.

bfd/
	* elf64-s390.c (elf_s390_relocate_section): Do not rewrite
	non-TLS instructions and related relocations if --no-relax.
	* elf32-s390.c (elf_s390_relocate_section): Likewise.

ld/testsuite/
	* ld-s390/s390.exp: New tests.  Same as gotreloc_*-1a and
	weakundef-*a, but with linker option --no-relax, to verify
	suppression of linker non-TLS insn and reloc rewrites.
	* ld-s390/gotreloc_31-1b.dd: Likewise.
	* ld-s390/gotreloc_31-no-pie-1b.dd: Likewise.
	* ld-s390/gotreloc_64-no-pie-1b.dd: Likewise.
	* ld-s390/gotreloc_64-norelro-1b.dd: Likewise.
	* ld-s390/gotreloc_64-relro-1b.dd: Likewise.
	* ld-s390/weakundef-1b.d: Likewise.  Check for expected reloc
	overflows.
	* ld-s390/weakundef-2b.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
10 files changed