public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Mark P. Mitchell" <mark@codesourcery.com>
To: binutils@sourceware.cygnus.com
Subject: PATCH for elf/mips
Date: Thu, 15 Jul 1999 16:59:00 -0000	[thread overview]
Message-ID: <199907152359.RAA1243056@n02.acl.lanl.gov> (raw)

This patch (checked in) fixes a buglet in Richard's recent
section-symbol changes, and also fixes a couple of minor issues
revealed by the test-suite.  Only one failure remains; it will be
fixed next.

--

Thu Jul 15 17:55:31 1999  Mark P. Mitchell  <mark@codesourcery.com>

	* elf32-mips.c (_bfd_mips_elf_modify_segment_map): Don't require
	a PT_PHDR program headers.
	(_bfd_mips_elf_final_link): Don't assume there are going to be
	section symbols when we're not building a shared object.
	(_bfd_mips_elf_check_relocs): Make sure we have a GOT when
	we need one.

Index: elf32-mips.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elf32-mips.c,v
retrieving revision 1.25
diff -c -p -r1.25 elf32-mips.c
*** elf32-mips.c	1999/07/14 14:23:13	1.25
--- elf32-mips.c	1999/07/15 23:54:57
*************** _bfd_mips_elf_modify_segment_map (abfd)
*** 3242,3264 ****
  	{
  	  struct elf_segment_map *options_segment;
  
! 	  for (m = elf_tdata (abfd)->segment_map; m; m = m->next)
! 	    if (m->p_type == PT_PHDR)
  	      break;
  
- 	  /* There should always be a program header table.  */
- 	  if (m == NULL)
- 	    return false;
- 
  	  options_segment = bfd_zalloc (abfd, 
  					sizeof (struct elf_segment_map));
! 	  options_segment->next = m->next;
  	  options_segment->p_type = PT_MIPS_OPTIONS;
  	  options_segment->p_flags = PF_R;
  	  options_segment->p_flags_valid = true;
  	  options_segment->count = 1;
  	  options_segment->sections[0] = s;
! 	  m->next = options_segment;
  	}
      }
    else
--- 3242,3266 ----
  	{
  	  struct elf_segment_map *options_segment;
  
! 	  /* Usually, there's a program header table.  But, sometimes
! 	     there's not (like when running the `ld' testsuite).  So,
! 	     if there's no program header table, we just put the
! 	     options segement at the end.  */
! 	  for (pm = &elf_tdata (abfd)->segment_map; 
! 	       *pm != NULL;
! 	       pm = &(*pm)->next)
! 	    if ((*pm)->p_type == PT_PHDR)
  	      break;
  
  	  options_segment = bfd_zalloc (abfd, 
  					sizeof (struct elf_segment_map));
! 	  options_segment->next = *pm;
  	  options_segment->p_type = PT_MIPS_OPTIONS;
  	  options_segment->p_flags = PF_R;
  	  options_segment->p_flags_valid = true;
  	  options_segment->count = 1;
  	  options_segment->sections[0] = s;
! 	  *pm = options_segment;
  	}
      }
    else
*************** _bfd_mips_elf_final_link (abfd, info)
*** 4323,4336 ****
       generic size_dynamic_sections renumbered them out from under us.
       Rather than trying somehow to prevent the renumbering, just do
       the sort again.  */
- 
    if (elf_hash_table (info)->dynobj)
      {
        bfd *dynobj;
        asection *got;
        struct mips_got_info *g;
  
!       if (!mips_elf_sort_hash_table (info, bfd_count_sections (abfd) + 1))
          return false;
  
        /* Make sure we didn't grow the global .got region.  */
--- 4325,4345 ----
       generic size_dynamic_sections renumbered them out from under us.
       Rather than trying somehow to prevent the renumbering, just do
       the sort again.  */
    if (elf_hash_table (info)->dynobj)
      {
        bfd *dynobj;
        asection *got;
        struct mips_got_info *g;
  
!       /* When we resort, we must tell mips_elf_sort_hash_table what
! 	 the lowest index it may use is.  That's the number of section
! 	 symbols we're going to add.  The generic ELF linker only
! 	 adds these symbols when building a shared object.  Note that
! 	 we count the sections after (possibly) removing the .options
! 	 section above.  */
!       if (!mips_elf_sort_hash_table (info, (info->shared 
! 					    ? bfd_count_sections (abfd) + 1
! 					    : 1)))
          return false;
  
        /* Make sure we didn't grow the global .got region.  */
*************** mips_elf_next_lo16_addend (relocation, r
*** 5528,5534 ****
       immediately following.  However, for the IRIX6 ABI, the next
       relocation may be a composed relocation consisting of several
       relocations for the same address.  In that case, the R_MIPS_LO16
!      relo!scation may occur as one of these.  We permit a similar
       extension in general, as that is useful for GCC.  */
    while (relocation < relend)
      {
--- 5537,5543 ----
       immediately following.  However, for the IRIX6 ABI, the next
       relocation may be a composed relocation consisting of several
       relocations for the same address.  In that case, the R_MIPS_LO16
!      relocation may occur as one of these.  We permit a similar
       extension in general, as that is useful for GCC.  */
    while (relocation < relend)
      {
*************** _bfd_mips_elf_check_relocs (abfd, info, 
*** 7056,7061 ****
--- 7065,7073 ----
  	    case R_MIPS_CALL_LO16:
  	    case R_MIPS_GOT_HI16:
  	    case R_MIPS_GOT_LO16:
+ 	    case R_MIPS_GOT_PAGE:
+ 	    case R_MIPS_GOT_OFST:
+ 	    case R_MIPS_GOT_DISP:
  	      if (dynobj == NULL)
  		elf_hash_table (info)->dynobj = dynobj = abfd;
  	      if (! mips_elf_create_got_section (dynobj, info))

                 reply	other threads:[~1999-07-15 16:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199907152359.RAA1243056@n02.acl.lanl.gov \
    --to=mark@codesourcery.com \
    --cc=binutils@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).