This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Get rid of weak symbols in static objects
- From: Momchil Velikov <velco at fadata dot bg>
- To: binutils at sources dot redhat dot com
- Date: 26 Nov 2003 12:22:34 +0200
- Subject: 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:
{