d0117f
--- binutils.orig/bfd/elf64-s390.c	2020-06-15 11:01:54.671940830 +0100
d0117f
+++ binutils-2.30/bfd/elf64-s390.c	2020-06-15 11:04:44.663343784 +0100
d0117f
@@ -2335,6 +2335,9 @@ elf_s390_relocate_section (bfd *output_b
d0117f
 			   && SYMBOL_REFERENCES_LOCAL (info, h))
d0117f
 		       || resolved_to_zero)
d0117f
 		{
d0117f
+		  Elf_Internal_Sym *isym;
d0117f
+		  asection *sym_sec;
d0117f
+
d0117f
 		  /* This is actually a static link, or it is a
d0117f
 		     -Bsymbolic link and the symbol is defined
d0117f
 		     locally, or the symbol was forced to be local
d0117f
@@ -2356,6 +2359,10 @@ elf_s390_relocate_section (bfd *output_b
d0117f
 		      h->got.offset |= 1;
d0117f
 		    }
d0117f
 
d0117f
+		  /* When turning a GOT slot dereference into a direct
d0117f
+		     reference using larl we have to make sure that
d0117f
+		     the symbol is 1. properly aligned and 2. it is no
d0117f
+		     ABS symbol or will become one.  */
d0117f
 		  if ((h->def_regular
d0117f
 		       && bfd_link_pic (info)
d0117f
 		       && SYMBOL_REFERENCES_LOCAL (info, h))
d0117f
@@ -2370,8 +2377,17 @@ elf_s390_relocate_section (bfd *output_b
d0117f
 					      contents + rel->r_offset - 2)
d0117f
 				  & 0xff00f000) == 0xe300c000
d0117f
 			      && bfd_get_8 (input_bfd,
d0117f
-					    contents + rel->r_offset + 3) == 0x04)))
d0117f
-
d0117f
+					    contents + rel->r_offset + 3) == 0x04))
d0117f
+		      && (isym = bfd_sym_from_r_symndx (&htab->sym_cache,
d0117f
+							input_bfd, r_symndx))
d0117f
+		      && isym->st_shndx != SHN_ABS
d0117f
+		      && h != htab->elf.hdynamic
d0117f
+		      && h != htab->elf.hgot
d0117f
+		      && h != htab->elf.hplt
d0117f
+		      && !(isym->st_value & 1)
d0117f
+		      && (sym_sec = bfd_section_from_elf_index (input_bfd,
d0117f
+								isym->st_shndx))
d0117f
+		      && sym_sec->alignment_power)
d0117f
 		    {
d0117f
 		      unsigned short new_insn =
d0117f
 			(0xc000 | (bfd_get_8 (input_bfd,