488c472
diff -rup binutils.orig/bfd/elf32-i386.c binutils-2.29/bfd/elf32-i386.c
488c472
--- binutils.orig/bfd/elf32-i386.c	2018-03-09 15:45:28.758238880 +0000
488c472
+++ binutils-2.29/bfd/elf32-i386.c	2018-03-09 15:47:19.000943106 +0000
488c472
@@ -4097,6 +4097,10 @@ elf_i386_relocate_section (bfd *output_b
488c472
 
488c472
 	  if ((input_section->flags & SEC_ALLOC) == 0)
488c472
 	    {
488c472
+	      /* If this is a SHT_NOTE section without SHF_ALLOC, treat
488c472
+	         STT_GNU_IFUNC symbol as STT_FUNC.  */
488c472
+	      if (elf_section_type (input_section) == SHT_NOTE)
488c472
+		goto skip_ifunc;
488c472
 	      /* Dynamic relocs are not propagated for SEC_DEBUGGING
488c472
 		 sections because such sections are not SEC_ALLOC and
488c472
 		 thus ld.so will not process them.  */
488c472
@@ -4318,6 +4322,7 @@ do_ifunc_pointer:
488c472
 	    }
488c472
 	}
488c472
 
488c472
+    skip_ifunc:
488c472
       resolved_to_zero = (eh != NULL
488c472
 			  && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
488c472
 							      eh->has_got_reloc,
488c472
diff -rup binutils.orig/bfd/elf32-s390.c binutils-2.29/bfd/elf32-s390.c
488c472
--- binutils.orig/bfd/elf32-s390.c	2018-03-09 15:45:28.775238681 +0000
488c472
+++ binutils-2.29/bfd/elf32-s390.c	2018-03-09 15:47:50.219576165 +0000
488c472
@@ -2770,6 +2770,9 @@ elf_s390_relocate_section (bfd *output_b
488c472
 	case R_390_8:
488c472
 	case R_390_16:
488c472
 	case R_390_32:
488c472
+	  if ((input_section->flags & SEC_ALLOC) == 0)
488c472
+	    break;
488c472
+
488c472
 	  if (h != NULL
488c472
 	      && s390_is_ifunc_symbol_p (h)
488c472
 	      && h->def_regular)
488c472
@@ -2831,9 +2834,6 @@ elf_s390_relocate_section (bfd *output_b
488c472
 		}
488c472
 	    }
488c472
 
488c472
-	  if ((input_section->flags & SEC_ALLOC) == 0)
488c472
-	    break;
488c472
-
488c472
 	  if ((bfd_link_pic (info)
488c472
 	       && (h == NULL
488c472
 		   || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
488c472
diff -rup binutils.orig/bfd/elf64-s390.c binutils-2.29/bfd/elf64-s390.c
488c472
--- binutils.orig/bfd/elf64-s390.c	2018-03-09 15:45:28.779238634 +0000
488c472
+++ binutils-2.29/bfd/elf64-s390.c	2018-03-09 15:48:30.734099969 +0000
488c472
@@ -2737,6 +2737,9 @@ elf_s390_relocate_section (bfd *output_b
488c472
 	case R_390_32:
488c472
 	case R_390_64:
488c472
 
488c472
+	  if ((input_section->flags & SEC_ALLOC) == 0)
488c472
+	    break;
488c472
+
488c472
 	  if (h != NULL
488c472
 	      && s390_is_ifunc_symbol_p (h)
488c472
 	      && h->def_regular)
488c472
@@ -2799,9 +2802,6 @@ elf_s390_relocate_section (bfd *output_b
488c472
 		}
488c472
 	    }
488c472
 
488c472
-	  if ((input_section->flags & SEC_ALLOC) == 0)
488c472
-	    break;
488c472
-
488c472
 	  if ((bfd_link_pic (info)
488c472
 	       && (h == NULL
488c472
 		   || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
488c472
diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.29/bfd/elf64-x86-64.c
488c472
--- binutils.orig/bfd/elf64-x86-64.c	2018-03-09 15:45:28.772238716 +0000
488c472
+++ binutils-2.29/bfd/elf64-x86-64.c	2018-03-09 15:48:59.184765567 +0000
488c472
@@ -4426,6 +4426,10 @@ elf_x86_64_relocate_section (bfd *output
488c472
 
488c472
 	  if ((input_section->flags & SEC_ALLOC) == 0)
488c472
 	    {
488c472
+	      /* If this is a SHT_NOTE section without SHF_ALLOC, treat
488c472
+	         STT_GNU_IFUNC symbol as STT_FUNC.  */
488c472
+	      if (elf_section_type (input_section) == SHT_NOTE)
488c472
+		goto skip_ifunc;
488c472
 	      /* Dynamic relocs are not propagated for SEC_DEBUGGING
488c472
 		 sections because such sections are not SEC_ALLOC and
488c472
 		 thus ld.so will not process them.  */
488c472
@@ -4651,6 +4655,7 @@ do_ifunc_pointer:
488c472
 	    }
488c472
 	}
488c472
 
488c472
+    skip_ifunc:
488c472
       resolved_to_zero = (eh != NULL
488c472
 			  && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
488c472
 							      eh->has_got_reloc,
488c472
diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.29/bfd/elfnn-aarch64.c
488c472
--- binutils.orig/bfd/elfnn-aarch64.c	2018-03-09 15:45:28.768238763 +0000
488c472
+++ binutils-2.29/bfd/elfnn-aarch64.c	2018-03-09 15:53:05.151874514 +0000
488c472
@@ -4981,6 +4981,20 @@ elfNN_aarch64_final_link_relocate (reloc
488c472
       const char *name;
488c472
       bfd_vma addend = 0;
488c472
 
488c472
+      if ((input_section->flags & SEC_ALLOC) == 0)
488c472
+	{
488c472
+	  /* If this is a SHT_NOTE section without SHF_ALLOC, treat
488c472
+	     STT_GNU_IFUNC symbol as STT_FUNC.  */
488c472
+	  if (elf_section_type (input_section) == SHT_NOTE)
488c472
+	    goto skip_ifunc;
488c472
+
488c472
+	  /* Dynamic relocs are not propagated for SEC_DEBUGGING
488c472
+	     sections because such sections are not SEC_ALLOC and
488c472
+	     thus ld.so will not process them.  */
488c472
+	  if ((input_section->flags & SEC_DEBUGGING) != 0)
488c472
+	    return bfd_reloc_ok;
488c472
+	}
488c472
+
488c472
       if ((input_section->flags & SEC_ALLOC) == 0
488c472
 	  || h->plt.offset == (bfd_vma) -1)
488c472
 	abort ();
488c472
@@ -5157,6 +5171,7 @@ elfNN_aarch64_final_link_relocate (reloc
488c472
 	}
488c472
     }
488c472
 
488c472
+ skip_ifunc:
488c472
   switch (bfd_r_type)
488c472
     {
488c472
     case BFD_RELOC_AARCH64_NONE:
488c472
diff -rup binutils.orig/bfd/elfxx-sparc.c binutils-2.29/bfd/elfxx-sparc.c
488c472
--- binutils.orig/bfd/elfxx-sparc.c	2018-03-09 15:45:28.767238774 +0000
488c472
+++ binutils-2.29/bfd/elfxx-sparc.c	2018-03-09 15:53:51.395330976 +0000
488c472
@@ -3203,7 +3203,13 @@ _bfd_sparc_elf_relocate_section (bfd *ou
488c472
 
488c472
 	  if ((input_section->flags & SEC_ALLOC) == 0
488c472
 	      || h->plt.offset == (bfd_vma) -1)
488c472
-	    abort ();
488c472
+	    {
488c472
+	      /* If this is a SHT_NOTE section without SHF_ALLOC, treat
488c472
+	         STT_GNU_IFUNC symbol as STT_FUNC.  */
488c472
+	      if (elf_section_type (input_section) == SHT_NOTE)
488c472
+		goto skip_ifunc;
488c472
+	      abort ();
488c472
+	    }
488c472
 
488c472
 	  plt_sec = htab->elf.splt;
488c472
 	  if (! plt_sec)
488c472
@@ -3307,6 +3313,7 @@ _bfd_sparc_elf_relocate_section (bfd *ou
488c472
 	    }
488c472
 	}
488c472
 
488c472
+    skip_ifunc:
488c472
       eh = (struct _bfd_sparc_elf_link_hash_entry *) h;
488c472
       resolved_to_zero = (eh != NULL
488c472
                           && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));