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]

Re: usr/bin/ld: internal error, aborting at ../../bfd/elf32-hppa.c line 3850 in elf32_hppa_relocate_section


On Sun, Nov 18, 2001 at 02:39:49AM +0000, James Troup wrote:
> aborting at ../../bfd/elf32-hppa.c line 3850 in elf32_hppa_relocate_section

Ouch.  We were dropping the .plt entries for plabel relocations to static
functions.

bfd/ChangeLog
	* elf32-hppa.c (PLABEL_PLT_ENTRY_SIZE): Delete.
	(allocate_PIC_calls): Rename to allocate_plt_static.
	(allocate_dynrelocs): Move most of code handling .plt entries to..
	(allocate_plt_static): ..here.  Don't drop plabel entries.

-- 
Alan Modra

Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.59
diff -c -r1.59 elf32-hppa.c
*** elf32-hppa.c	2001/11/10 00:23:35	1.59
--- elf32-hppa.c	2001/11/19 01:13:41
***************
*** 114,120 ****
     :		be,n 0(%sr0,%rp)		; inter-space return  */
  
  #define PLT_ENTRY_SIZE 8
- #define PLABEL_PLT_ENTRY_SIZE PLT_ENTRY_SIZE
  #define GOT_ENTRY_SIZE 4
  #define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1"
  
--- 114,119 ----
***************
*** 344,350 ****
  static boolean mark_PIC_calls
    PARAMS ((struct elf_link_hash_entry *, PTR));
  
! static boolean allocate_PIC_calls
    PARAMS ((struct elf_link_hash_entry *, PTR));
  
  static boolean allocate_dynrelocs
--- 343,349 ----
  static boolean mark_PIC_calls
    PARAMS ((struct elf_link_hash_entry *, PTR));
  
! static boolean allocate_plt_static
    PARAMS ((struct elf_link_hash_entry *, PTR));
  
  static boolean allocate_dynrelocs
***************
*** 2008,2017 ****
    return true;
  }
  
! /* Allocate space in the .plt for pic_call entries.  */
  
  static boolean
! allocate_PIC_calls (h, inf)
       struct elf_link_hash_entry *h;
       PTR inf;
  {
--- 2007,2017 ----
    return true;
  }
  
! /* Allocate space in the .plt for entries that won't have relocations.
!    ie. pic_call and plabel entries.  */
  
  static boolean
! allocate_plt_static (h, inf)
       struct elf_link_hash_entry *h;
       PTR inf;
  {
***************
*** 2027,2044 ****
    htab = hppa_link_hash_table (info);
    if (((struct elf32_hppa_link_hash_entry *) h)->pic_call)
      {
!       /* Make an entry in the .plt section.  */
        s = htab->splt;
        h->plt.offset = s->_raw_size;
!       if (PLABEL_PLT_ENTRY_SIZE != PLT_ENTRY_SIZE
! 	  && ((struct elf32_hppa_link_hash_entry *) h)->plabel
! 	  && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
  	{
! 	  /* Add some extra space for the dynamic linker to use.  */
! 	  s->_raw_size += PLABEL_PLT_ENTRY_SIZE;
  	}
        else
! 	s->_raw_size += PLT_ENTRY_SIZE;
      }
  
    return true;
--- 2027,2074 ----
    htab = hppa_link_hash_table (info);
    if (((struct elf32_hppa_link_hash_entry *) h)->pic_call)
      {
!       /* Make an entry in the .plt section for non-pic code that is
! 	 calling pic code.  */
        s = htab->splt;
        h->plt.offset = s->_raw_size;
!       s->_raw_size += PLT_ENTRY_SIZE;
!     }
!   else if (htab->elf.dynamic_sections_created
! 	   && h->plt.refcount > 0)
!     {
!       /* Make sure this symbol is output as a dynamic symbol.
! 	 Undefined weak syms won't yet be marked as dynamic.  */
!       if (h->dynindx == -1
! 	  && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0
! 	  && h->type != STT_PARISC_MILLI)
  	{
! 	  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
! 	    return false;
  	}
+ 
+       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
+ 	{
+ 	  /* Allocate these later.  */
+ 	}
+       else if (((struct elf32_hppa_link_hash_entry *) h)->plabel)
+ 	{
+ 	  /* Make an entry in the .plt section for plabel references
+ 	     that won't have a .plt entry for other reasons.  */
+ 	  s = htab->splt;
+ 	  h->plt.offset = s->_raw_size;
+ 	  s->_raw_size += PLT_ENTRY_SIZE;
+ 	}
        else
! 	{
! 	  /* No .plt entry needed.  */
! 	  h->plt.offset = (bfd_vma) -1;
! 	  h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
! 	}
!     }
!   else
!     {
!       h->plt.offset = (bfd_vma) -1;
!       h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
      }
  
    return true;
***************
*** 2064,2117 ****
  
    info = (struct bfd_link_info *) inf;
    htab = hppa_link_hash_table (info);
!   if ((htab->elf.dynamic_sections_created
!        && h->plt.refcount > 0)
!       || ((struct elf32_hppa_link_hash_entry *) h)->pic_call)
      {
!       /* Make sure this symbol is output as a dynamic symbol.
! 	 Undefined weak syms won't yet be marked as dynamic.  */
!       if (h->dynindx == -1
! 	  && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0
! 	  && h->type != STT_PARISC_MILLI
! 	  && !((struct elf32_hppa_link_hash_entry *) h)->pic_call)
! 	{
! 	  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
! 	    return false;
! 	}
! 
!       if (((struct elf32_hppa_link_hash_entry *) h)->pic_call)
! 	{
! 	  /* Already handled by allocate_PIC_calls.  */
! 	}
!       else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
! 	{
! 	  /* Make an entry in the .plt section.  */
! 	  s = htab->splt;
! 	  h->plt.offset = s->_raw_size;
! 	  if (PLABEL_PLT_ENTRY_SIZE != PLT_ENTRY_SIZE
! 	      && ((struct elf32_hppa_link_hash_entry *) h)->plabel
! 	      && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
! 	    {
! 	      /* Add some extra space for the dynamic linker to use.  */
! 	      s->_raw_size += PLABEL_PLT_ENTRY_SIZE;
! 	    }
! 	  else
! 	    s->_raw_size += PLT_ENTRY_SIZE;
  
! 	  /* We also need to make an entry in the .rela.plt section.  */
! 	  htab->srelplt->_raw_size += sizeof (Elf32_External_Rela);
! 	  htab->need_plt_stub = 1;
! 	}
!       else
! 	{
! 	  h->plt.offset = (bfd_vma) -1;
! 	  h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
! 	}
!     }
!   else
!     {
!       h->plt.offset = (bfd_vma) -1;
!       h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
      }
  
    if (h->got.refcount > 0)
--- 2094,2112 ----
  
    info = (struct bfd_link_info *) inf;
    htab = hppa_link_hash_table (info);
!   if (htab->elf.dynamic_sections_created
!       && h->plt.offset != (bfd_vma) -1
!       && !((struct elf32_hppa_link_hash_entry *) h)->pic_call
!       && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
      {
!       /* Make an entry in the .plt section.  */
!       s = htab->splt;
!       h->plt.offset = s->_raw_size;
!       s->_raw_size += PLT_ENTRY_SIZE;
  
!       /* We also need to make an entry in the .rela.plt section.  */
!       htab->srelplt->_raw_size += sizeof (Elf32_External_Rela);
!       htab->need_plt_stub = 1;
      }
  
    if (h->got.refcount > 0)
***************
*** 2400,2407 ****
  	}
      }
  
!   if (! info->shared)
!     elf_link_hash_traverse (&htab->elf, allocate_PIC_calls, (PTR) info);
  
    /* Allocate global sym .plt and .got entries, and space for global
       sym dynamic relocs.  */
--- 2395,2404 ----
  	}
      }
  
!   /* Do all the .plt entries without relocs first.  The dynamic linker
!      uses the last .plt reloc to find the end of the .plt (and hence
!      the start of the .got) for lazy linking.  */
!   elf_link_hash_traverse (&htab->elf, allocate_plt_static, (PTR) info);
  
    /* Allocate global sym .plt and .got entries, and space for global
       sym dynamic relocs.  */


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