public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Fix to common symbol detection
@ 1999-12-14 15:08 Nick Clifton
  1999-12-14 15:19 ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 1999-12-14 15:08 UTC (permalink / raw)
  To: binutils

Hi Guys,

  Here is a further patch to the new code to cope with linking in
  defintions of commons in archives.  This patch fixes the code to
  determine if a symbol is a common definition and adds a place for
  a backend specific funciton to process special sections.

  Is this patch OK to apply ?

Cheers
	Nick

1999-12-14  Nick Clifton  <nickc@cygnus.com>

	* elflink.h (is_global_symbol_definition): New Function: Return
	true iff the symbol is being given a global definition in this
	bfd. 
	(elf_link_is_defined_archive_symbol): Do not bother processing
	symbols for an archive element that has already been included
	in the link.
	Use is_global_symbol_definition().
	
Index: elflink.h
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/elflink.h,v
retrieving revision 1.142
diff -p -r1.142 elflink.h
*** elflink.h	1999/12/13 17:58:24	1.142
--- elflink.h	1999/12/14 22:58:00
*************** elf_bfd_link_add_symbols (abfd, info)
*** 80,85 ****
--- 80,120 ----
      }
  }
  \f
+ /* Return true iff this is a non-common definition of a symbol.  */
+ static boolean
+ is_global_symbol_definition (abfd, sym)
+      bfd * abfd;
+      Elf_Internal_Sym * sym;
+ {
+   /* Local symbols do not count.  */
+   if (ELF_ST_BIND (sym->st_info) != STB_GLOBAL)
+     return false;
+ 
+   /* If the section is undefined, then so is the symbol.  */
+   if (sym->st_shndx == SHN_UNDEF)
+     return false;
+   
+   /* If the symbol is defined in the common section, then
+      it is a common definition and so does not count.  */
+   if (sym->st_shndx == SHN_COMMON)
+     return false;
+ 
+   /* If the symbol is in a target specific section then we
+      must rely upon the backend to tell us what it is.  */
+   if (sym->st_shndx >= SHN_LORESERVE && sym->st_shndx < SHN_ABS)
+     /* FIXME - this function is not coded yet:
+        
+        return _bfd_is_global_symbol_definition (abfd, sym);
+        
+        Instead for now assume that the definition is not global,
+        Even if this is wrong, at least the linker will behave
+        in the same way that it used to do.  */
+     return false;
+       
+   return true;
+ }
+ 
+ 
  /* Search the symbol table of the archive element of the archive ABFD
     whoes archove map contains a mention of SYMDEF, and determine if
     the symbol is defined in this element.  */
*************** elf_link_is_defined_archive_symbol (abfd
*** 104,109 ****
--- 139,151 ----
    if (! bfd_check_format (abfd, bfd_object))
      return false;
  
+   /* If we have already included the element containing this symbol in the
+      link then we do not need to include it again.  Just claim that any symbol
+      it contains is not a definition, so that our caller will not decide to
+      (re)include this element.  */
+   if (abfd->archive_pass)
+     return false;
+   
    /* Select the appropriate symbol table.  */
    if ((abfd->flags & DYNAMIC) == 0 || elf_dynsymtab (abfd) == 0)
      hdr = &elf_tdata (abfd)->symtab_hdr;
*************** elf_link_is_defined_archive_symbol (abfd
*** 159,169 ****
  
        if (strcmp (name, symdef->name) == 0)
  	{
! 	  result =
! 	    (ELF_ST_BIND (sym.st_info) == STB_GLOBAL)
! 	    && (sym.st_shndx != SHN_UNDEF)
! 	    && (sym.st_shndx != SHN_COMMON)
! 	    ;
  	  break;
  	}
      }
--- 201,207 ----
  
        if (strcmp (name, symdef->name) == 0)
  	{
! 	  result = is_global_symbol_definition (abfd, & sym);
  	  break;
  	}
      }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fix to common symbol detection
  1999-12-14 15:08 Fix to common symbol detection Nick Clifton
@ 1999-12-14 15:19 ` Ian Lance Taylor
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 1999-12-14 15:19 UTC (permalink / raw)
  To: nickc; +Cc: binutils

   Date: Tue, 14 Dec 1999 15:08:57 -0800
   From: Nick Clifton <nickc@cygnus.com>

     Here is a further patch to the new code to cope with linking in
     defintions of commons in archives.  This patch fixes the code to
     determine if a symbol is a common definition and adds a place for
     a backend specific funciton to process special sections.

Looks basically OK.

   +   /* Local symbols do not count.  */
   +   if (ELF_ST_BIND (sym->st_info) != STB_GLOBAL)
   +     return false;

There are processor specific STB_* values too.  In principle they too
should go to the hypothetical backend function.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fix to common symbol detection
@ 1999-12-15 10:26 Nick Clifton
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Clifton @ 1999-12-15 10:26 UTC (permalink / raw)
  To: hjl; +Cc: ian, binutils

Hi H.J.

: Do we support ST_VISIBILITY in the new elf ABI?

Sorry - I don't know.

: Ulrich puts the new ABI
: support in glibc 2.2. It will be nice to have it in binutils. If you want
: to work on the new ELF ABI draft, which I don't expect there will
: be any significant changes in its final version, please drop me a line.
: I will send it to you.

Please do.

Cheers
	Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fix to common symbol detection
  1999-12-14 15:34 Nick Clifton
@ 1999-12-15  7:45 ` H.J. Lu
  0 siblings, 0 replies; 5+ messages in thread
From: H.J. Lu @ 1999-12-15  7:45 UTC (permalink / raw)
  To: Nick Clifton; +Cc: ian, binutils

> 
> Hi Ian,
> 
> :    +   /* Local symbols do not count.  */
> :    +   if (ELF_ST_BIND (sym->st_info) != STB_GLOBAL)
> :    +     return false;
> : 
> : There are processor specific STB_* values too.  In principle they too
> : should go to the hypothetical backend function.
> 
> Good point - I checked in the patch with the following change:
> 
>   /* Local symbols do not count, but target specific ones might.  */
>   if (ELF_ST_BIND (sym->st_info) != STB_GLOBAL
>       && ELF_ST_BIND (sym->st_info) < STB_LOOS)
>     return false;
> 

Do we support ST_VISIBILITY in the new elf ABI? Ulrich puts the new ABI
support in glibc 2.2. It will be nice to have it in binutils. If you want
to work on the new ELF ABI draft, which I don't expect there will
be any significant changes in its final version, please drop me a line.
I will send it to you.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fix to common symbol detection
@ 1999-12-14 15:34 Nick Clifton
  1999-12-15  7:45 ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 1999-12-14 15:34 UTC (permalink / raw)
  To: ian; +Cc: binutils

Hi Ian,

:    +   /* Local symbols do not count.  */
:    +   if (ELF_ST_BIND (sym->st_info) != STB_GLOBAL)
:    +     return false;
: 
: There are processor specific STB_* values too.  In principle they too
: should go to the hypothetical backend function.

Good point - I checked in the patch with the following change:

  /* Local symbols do not count, but target specific ones might.  */
  if (ELF_ST_BIND (sym->st_info) != STB_GLOBAL
      && ELF_ST_BIND (sym->st_info) < STB_LOOS)
    return false;

Cheers
	Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-12-15 10:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-14 15:08 Fix to common symbol detection Nick Clifton
1999-12-14 15:19 ` Ian Lance Taylor
1999-12-14 15:34 Nick Clifton
1999-12-15  7:45 ` H.J. Lu
1999-12-15 10:26 Nick Clifton

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).