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]

Get rid of weak symbols in static objects


2003-11-26  Momchil Velikov  <velco@fadata.bg>

	* elflink.h (elf_link_output_extsym): Do not output weak symbols
	in statically linked objects.

--- elflink.h.~1.247.~	2003-11-25 11:28:37.000000000 +0200
+++ elflink.h	2003-11-26 11:48:35.000000000 +0200
@@ -4436,7 +4436,12 @@ elf_link_output_extsym (struct elf_link_
     sym.st_info = ELF_ST_INFO (STB_LOCAL, h->type);
   else if (h->root.type == bfd_link_hash_undefweak
 	   || h->root.type == bfd_link_hash_defweak)
-    sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
+    {
+      if (finfo->info->static_link)
+	sym.st_info = ELF_ST_INFO (STB_GLOBAL, h->type);
+      else
+	sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
+    }
   else
     sym.st_info = ELF_ST_INFO (STB_GLOBAL, h->type);
 
@@ -4449,11 +4454,23 @@ elf_link_output_extsym (struct elf_link_
       return FALSE;
 
     case bfd_link_hash_undefined:
-    case bfd_link_hash_undefweak:
       input_sec = bfd_und_section_ptr;
       sym.st_shndx = SHN_UNDEF;
       break;
 
+    case bfd_link_hash_undefweak:
+      if (finfo->info->static_link)
+	{
+	  input_sec = bfd_abs_section_ptr;
+	  sym.st_shndx = SHN_ABS;
+	}
+      else
+	{
+	  input_sec = bfd_und_section_ptr;
+	  sym.st_shndx = SHN_UNDEF;
+	}
+      break;
+
     case bfd_link_hash_defined:
     case bfd_link_hash_defweak:
       {

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