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