weak symbols and PLT on sparc

Andreas Jaeger aj@suse.de
Thu Feb 22 05:50:00 GMT 2001


Phil, Jakub,

IMO this fix is critical and should go on the release branch.  Shall I
commit it to the release branch myself?

Andreas

Jakub Jelinek <jakub@redhat.com> writes:

> Hi!
> 
> I've commited following port of Geoff Keating's PPC patch which is needed on
> sparc* as well.
> 
> 2001-02-19  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* elf32-sparc.c (elf32_sparc_finish_dynamic_symbol): Don't make PLT
> 	entries that could serve as a definition for a weak symbol.
> 	* elf64-sparc.c (sparc64_elf_finish_dynamic_symbol): Likewise.
> 
> --- bfd/elf32-sparc.c.jj	Fri Feb  9 18:40:44 2001
> +++ bfd/elf32-sparc.c	Tue Feb 20 00:21:42 2001
> @@ -1759,6 +1759,13 @@ elf32_sparc_finish_dynamic_symbol (outpu
>  	  /* Mark the symbol as undefined, rather than as defined in
>  	     the .plt section.  Leave the value alone.  */
>  	  sym->st_shndx = SHN_UNDEF;
> +	  /* If the symbol is weak, we do need to clear the value.
> +	     Otherwise, the PLT entry would provide a definition for
> +	     the symbol even if the symbol wasn't defined anywhere,
> +	     and so the symbol would never be NULL.  */
> +	  if ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK)
> +	      == 0)
> +	    sym->st_value = 0;
>  	}
>      }
>  
> --- bfd/elf64-sparc.c.jj	Tue Feb 20 00:18:20 2001
> +++ bfd/elf64-sparc.c	Tue Feb 20 00:27:54 2001
> @@ -2709,6 +2709,13 @@ sparc64_elf_finish_dynamic_symbol (outpu
>  	  /* Mark the symbol as undefined, rather than as defined in
>  	     the .plt section.  Leave the value alone.  */
>  	  sym->st_shndx = SHN_UNDEF;
> +	  /* If the symbol is weak, we do need to clear the value.
> +	     Otherwise, the PLT entry would provide a definition for
> +	     the symbol even if the symbol wasn't defined anywhere,
> +	     and so the symbol would never be NULL.  */
> +	  if ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK)
> +	      == 0)
> +	    sym->st_value = 0;
>  	}
>      }
>  
> 	Jakub
> 

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj



More information about the Binutils mailing list