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]

Eliminate redundant GOT entry initialization code


I find there are some redundant code in elf32-sparc.c. First
elf32_sparc_relocate_section will initialize the GOT entry for the
symbols in some case, then elf32_sparc_finish_dynamic_symbol will create
R_SPARC_RELATIVE relocations for them. The following small patch will
remove the redundant initialization. It is against CVS head. Is it OK?

Jie

*** elf32-sparc.c	Tue Apr  6 10:35:27 2004
--- elf32-sparc.c.new	Tue Apr  6 10:30:38 2004
***************
*** 2228,2252 ****
  	      BFD_ASSERT (off != (bfd_vma) -1);
  	      dyn = elf_hash_table (info)->dynamic_sections_created;
  
! 	      if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
! 		  || (info->shared
! 		      && (info->symbolic
! 			  || h->dynindx == -1
! 			  || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
! 		      && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
  		{
! 		  /* This is actually a static link, or it is a
! 		     -Bsymbolic link and the symbol is defined
! 		     locally, or the symbol was forced to be local
! 		     because of a version file.  We must initialize
! 		     this entry in the global offset table.  Since the
! 		     offset must always be a multiple of 4, we use the
! 		     least significant bit to record whether we have
! 		     initialized it already.
! 
! 		     When doing a dynamic link, we create a .rela.got
! 		     relocation entry to initialize the value.  This
! 		     is done in the finish_dynamic_symbol routine.  */
  		  if ((off & 1) != 0)
  		    off &= ~1;
  		  else
--- 2228,2244 ----
  	      BFD_ASSERT (off != (bfd_vma) -1);
  	      dyn = elf_hash_table (info)->dynamic_sections_created;
  
! 	      if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h))
  		{
! 		  /* If finish_dynamic_symbol won't be called, we must
! 		     initialize this entry in the global offset table.
! 		     Since the offset must always be a multiple of 4, 
! 		     we use the least significant bit to record whether
! 		     we have initialized it already.
! 
! 		     Otherwise, we create a .rela.got relocation entry
! 		     to initialize the value.  This is done in the
! 		     finish_dynamic_symbol routine.  */
  		  if ((off & 1) != 0)
  		    off &= ~1;
  		  else


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