public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Mitchell <mark@codesourcery.com>
To: binutils@sourceware.cygnus.com
Subject: PATCH for smaller GOTs on MIPS
Date: Thu, 26 Aug 1999 17:10:00 -0000	[thread overview]
Message-ID: <19990826171544P.mitchell@codesourcery.com> (raw)

Ralf noticed that the new binutils was using more GOT space.  This
patch (checked in) fixes the thinko that caused that.  With this
patch, Ralf reports markedly smaller GOTs that with binutils 2.9.1,
presumably because of the fact that we're now sorting the symbol
table, which allows us to avoid GOT entries for many symbols.

Ralf, thanks again for your testing, feedback, etc.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-08-26  Mark Mitchell  <mark@codesourcery.com>

	* elf32-mips.c (_bfd_mips_elf_check_relocs): Don't allocate local
	GOT entries for GOT16 relocations; they're not required.

Index: elf32-mips.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elf32-mips.c,v
retrieving revision 1.49
diff -c -p -r1.49 elf32-mips.c
*** elf32-mips.c	1999/08/15 22:56:20	1.49
--- elf32-mips.c	1999/08/27 00:04:07
*************** _bfd_mips_elf_check_relocs (abfd, info, 
*** 7456,7470 ****
  
        if (!h && (r_type == R_MIPS_CALL_LO16
  		 || r_type == R_MIPS_GOT_LO16
! 		 || r_type == R_MIPS_GOT_DISP
! 		 || r_type == R_MIPS_GOT16))
  	{
  	  /* We may need a local GOT entry for this relocation.  We
  	     don't count R_MIPS_GOT_PAGE because we can estimate the
  	     maximum number of pages needed by looking at the size of
! 	     the segment.  We don't count R_MIPS_GOT_HI16, or
! 	     R_MIPS_CALL_HI16 because these are always followed by an
! 	     R_MIPS_GOT_LO16 or R_MIPS_CALL_LO16.
  
  	     This estimation is very conservative since we can merge
  	     duplicate entries in the GOT.  In order to be less
--- 7456,7470 ----
  
        if (!h && (r_type == R_MIPS_CALL_LO16
  		 || r_type == R_MIPS_GOT_LO16
! 		 || r_type == R_MIPS_GOT_DISP))
  	{
  	  /* We may need a local GOT entry for this relocation.  We
  	     don't count R_MIPS_GOT_PAGE because we can estimate the
  	     maximum number of pages needed by looking at the size of
! 	     the segment.  Similar comments apply to R_MIPS_GOT16.  We
! 	     don't count R_MIPS_GOT_HI16, or R_MIPS_CALL_HI16 because
! 	     these are always followed by an R_MIPS_GOT_LO16 or
! 	     R_MIPS_CALL_LO16.
  
  	     This estimation is very conservative since we can merge
  	     duplicate entries in the GOT.  In order to be less
*************** _bfd_mips_elf_size_dynamic_sections (out
*** 8003,8010 ****
   	  loadable_size += MIPS_FUNCTION_STUB_SIZE;
  
   	  /* Assume there are two loadable segments consisting of
!  	     contiguous sections.  Is 5 enough? */
   	  local_gotno = (loadable_size >> 16) + 5;
   	  g->local_gotno += local_gotno;
   	  s->_raw_size += local_gotno * MIPS_ELF_GOT_SIZE (dynobj);
  
--- 8003,8016 ----
   	  loadable_size += MIPS_FUNCTION_STUB_SIZE;
  
   	  /* Assume there are two loadable segments consisting of
!  	     contiguous sections.  Is 5 enough?  */
   	  local_gotno = (loadable_size >> 16) + 5;
+ 	  if (IRIX_COMPAT (output_bfd) == ict_irix6)
+ 	    /* It's possible we will need GOT_PAGE entries as well as
+ 	       GOT16 entries.  Often, these will be able to share GOT
+ 	       entries, but not always.  */
+ 	    local_gotno *= 2;
+ 
   	  g->local_gotno += local_gotno;
   	  s->_raw_size += local_gotno * MIPS_ELF_GOT_SIZE (dynobj);
  

                 reply	other threads:[~1999-08-26 17:10 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=19990826171544P.mitchell@codesourcery.com \
    --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).