Blame SOURCES/binutils-ifunc-relocs-in-notes.patch

13ae24
diff -rup binutils.orig/bfd/elf32-i386.c binutils-2.30/bfd/elf32-i386.c
13ae24
--- binutils.orig/bfd/elf32-i386.c	2018-03-09 14:43:05.324208873 +0000
13ae24
+++ binutils-2.30/bfd/elf32-i386.c	2018-03-09 14:43:23.158000456 +0000
13ae24
@@ -2202,12 +2202,19 @@ elf_i386_relocate_section (bfd *output_b
13ae24
 
13ae24
 	  if ((input_section->flags & SEC_ALLOC) == 0)
13ae24
 	    {
13ae24
+	      /* If this is a SHT_NOTE section without SHF_ALLOC, treat
13ae24
+	         STT_GNU_IFUNC symbol as STT_FUNC.  */
13ae24
+	      if (elf_section_type (input_section) == SHT_NOTE)
13ae24
+		goto skip_ifunc;
13ae24
 	      /* Dynamic relocs are not propagated for SEC_DEBUGGING
13ae24
 		 sections because such sections are not SEC_ALLOC and
13ae24
 		 thus ld.so will not process them.  */
13ae24
 	      if ((input_section->flags & SEC_DEBUGGING) != 0)
13ae24
 		continue;
13ae24
-	      abort ();
13ae24
+	      _bfd_error_handler (_("%B: error: relocation againt ifunc symbol in non-alloc section %A"),
13ae24
+				  input_bfd, input_section);
13ae24
+	      bfd_set_error (bfd_error_invalid_operation);
13ae24
+	      return FALSE;
13ae24
 	    }
13ae24
 
13ae24
 	  /* STT_GNU_IFUNC symbol must go through PLT.  */
13ae24
@@ -2421,6 +2428,7 @@ do_ifunc_pointer:
13ae24
 	    }
13ae24
 	}
13ae24
 
13ae24
+    skip_ifunc:
13ae24
       resolved_to_zero = (eh != NULL
13ae24
 			  && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
13ae24
 
13ae24
diff -rup binutils.orig/bfd/elf32-s390.c binutils-2.30/bfd/elf32-s390.c
13ae24
--- binutils.orig/bfd/elf32-s390.c	2018-03-09 14:43:05.325208861 +0000
13ae24
+++ binutils-2.30/bfd/elf32-s390.c	2018-03-09 14:43:31.353904647 +0000
13ae24
@@ -2601,6 +2601,9 @@ elf_s390_relocate_section (bfd *output_b
13ae24
 	case R_390_8:
13ae24
 	case R_390_16:
13ae24
 	case R_390_32:
13ae24
+	  if ((input_section->flags & SEC_ALLOC) == 0)
13ae24
+	    break;
13ae24
+
13ae24
 	  if (h != NULL
13ae24
 	      && s390_is_ifunc_symbol_p (h)
13ae24
 	      && h->def_regular)
13ae24
@@ -2662,9 +2665,6 @@ elf_s390_relocate_section (bfd *output_b
13ae24
 		}
13ae24
 	    }
13ae24
 
13ae24
-	  if ((input_section->flags & SEC_ALLOC) == 0)
13ae24
-	    break;
13ae24
-
13ae24
 	  if ((bfd_link_pic (info)
13ae24
 	       && (h == NULL
13ae24
 		   || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
13ae24
Only in binutils-2.30/bfd: elf32-s390.c.orig
13ae24
diff -rup binutils.orig/bfd/elf64-s390.c binutils-2.30/bfd/elf64-s390.c
13ae24
--- binutils.orig/bfd/elf64-s390.c	2018-03-09 14:43:05.341208674 +0000
13ae24
+++ binutils-2.30/bfd/elf64-s390.c	2018-03-09 14:43:31.354904635 +0000
13ae24
@@ -2559,6 +2559,9 @@ elf_s390_relocate_section (bfd *output_b
13ae24
 	case R_390_32:
13ae24
 	case R_390_64:
13ae24
 
13ae24
+	  if ((input_section->flags & SEC_ALLOC) == 0)
13ae24
+	    break;
13ae24
+
13ae24
 	  if (h != NULL
13ae24
 	      && s390_is_ifunc_symbol_p (h)
13ae24
 	      && h->def_regular)
13ae24
@@ -2621,9 +2624,6 @@ elf_s390_relocate_section (bfd *output_b
13ae24
 		}
13ae24
 	    }
13ae24
 
13ae24
-	  if ((input_section->flags & SEC_ALLOC) == 0)
13ae24
-	    break;
13ae24
-
13ae24
 	  if ((bfd_link_pic (info)
13ae24
 	       && (h == NULL
13ae24
 		   || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
13ae24
Only in binutils-2.30/bfd: elf64-s390.c.orig
13ae24
diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.30/bfd/elf64-x86-64.c
13ae24
--- binutils.orig/bfd/elf64-x86-64.c	2018-03-09 14:43:05.344208639 +0000
13ae24
+++ binutils-2.30/bfd/elf64-x86-64.c	2018-03-09 14:43:23.161000420 +0000
13ae24
@@ -2499,12 +2499,19 @@ elf_x86_64_relocate_section (bfd *output
13ae24
 
13ae24
 	  if ((input_section->flags & SEC_ALLOC) == 0)
13ae24
 	    {
13ae24
+	      /* If this is a SHT_NOTE section without SHF_ALLOC, treat
13ae24
+	         STT_GNU_IFUNC symbol as STT_FUNC.  */
13ae24
+	      if (elf_section_type (input_section) == SHT_NOTE)
13ae24
+		goto skip_ifunc;
13ae24
 	      /* Dynamic relocs are not propagated for SEC_DEBUGGING
13ae24
 		 sections because such sections are not SEC_ALLOC and
13ae24
 		 thus ld.so will not process them.  */
13ae24
 	      if ((input_section->flags & SEC_DEBUGGING) != 0)
13ae24
 		continue;
13ae24
-	      abort ();
13ae24
+	      _bfd_error_handler (_("%B: error: relocation againt ifunc symbol in non-alloc section %A"),
13ae24
+				  input_bfd, input_section);
13ae24
+	      bfd_set_error (bfd_error_invalid_operation);
13ae24
+	      return FALSE;
13ae24
 	    }
13ae24
 
13ae24
 	  switch (r_type)
13ae24
@@ -2722,6 +2729,7 @@ do_ifunc_pointer:
13ae24
 	    }
13ae24
 	}
13ae24
 
13ae24
+    skip_ifunc:
13ae24
       resolved_to_zero = (eh != NULL
13ae24
 			  && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
13ae24
 
13ae24
diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.30/bfd/elfnn-aarch64.c
13ae24
--- binutils.orig/bfd/elfnn-aarch64.c	2018-03-09 14:43:05.337208721 +0000
13ae24
+++ binutils-2.30/bfd/elfnn-aarch64.c	2018-03-09 14:43:31.355904624 +0000
13ae24
@@ -4987,6 +4987,11 @@ elfNN_aarch64_final_link_relocate (reloc
13ae24
 
13ae24
       if ((input_section->flags & SEC_ALLOC) == 0)
13ae24
 	{
13ae24
+	  /* If this is a SHT_NOTE section without SHF_ALLOC, treat
13ae24
+	     STT_GNU_IFUNC symbol as STT_FUNC.  */
13ae24
+	  if (elf_section_type (input_section) == SHT_NOTE)
13ae24
+	    goto skip_ifunc;
13ae24
+
13ae24
 	  /* Dynamic relocs are not propagated for SEC_DEBUGGING
13ae24
 	     sections because such sections are not SEC_ALLOC and
13ae24
 	     thus ld.so will not process them.  */
13ae24
@@ -5180,6 +5185,7 @@ bad_ifunc_reloc:
13ae24
 	}
13ae24
     }
13ae24
 
13ae24
+ skip_ifunc:
13ae24
   resolved_to_zero = (h != NULL
13ae24
 		      && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
13ae24
 
13ae24
Only in binutils-2.30/bfd: elfnn-aarch64.c.orig
13ae24
diff -rup binutils.orig/bfd/elfxx-sparc.c binutils-2.30/bfd/elfxx-sparc.c
13ae24
--- binutils.orig/bfd/elfxx-sparc.c	2018-03-09 14:43:05.333208768 +0000
13ae24
+++ binutils-2.30/bfd/elfxx-sparc.c	2018-03-09 14:43:31.355904624 +0000
13ae24
@@ -3026,7 +3026,13 @@ _bfd_sparc_elf_relocate_section (bfd *ou
13ae24
 
13ae24
 	  if ((input_section->flags & SEC_ALLOC) == 0
13ae24
 	      || h->plt.offset == (bfd_vma) -1)
13ae24
-	    abort ();
13ae24
+	    {
13ae24
+	      /* If this is a SHT_NOTE section without SHF_ALLOC, treat
13ae24
+	         STT_GNU_IFUNC symbol as STT_FUNC.  */
13ae24
+	      if (elf_section_type (input_section) == SHT_NOTE)
13ae24
+		goto skip_ifunc;
13ae24
+	      abort ();
13ae24
+	    }
13ae24
 
13ae24
 	  plt_sec = htab->elf.splt;
13ae24
 	  if (! plt_sec)
13ae24
@@ -3130,6 +3136,7 @@ _bfd_sparc_elf_relocate_section (bfd *ou
13ae24
 	    }
13ae24
 	}
13ae24
 
13ae24
+    skip_ifunc:
13ae24
       eh = (struct _bfd_sparc_elf_link_hash_entry *) h;
13ae24
       resolved_to_zero = (eh != NULL
13ae24
 			  && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
13ae24
Only in binutils-2.30/bfd: elfxx-sparc.c.orig
13ae24
diff -rup binutils.orig/ld/testsuite/ld-ifunc/ifunc.exp binutils-2.30/ld/testsuite/ld-ifunc/ifunc.exp
13ae24
--- binutils.orig/ld/testsuite/ld-ifunc/ifunc.exp	2018-03-09 14:43:04.844214486 +0000
13ae24
+++ binutils-2.30/ld/testsuite/ld-ifunc/ifunc.exp	2018-03-09 14:43:31.355904624 +0000
13ae24
@@ -47,6 +47,9 @@ if ![check_shared_lib_support] {
13ae24
     return
13ae24
 }
13ae24
 
13ae24
+# This test does not need a compiler...
13ae24
+run_dump_test "ifuncmod5"
13ae24
+
13ae24
 # We need a working compiler.  (Strictly speaking this is
13ae24
 # not true, we could use target specific assembler files).
13ae24
 if { [which $CC] == 0 } {
13ae24
Only in binutils-2.30: testsuite
13ae24
--- /dev/null	2018-03-09 07:59:09.608015200 +0000
13ae24
+++ binutils-2.30/ld/testsuite/ld-ifunc/ifuncmod5.s	2018-03-09 14:45:45.698334500 +0000
13ae24
@@ -0,0 +1,105 @@
13ae24
+	.file	"ifuncmod5.c"
13ae24
+
13ae24
+	.text
13ae24
+	.type ifuncmod5.c, STT_NOTYPE
13ae24
+ifuncmod5.c:
13ae24
+	.size ifuncmod5.c, 0
13ae24
+
13ae24
+	.pushsection .gnu.build.attributes, "", %note
13ae24
+	.balign 4
13ae24
+	.dc.l 8 	
13ae24
+	.dc.l 16	
13ae24
+	.dc.l 0x100	
13ae24
+	.asciz "GA$?3p4"	
13ae24
+	.dc.a ifuncmod5.c
13ae24
+	.dc.a ifuncmod5.c_end	
13ae24
+	.popsection
13ae24
+
13ae24
+.Ltext0:
13ae24
+#APP
13ae24
+	.protected global
13ae24
+	.type foo, %gnu_indirect_function
13ae24
+	.type foo_hidden, %gnu_indirect_function
13ae24
+	.type foo_protected, %gnu_indirect_function
13ae24
+	.hidden foo_hidden
13ae24
+	.protected foo_protected
13ae24
+#NO_APP
13ae24
+	.align	8
13ae24
+	.type	one, %function
13ae24
+one:
13ae24
+	.dc.l 0
13ae24
+	.size	one, .-one
13ae24
+	.align	8
13ae24
+
13ae24
+.globl foo
13ae24
+	.type	foo, %function
13ae24
+foo:
13ae24
+	.dc.l	0
13ae24
+	.size	foo, .-foo
13ae24
+
13ae24
+	.pushsection .gnu.build.attributes
13ae24
+	.dc.l 6		
13ae24
+	.dc.l 16	
13ae24
+	.dc.l 0x101	
13ae24
+	.dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 	
13ae24
+	.dc.b 0, 0 	
13ae24
+	.dc.a foo
13ae24
+	.dc.a foo_end	
13ae24
+	.popsection
13ae24
+
13ae24
+foo_end:
13ae24
+	.align	8
13ae24
+.globl foo_hidden
13ae24
+	.type	foo_hidden, %function
13ae24
+foo_hidden:
13ae24
+	.dc.l	0
13ae24
+	.size	foo_hidden, .-foo_hidden
13ae24
+
13ae24
+	.pushsection .gnu.build.attributes
13ae24
+	.dc.l 6		
13ae24
+	.dc.l 16	
13ae24
+	.dc.l 0x101	
13ae24
+	.dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 	
13ae24
+	.dc.b 0, 0 	
13ae24
+	.dc.a foo_hidden
13ae24
+	.dc.a foo_hidden_end	
13ae24
+	.popsection
13ae24
+
13ae24
+foo_hidden_end:
13ae24
+	.align	8
13ae24
+
13ae24
+	.globl foo_protected
13ae24
+	.type	foo_protected, %function
13ae24
+foo_protected:
13ae24
+	.dc.l	0
13ae24
+
13ae24
+	.size	foo_protected, .-foo_protected
13ae24
+
13ae24
+	.pushsection .gnu.build.attributes
13ae24
+	.dc.l 6		
13ae24
+	.dc.l 16	
13ae24
+	.dc.l 0x101	
13ae24
+	.dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0 	
13ae24
+	.dc.b 0, 0 	
13ae24
+	.dc.a foo_protected
13ae24
+	.dc.a foo_protected_end	
13ae24
+	.popsection
13ae24
+
13ae24
+foo_protected_end:
13ae24
+	.globl global
13ae24
+
13ae24
+	.data
13ae24
+	.align	4
13ae24
+	.type	global, %object
13ae24
+	.size	global, 4
13ae24
+global:
13ae24
+	.long	-1
13ae24
+
13ae24
+	.text
13ae24
+	.Letext0:
13ae24
+
13ae24
+ifuncmod5.c_end:
13ae24
+	.type ifuncmod5.c_end, STT_NOTYPE
13ae24
+	.size ifuncmod5.c_end, 0
13ae24
+
13ae24
+
13ae24
--- /dev/null	2018-03-09 07:59:09.608015200 +0000
13ae24
+++ binutils-2.30/ld/testsuite/ld-ifunc/ifuncmod5.d	2018-03-09 14:45:45.698334500 +0000
13ae24
@@ -0,0 +1,8 @@
13ae24
+# name: Reloc against IFUNC symbol in NOTE section
13ae24
+# ld: -shared
13ae24
+# nm: -p
13ae24
+
13ae24
+# We do not actually care about the notes at the moment.
13ae24
+# The purpose of this test is to make sure that the link completes successfully.
13ae24
+#pass
13ae24
+