Blame SOURCES/binutils-s390x-static-PIE.patch

7fa5cb
diff -rup binutils.orig/bfd/elf64-s390.c binutils-2.35.2/bfd/elf64-s390.c
7fa5cb
--- binutils.orig/bfd/elf64-s390.c	2022-05-03 12:03:39.004203905 +0100
7fa5cb
+++ binutils-2.35.2/bfd/elf64-s390.c	2022-05-03 12:06:19.884715801 +0100
7fa5cb
@@ -773,7 +773,7 @@ elf_s390_tls_transition (struct bfd_link
7fa5cb
 			 int r_type,
7fa5cb
 			 int is_local)
7fa5cb
 {
7fa5cb
-  if (bfd_link_pic (info))
7fa5cb
+  if (bfd_link_dll (info))
7fa5cb
     return r_type;
7fa5cb
 
7fa5cb
   switch (r_type)
7fa5cb
@@ -1025,7 +1025,7 @@ elf_s390_check_relocs (bfd *abfd,
7fa5cb
 	case R_390_TLS_GOTIE20:
7fa5cb
 	case R_390_TLS_GOTIE64:
7fa5cb
 	case R_390_TLS_IEENT:
7fa5cb
-	  if (bfd_link_pic (info))
7fa5cb
+	  if (bfd_link_dll (info))
7fa5cb
 	    info->flags |= DF_STATIC_TLS;
7fa5cb
 	  /* Fall through */
7fa5cb
 
7fa5cb
@@ -1106,7 +1106,7 @@ elf_s390_check_relocs (bfd *abfd,
7fa5cb
 	  if (r_type == R_390_TLS_LE64 && bfd_link_pie (info))
7fa5cb
 	    break;
7fa5cb
 
7fa5cb
-	  if (!bfd_link_pic (info))
7fa5cb
+	  if (!bfd_link_dll (info))
7fa5cb
 	    break;
7fa5cb
 	  info->flags |= DF_STATIC_TLS;
7fa5cb
 	  /* Fall through */
7fa5cb
@@ -1570,7 +1570,7 @@ allocate_dynrelocs (struct elf_link_hash
7fa5cb
      to R_390_TLS_LE64 requiring no TLS entry. For GOTIE12 and IEENT
7fa5cb
      we can save the dynamic TLS relocation.  */
7fa5cb
   if (h->got.refcount > 0
7fa5cb
-      && !bfd_link_pic (info)
7fa5cb
+      && !bfd_link_dll (info)
7fa5cb
       && h->dynindx == -1
7fa5cb
       && elf_s390_hash_entry(h)->tls_type >= GOT_TLS_IE)
7fa5cb
     {
7fa5cb
@@ -1875,7 +1875,20 @@ elf_s390_size_dynamic_sections (bfd *out
7fa5cb
       else if (CONST_STRNEQ (bfd_section_name (s), ".rela"))
7fa5cb
 	{
7fa5cb
 	  if (s->size != 0 && s != htab->elf.srelplt)
7fa5cb
-	    relocs = TRUE;
7fa5cb
+	    {
7fa5cb
+	      relocs = TRUE;
7fa5cb
+	      if (s == htab->elf.irelplt)
7fa5cb
+		{
7fa5cb
+		  /* In static-pie case, there are IRELATIVE-relocs in
7fa5cb
+		     .rela.iplt (htab->irelplt), which will later be grouped
7fa5cb
+		     to .rela.plt.  On s390, the IRELATIVE relocations are
7fa5cb
+		     always located in .rela.iplt - even for non-static case.
7fa5cb
+		     Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added
7fa5cb
+		     to the dynamic section even if htab->srelplt->size == 0.
7fa5cb
+		     See _bfd_elf_add_dynamic_tags in bfd/elflink.c.  */
7fa5cb
+		  htab->elf.dt_jmprel_required = TRUE;
7fa5cb
+		}
7fa5cb
+	    }
7fa5cb
 
7fa5cb
 	  /* We use the reloc_count field as a counter if we need
7fa5cb
 	     to copy relocs into the output file.  */
7fa5cb
@@ -2661,7 +2674,7 @@ elf_s390_relocate_section (bfd *output_b
7fa5cb
 
7fa5cb
 	  /* Relocations for tls literal pool entries.  */
7fa5cb
 	case R_390_TLS_IE64:
7fa5cb
-	  if (bfd_link_pic (info))
7fa5cb
+	  if (bfd_link_dll (info))
7fa5cb
 	    {
7fa5cb
 	      Elf_Internal_Rela outrel;
7fa5cb
 	      asection *sreloc;
7fa5cb
@@ -2689,7 +2702,7 @@ elf_s390_relocate_section (bfd *output_b
7fa5cb
 	  else if (h != NULL)
7fa5cb
 	    {
7fa5cb
 	      tls_type = elf_s390_hash_entry(h)->tls_type;
7fa5cb
-	      if (!bfd_link_pic (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
7fa5cb
+	      if (!bfd_link_dll (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE)
7fa5cb
 		r_type = R_390_TLS_LE64;
7fa5cb
 	    }
7fa5cb
 	  if (r_type == R_390_TLS_GD64 && tls_type >= GOT_TLS_IE)
7fa5cb
@@ -2800,14 +2813,14 @@ elf_s390_relocate_section (bfd *output_b
7fa5cb
 	      if (local_got_offsets == NULL)
7fa5cb
 		abort();
7fa5cb
 	      off = local_got_offsets[r_symndx];
7fa5cb
-	      if (bfd_link_pic (info))
7fa5cb
+	      if (bfd_link_dll (info))
7fa5cb
 		goto emit_tls_relocs;
7fa5cb
 	    }
7fa5cb
 	  else
7fa5cb
 	    {
7fa5cb
 	      off = h->got.offset;
7fa5cb
 	      tls_type = elf_s390_hash_entry(h)->tls_type;
7fa5cb
-	      if (bfd_link_pic (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
7fa5cb
+	      if (bfd_link_dll (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE)
7fa5cb
 		goto emit_tls_relocs;
7fa5cb
 	    }
7fa5cb
 
7fa5cb
@@ -2824,7 +2837,7 @@ elf_s390_relocate_section (bfd *output_b
7fa5cb
 	  break;
7fa5cb
 
7fa5cb
 	case R_390_TLS_LDM64:
7fa5cb
-	  if (! bfd_link_pic (info))
7fa5cb
+	  if (! bfd_link_dll (info))
7fa5cb
 	    /* The literal pool entry this relocation refers to gets ignored
7fa5cb
 	       by the optimized code of the local exec model. Do nothing
7fa5cb
 	       and the value will turn out zero.  */
7fa5cb
@@ -2899,7 +2912,7 @@ elf_s390_relocate_section (bfd *output_b
7fa5cb
 	  continue;
7fa5cb
 
7fa5cb
 	case R_390_TLS_LDO64:
7fa5cb
-	  if (bfd_link_pic (info) || (input_section->flags & SEC_DEBUGGING))
7fa5cb
+	  if (bfd_link_dll (info) || (input_section->flags & SEC_DEBUGGING))
7fa5cb
 	    relocation -= dtpoff_base (info);
7fa5cb
 	  else
7fa5cb
 	    /* When converting LDO to LE, we must negate.  */
7fa5cb
@@ -2921,7 +2934,7 @@ elf_s390_relocate_section (bfd *output_b
7fa5cb
 
7fa5cb
 	  if (r_type == R_390_TLS_LOAD)
7fa5cb
 	    {
7fa5cb
-	      if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
7fa5cb
+	      if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
7fa5cb
 		{
7fa5cb
 		  /* IE->LE transition. Four valid cases:
7fa5cb
 		     lg %rx,(0,%ry)    -> sllg %rx,%ry,0
7fa5cb
@@ -2971,7 +2984,7 @@ elf_s390_relocate_section (bfd *output_b
7fa5cb
 		  invalid_tls_insn (input_bfd, input_section, rel);
7fa5cb
 		  return FALSE;
7fa5cb
 		}
7fa5cb
-	      if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1))
7fa5cb
+	      if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1))
7fa5cb
 		{
7fa5cb
 		  /* GD->LE transition.
7fa5cb
 		     brasl %r14,__tls_get_addr@plt -> brcl 0,. */
7fa5cb
@@ -2990,7 +3003,7 @@ elf_s390_relocate_section (bfd *output_b
7fa5cb
 	    }
7fa5cb
 	  else if (r_type == R_390_TLS_LDCALL)
7fa5cb
 	    {
7fa5cb
-	      if (!bfd_link_pic (info))
7fa5cb
+	      if (!bfd_link_dll (info))
7fa5cb
 		{
7fa5cb
 		  unsigned int insn0, insn1;
7fa5cb
 
7fa5cb
Only in binutils-2.35.2/bfd: elf64-s390.c.orig
7fa5cb
Only in binutils-2.35.2/bfd: elf64-s390.c.rej