This is the mail archive of the binutils@sourceware.cygnus.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]

Fix to common symbol detection


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 ----
      }
  }
  
+ /* 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;
  	}
      }

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