This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix --eh-frame-hdr with DW_EH_PE_absptr in shared libs


Hi!

The following patch enables DW_EH_PE_absptr -> DW_EH_PE_pcrel optimization
for shared libs (no runtime relocs needed) for targets where gcc doesn't do
this already in assembly for various reasons.
In addition to this, if this optimization is not possible and FDE encoding
is still DW_EH_PE_absptr, doesn't create the binary search table in
.eh_frame_hdr. I thought about making this work anyway, but the code would
need to have at least some understanding of ELF target relocs which doesn't
look like 2.12 material.
The main change is that _bfd_elf_section_offset has 2 special return values
instead of 1 (previously just -1 (skip), now -1 (skip) and -2 (skip dynamic
reloc, install relocation)). If _bfd_elf_section_offset returns -2, target
relocate_section should avoid dynamic relocation at this offset, but should
call _bfd_final_link_relocate or whatever it uses to install the relocation,
so that _bfd_elf_write_section_eh_frame reads the relocated value.

I've changed all targets but elf{32,64}-mips.c, can any of the MIPS folks
look at this?

absptr -> pcrel conversion is done for LSDA pointers plus for FDE pointers
if R augmentation was emitted by gcc (this is because enlarging CIEs so that
R augmentation for DW_EH_PE_pcrel FDE encoding would need too much linker
work).
So, if gcc wants to use this conversion, it should do something like:
--- gcc/dwarf2out.c.jj	Wed Jan 30 12:17:55 2002
+++ gcc/dwarf2out.c	Mon Feb 18 15:38:54 2002
@@ -1869,7 +1869,14 @@ output_call_frame_info (for_eh)
 	  *p++ = 'L';
 	  augmentation_size += 1;
 	}
-      if (fde_encoding != DW_EH_PE_absptr)
+      if (fde_encoding != DW_EH_PE_absptr
+#ifdef HAVE_LD_EH_FRAME_HDR
+	  /* If linker supports .eh_frame optimization, emitting R
+	     augmentation allows it to convert DW_EH_PE_absptr FDE
+	     addresses to DW_EH_PE_pcrel.  */
+	  || flag_pic
+#endif
+	  )
 	{
 	  *p++ = 'R';
 	  augmentation_size += 1;

Ok to commit?

2002-02-18  Jakub Jelinek  <jakub@redhat.com>

	* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Enable
	absptr -> pcrel optimization for shared libs.
	Only create minimal .eh_frame_hdr if absptr FDE encoding in shared
	library cannot be converted to pcrel.
	(_bfd_elf_eh_frame_section_offset): Return -2 if making absptr
	relative.
	* elf32-i386.c (elf_i386_relocate_section): If
	_bfd_elf_section_offset returned -2, skip, but make sure the
	relocation is installed.
	* elf32-arm.h (elf32_arm_final_link_relocate): Likewise.
	* elf32-cris.c (cris_elf_relocate_section): Likewise.
	* elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
	* elf32-i370.c (i370_elf_relocate_section): Likewise.
	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
	* elf32-s390.c (elf_s390_relocate_section): Likewise.
	* elf32-sh.c (sh_elf_relocate_section): Likewise.
	* elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
	* elf64-s390.c (elf_s390_relocate_section): Likewise.
	* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
	* elf64-sparc.c	(sparc64_elf_relocate_section): Likewise.
	* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
	* elf64-alpha.c (elf64_alpha_relocate_section): Handle
	_bfd_elf_section_offset returning -2 the same way as -1.
	* elfxx-ia64.c (elfNN_ia64_install_dyn_reloc): Likewise.

--- bfd/elf-eh-frame.c.jj	Mon Jan 28 14:42:17 2002
+++ bfd/elf-eh-frame.c	Mon Feb 18 13:20:00 2002
@@ -586,16 +586,12 @@ _bfd_elf_discard_section_eh_frame (abfd,
 	    }
 
 	  /* For shared libraries, try to get rid of as many RELATIVE relocs
-	     as possible.
-	     FIXME: For this to work, ELF backends need to perform the
-	     relocation if omitting dynamic relocs, not skip it.  */
-          if (0
-	      && info->shared
+	     as possible.  */
+          if (info->shared
 	      && (cie.fde_encoding & 0xf0) == DW_EH_PE_absptr)
 	    cie.make_relative = 1;
 
-	  if (0
-	      && info->shared
+	  if (info->shared
 	      && (cie.lsda_encoding & 0xf0) == DW_EH_PE_absptr)
 	    cie.make_lsda_relative = 1;
 
@@ -636,6 +632,16 @@ _bfd_elf_discard_section_eh_frame (abfd,
 	    }
 	  else
 	    {
+	      if (info->shared
+		  && (cie.fde_encoding & 0xf0) == DW_EH_PE_absptr
+		  && cie.make_relative == 0)
+		{
+		  /* If shared library uses absolute pointers
+		     which we cannot turn into PC relative,
+		     don't create the binary search table,
+		     since it is affected by runtime relocations.  */
+		  hdr_info->table = false;
+		}
 	      cie_usage_count++;
 	      hdr_info->fde_count++;
 	    }
@@ -856,7 +862,7 @@ _bfd_elf_eh_frame_section_offset (output
   if (sec_info->entry[mid].make_relative
       && ! sec_info->entry[mid].cie
       && offset == sec_info->entry[mid].offset + 8)
-    return (bfd_vma) -1;
+    return (bfd_vma) -2;
 
   /* If converting LSDA pointers to DW_EH_PE_pcrel, there will be no need
      for run-time relocation against LSDA field.  */
@@ -865,7 +871,7 @@ _bfd_elf_eh_frame_section_offset (output
       && (offset
 	  == (sec_info->entry[mid].offset + 8
 	      + sec_info->entry[mid].lsda_offset)))
-    return (bfd_vma) -1;
+    return (bfd_vma) -2;
 
   return (offset + sec_info->entry[mid].new_offset
 	  - sec_info->entry[mid].offset);
--- bfd/elf32-i386.c.jj	Tue Feb 12 14:56:56 2002
+++ bfd/elf32-i386.c	Fri Feb 15 10:11:01 2002
@@ -2006,20 +2006,20 @@ elf_i386_relocate_section (output_bfd, i
 		 time.  */
 
 	      skip = false;
+	      relocate = false;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = true, relocate = true;
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 
 	      if (skip)
-		{
-		  memset (&outrel, 0, sizeof outrel);
-		  relocate = false;
-		}
+		memset (&outrel, 0, sizeof outrel);
 	      else if (h != NULL
 		       && h->dynindx != -1
 		       && (r_type == R_386_PC32
@@ -2027,11 +2027,7 @@ elf_i386_relocate_section (output_bfd, i
 			   || !info->symbolic
 			   || (h->elf_link_hash_flags
 			       & ELF_LINK_HASH_DEF_REGULAR) == 0))
-
-		{
-		  relocate = false;
-		  outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
-		}
+		outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
 	      else
 		{
 		  /* This symbol is local, or marked to become local.  */
--- bfd/elf32-arm.h.jj	Tue Feb 12 14:56:56 2002
+++ bfd/elf32-arm.h	Fri Feb 15 11:36:35 2002
@@ -1148,26 +1148,24 @@ elf32_arm_final_link_relocate (howto, in
 	    }
 
 	  skip = false;
+	  relocate = false;
 
 	  outrel.r_offset =
 	    _bfd_elf_section_offset (output_bfd, info, input_section,
 				     rel->r_offset);
 	  if (outrel.r_offset == (bfd_vma) -1)
 	    skip = true;
+	  else if (outrel.r_offset == (bfd_vma) -2)
+	    skip = true, relocate = true;
 	  outrel.r_offset += (input_section->output_section->vma
 			      + input_section->output_offset);
 
 	  if (skip)
-	    {
-	      memset (&outrel, 0, sizeof outrel);
-	      relocate = false;
-	    }
+	    memset (&outrel, 0, sizeof outrel);
 	  else if (r_type == R_ARM_PC24)
 	    {
 	      BFD_ASSERT (h != NULL && h->dynindx != -1);
-	      if ((input_section->flags & SEC_ALLOC) != 0)
-		relocate = false;
-	      else
+	      if ((input_section->flags & SEC_ALLOC) == 0)
 		relocate = true;
 	      outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_PC24);
 	    }
@@ -1184,9 +1182,7 @@ elf32_arm_final_link_relocate (howto, in
 	      else
 		{
 		  BFD_ASSERT (h->dynindx != -1);
-		  if ((input_section->flags & SEC_ALLOC) != 0)
-		    relocate = false;
-		  else
+		  if ((input_section->flags & SEC_ALLOC) == 0)
 		    relocate = true;
 		  outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_ABS32);
 		}
--- bfd/elf32-cris.c.jj	Tue Feb 12 14:56:56 2002
+++ bfd/elf32-cris.c	Fri Feb 15 11:38:20 2002
@@ -1296,20 +1296,20 @@ cris_elf_relocate_section (output_bfd, i
 		}
 
 	      skip = false;
+	      relocate = false;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = true, relocate = true;
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 
 	      if (skip)
-		{
-		  memset (&outrel, 0, sizeof outrel);
-		  relocate = false;
-		}
+		memset (&outrel, 0, sizeof outrel);
 	      /* h->dynindx may be -1 if the symbol was marked to
 		 become local.  */
 	      else if (h != NULL
@@ -1318,7 +1318,6 @@ cris_elf_relocate_section (output_bfd, i
 			       & ELF_LINK_HASH_DEF_REGULAR) == 0))
 		{
 		  BFD_ASSERT (h->dynindx != -1);
-		  relocate = false;
 		  outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
 		  outrel.r_addend = relocation + rel->r_addend;
 		}
@@ -1359,7 +1358,6 @@ cris_elf_relocate_section (output_bfd, i
 			  BFD_ASSERT (indx > 0);
 			}
 
-		      relocate = false;
 		      outrel.r_info = ELF32_R_INFO (indx, r_type);
 		      outrel.r_addend = relocation + rel->r_addend;
 		    }
--- bfd/elf32-hppa.c.jj	Tue Feb 12 14:56:56 2002
+++ bfd/elf32-hppa.c	Fri Feb 15 11:39:38 2002
@@ -3976,7 +3976,8 @@ elf32_hppa_relocate_section (output_bfd,
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
-	      skip = (outrel.r_offset == (bfd_vma) -1);
+	      skip = (outrel.r_offset == (bfd_vma) -1
+		      || outrel.r_offset == (bfd_vma) -2);
 	      outrel.r_offset += (input_section->output_offset
 				  + input_section->output_section->vma);
 
--- bfd/elf32-i370.c.jj	Mon Jan 28 14:42:17 2002
+++ bfd/elf32-i370.c	Fri Feb 15 11:42:40 2002
@@ -1436,7 +1436,7 @@ i370_elf_relocate_section (output_bfd, i
 	      && r_symndx != 0)
 	    {
 	      Elf_Internal_Rela outrel;
-	      boolean skip;
+	      int skip;
 
 #ifdef DEBUG
 	      fprintf (stderr,
@@ -1468,13 +1468,14 @@ i370_elf_relocate_section (output_bfd, i
 		  BFD_ASSERT (sreloc != NULL);
 		}
 
-	      skip = false;
+	      skip = 0;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
-	      if (outrel.r_offset == (bfd_vma) -1)
-		skip = true;
+	      if (outrel.r_offset == (bfd_vma) -1
+		  || outrel.r_offset == (bfd_vma) -2)
+		skip = (int) outrel.r_offset;
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 
@@ -1549,7 +1550,7 @@ i370_elf_relocate_section (output_bfd, i
 	      /* This reloc will be computed at runtime, so there's no
                  need to do anything now, unless this is a RELATIVE
                  reloc in an unallocated section.  */
-	      if (skip
+	      if (skip == -1
 		  || (input_section->flags & SEC_ALLOC) != 0
 		  || ELF32_R_TYPE (outrel.r_info) != R_I370_RELATIVE)
 		continue;
--- bfd/elf32-m68k.c.jj	Fri Feb 15 09:38:02 2002
+++ bfd/elf32-m68k.c	Fri Feb 15 11:45:25 2002
@@ -1654,20 +1654,20 @@ elf_m68k_relocate_section (output_bfd, i
 		}
 
 	      skip = false;
+	      relocate = false;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = true, relocate = true;
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 
 	      if (skip)
-		{
-		  memset (&outrel, 0, sizeof outrel);
-		  relocate = false;
-		}
+		memset (&outrel, 0, sizeof outrel);
 	      /* h->dynindx may be -1 if the symbol was marked to
                  become local.  */
 	      else if (h != NULL
@@ -1676,7 +1676,6 @@ elf_m68k_relocate_section (output_bfd, i
 			       & ELF_LINK_HASH_DEF_REGULAR) == 0))
 		{
 		  BFD_ASSERT (h->dynindx != -1);
-		  relocate = false;
 		  outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
 		  outrel.r_addend = relocation + rel->r_addend;
 		}
@@ -1717,7 +1716,6 @@ elf_m68k_relocate_section (output_bfd, i
 			  BFD_ASSERT (indx > 0);
 			}
 
-		      relocate = false;
 		      outrel.r_info = ELF32_R_INFO (indx, r_type);
 		      outrel.r_addend = relocation + rel->r_addend;
 		    }
--- bfd/elf32-ppc.c.jj	Sat Dec 22 00:48:25 2001
+++ bfd/elf32-ppc.c	Fri Feb 15 12:18:30 2002
@@ -3152,7 +3152,7 @@ ppc_elf_relocate_section (output_bfd, in
 	  if (info->shared && r_symndx != 0)
 	    {
 	      Elf_Internal_Rela outrel;
-	      boolean skip;
+	      int skip;
 
 #ifdef DEBUG
 	      fprintf (stderr, "ppc_elf_relocate_section need to create relocation for %s\n",
@@ -3183,13 +3183,14 @@ ppc_elf_relocate_section (output_bfd, in
 		  BFD_ASSERT (sreloc != NULL);
 		}
 
-	      skip = false;
+	      skip = 0;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
-	      if (outrel.r_offset == (bfd_vma) -1)
-		skip = true;
+	      if (outrel.r_offset == (bfd_vma) -1
+		  || outrel.r_offset == (bfd_vma) -2)
+		skip = (int) outrel.r_offset;
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 
@@ -3260,7 +3261,7 @@ ppc_elf_relocate_section (output_bfd, in
 	      /* This reloc will be computed at runtime, so there's no
                  need to do anything now, unless this is a RELATIVE
                  reloc in an unallocated section.  */
-	      if (skip
+	      if (skip != -1
 		  || (input_section->flags & SEC_ALLOC) != 0
 		  || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE)
 		continue;
--- bfd/elf32-s390.c.jj	Tue Feb 12 14:56:59 2002
+++ bfd/elf32-s390.c	Fri Feb 15 16:44:40 2002
@@ -1891,20 +1891,20 @@ elf_s390_relocate_section (output_bfd, i
 		 time.  */
 
               skip = false;
+              relocate = false;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = true, relocate = true;
               outrel.r_offset += (input_section->output_section->vma
                                   + input_section->output_offset);
 
               if (skip)
-                {
-                  memset (&outrel, 0, sizeof outrel);
-                  relocate = false;
-                }
+		memset (&outrel, 0, sizeof outrel);
               else if (h != NULL
 		       && h->dynindx != -1
 		       && (r_type == R_390_PC16
@@ -1915,7 +1915,6 @@ elf_s390_relocate_section (output_bfd, i
 			   || (h->elf_link_hash_flags
 			       & ELF_LINK_HASH_DEF_REGULAR) == 0))
                 {
-		  relocate = false;
                   outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
 		  outrel.r_addend = rel->r_addend;
                 }
--- bfd/elf32-sh.c.jj	Tue Feb 12 14:56:59 2002
+++ bfd/elf32-sh.c	Fri Feb 15 16:45:59 2002
@@ -4419,24 +4419,23 @@ sh_elf_relocate_section (output_bfd, inf
 		}
 
 	      skip = false;
+	      relocate = false;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = true, relocate = true;
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 
 	      if (skip)
-		{
-		  memset (&outrel, 0, sizeof outrel);
-		  relocate = false;
-		}
+		memset (&outrel, 0, sizeof outrel);
 	      else if (r_type == R_SH_REL32)
 		{
 		  BFD_ASSERT (h != NULL && h->dynindx != -1);
-		  relocate = false;
 		  outrel.r_info = ELF32_R_INFO (h->dynindx, R_SH_REL32);
 		  outrel.r_addend
 		    = bfd_get_32 (input_bfd, contents + rel->r_offset);
@@ -4459,7 +4458,6 @@ sh_elf_relocate_section (output_bfd, inf
 		  else
 		    {
 		      BFD_ASSERT (h->dynindx != -1);
-		      relocate = false;
 		      outrel.r_info = ELF32_R_INFO (h->dynindx, R_SH_DIR32);
 		      outrel.r_addend
 			= relocation + bfd_get_32 (input_bfd,
--- bfd/elf32-sparc.c.jj	Sat Dec 22 00:50:46 2001
+++ bfd/elf32-sparc.c	Fri Feb 15 16:55:19 2002
@@ -1438,7 +1438,7 @@ elf32_sparc_relocate_section (output_bfd
 	      && (input_section->flags & SEC_ALLOC))
 	    {
 	      Elf_Internal_Rela outrel;
-	      boolean skip;
+	      boolean skip, relocate = false;
 
 	      /* When generating a shared object, these relocations
                  are copied into the output file to be resolved at run
@@ -1471,6 +1471,8 @@ elf32_sparc_relocate_section (output_bfd
 					 rel->r_offset);
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = true, relocate = true;
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 
@@ -1571,7 +1573,8 @@ elf32_sparc_relocate_section (output_bfd
 
 	      /* This reloc will be computed at runtime, so there's no
                  need to do anything now.  */
-	      continue;
+	      if (! relocate)
+		continue;
 	    }
 	  break;
 
--- bfd/elf64-alpha.c.jj	Fri Feb 15 09:38:02 2002
+++ bfd/elf64-alpha.c	Fri Feb 15 16:59:32 2002
@@ -3677,7 +3677,7 @@ elf64_alpha_relocate_section (output_bfd
 	    outrel.r_offset =
 	      _bfd_elf_section_offset (output_bfd, info, input_section,
 				       rel->r_offset);
-	    if (outrel.r_offset != (bfd_vma) -1)
+	    if ((outrel.r_offset | 1) != (bfd_vma) -1)
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 	    else
--- bfd/elf64-ppc.c.jj	Tue Feb 12 14:56:59 2002
+++ bfd/elf64-ppc.c	Fri Feb 15 17:02:20 2002
@@ -3962,22 +3962,21 @@ ppc64_elf_relocate_section (output_bfd, 
 		 time.  */
 
 	      skip = false;
+	      relocate = false;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
-
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = true, relocate = true;
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 	      outrel.r_addend = addend;
 
 	      if (skip)
-		{
-		  relocate = false;
-		  memset (&outrel, 0, sizeof outrel);
-		}
+		memset (&outrel, 0, sizeof outrel);
 	      else if (h != NULL
 		       && h->dynindx != -1
 		       && !is_opd
@@ -3986,10 +3985,7 @@ ppc64_elf_relocate_section (output_bfd, 
 			   || !info->symbolic
 			   || (h->elf_link_hash_flags
 			       & ELF_LINK_HASH_DEF_REGULAR) == 0))
-		{
-		  relocate = false;
-		  outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
-		}
+		outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
 	      else
 		{
 		  /* This symbol is local, or marked to become local,
--- bfd/elf64-s390.c.jj	Tue Feb 12 14:56:59 2002
+++ bfd/elf64-s390.c	Fri Feb 15 17:03:10 2002
@@ -1890,21 +1890,21 @@ elf_s390_relocate_section (output_bfd, i
                  time.  */
 
               skip = false;
+              relocate = false;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rel->r_offset);
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = true, relocate = true;
 
               outrel.r_offset += (input_section->output_section->vma
                                   + input_section->output_offset);
 
               if (skip)
-                {
-                  memset (&outrel, 0, sizeof outrel);
-                  relocate = false;
-                }
+		memset (&outrel, 0, sizeof outrel);
               else if (h != NULL
 		       && h->dynindx != -1
 		       && (r_type == R_390_PC16
@@ -1917,7 +1917,6 @@ elf_s390_relocate_section (output_bfd, i
 			   || (h->elf_link_hash_flags
 			       & ELF_LINK_HASH_DEF_REGULAR) == 0))
                 {
-		  relocate = false;
                   outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
 		  outrel.r_addend = rel->r_addend;
                 }
--- bfd/elf64-sh64.c.jj	Mon Feb 11 07:17:43 2002
+++ bfd/elf64-sh64.c	Fri Feb 15 17:11:32 2002
@@ -1746,6 +1746,7 @@ sh_elf64_relocate_section (output_bfd, i
 		}
 
 	      skip = false;
+	      relocate = false;
 
 	      outrel.r_offset
 		= _bfd_elf_section_offset (output_bfd, info,
@@ -1753,19 +1754,17 @@ sh_elf64_relocate_section (output_bfd, i
 
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
+	      else if (outrel.r_offset == (bfd_vma) -1)
+		skip = true, relocate = true;
 	      
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 
 	      if (skip)
-		{
-		  memset (&outrel, 0, sizeof outrel);
-		  relocate = false;
-		}
+		memset (&outrel, 0, sizeof outrel);
 	      else if (r_type == R_SH_64_PCREL)
 		{
 		  BFD_ASSERT (h != NULL && h->dynindx != -1);
-		  relocate = false;
 		  outrel.r_info = ELF64_R_INFO (h->dynindx, R_SH_64_PCREL);
 		  outrel.r_addend = rel->r_addend;
 		}
@@ -1785,7 +1784,6 @@ sh_elf64_relocate_section (output_bfd, i
 		  else
 		    {
 		      BFD_ASSERT (h->dynindx != -1);
-		      relocate = false;
 		      outrel.r_info = ELF64_R_INFO (h->dynindx, R_SH_64);
 		      outrel.r_addend = relocation + rel->r_addend;
 		    }
--- bfd/elf64-sparc.c.jj	Tue Feb 12 14:57:04 2002
+++ bfd/elf64-sparc.c	Fri Feb 15 17:12:36 2002
@@ -2161,7 +2161,7 @@ do_dynreloc:
 	    case R_SPARC_UA16:
 	      {
 		Elf_Internal_Rela outrel;
-		boolean skip;
+		boolean skip, relocate;
 
 		if (sreloc == NULL)
 		  {
@@ -2184,12 +2184,15 @@ do_dynreloc:
 		  }
 
 		skip = false;
+		relocate = false;
 
 		outrel.r_offset =
 		  _bfd_elf_section_offset (output_bfd, info, input_section,
 					   rel->r_offset);
 		if (outrel.r_offset == (bfd_vma) -1)
 		  skip = true;
+		else if (outrel.r_offset == (bfd_vma) -2)
+		  skip = true, relocate = true;
 
 		outrel.r_offset += (input_section->output_section->vma
 				    + input_section->output_offset);
@@ -2301,7 +2304,8 @@ do_dynreloc:
 
 		/* This reloc will be computed at runtime, so there's no
 		   need to do anything now.  */
-		continue;
+		if (! relocate)
+		  continue;
 	      }
 	    break;
 	    }
--- bfd/elf64-x86-64.c.jj	Mon Dec 17 12:29:48 2001
+++ bfd/elf64-x86-64.c	Fri Feb 15 17:13:21 2002
@@ -1466,21 +1466,21 @@ elf64_x86_64_relocate_section (output_bf
 		}
 
 	      skip = false;
+	      relocate = false;
 
 	      outrel.r_offset =
 		_bfd_elf_section_offset (output_bfd, info, input_section,
 					 rela->r_offset);
 	      if (outrel.r_offset == (bfd_vma) -1)
 		skip = true;
+	      else if (outrel.r_offset == (bfd_vma) -1)
+		skip = true, relocate = true;
 
 	      outrel.r_offset += (input_section->output_section->vma
 				  + input_section->output_offset);
 
 	      if (skip)
-		{
-		  memset (&outrel, 0, sizeof outrel);
-		  relocate = false;
-		}
+		memset (&outrel, 0, sizeof outrel);
 	      /* h->dynindx may be -1 if this symbol was marked to
 		 become local.  */
 	      else if (h != NULL
@@ -1489,7 +1489,6 @@ elf64_x86_64_relocate_section (output_bf
 			       & ELF_LINK_HASH_DEF_REGULAR) == 0))
 		{
 		  BFD_ASSERT (h->dynindx != -1);
-		  relocate = false;
 		  outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
 		  outrel.r_addend = relocation + rela->r_addend;
 		}
@@ -1530,7 +1529,6 @@ elf64_x86_64_relocate_section (output_bf
 			  BFD_ASSERT (sindx > 0);
 			}
 
-		      relocate = false;
 		      outrel.r_info = ELF64_R_INFO (sindx, r_type);
 		      outrel.r_addend = relocation + rela->r_addend;
 		    }
--- bfd/elfxx-ia64.c.jj	Mon Jan 28 14:42:26 2002
+++ bfd/elfxx-ia64.c	Fri Feb 15 17:14:09 2002
@@ -3107,7 +3107,7 @@ elfNN_ia64_install_dyn_reloc (abfd, info
   outrel.r_info = ELFNN_R_INFO (dynindx, type);
   outrel.r_addend = addend;
   outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset);
-  if (outrel.r_offset == (bfd_vma) -1)
+  if ((outrel.r_offset | 1) == (bfd_vma) -1)
     {
       /* Run for the hills.  We shouldn't be outputting a relocation
 	 for this.  So do what everyone else does and output a no-op.  */

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]