This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Don't put .debug_* symbols into .dynsym
- To: binutils at sources dot redhat dot com
- Subject: [PATCH] Don't put .debug_* symbols into .dynsym
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Tue, 6 Nov 2001 19:37:48 +0100
- Cc: dan at cgsoftware dot com
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
Hi!
IMHO it makes no sense to put symbols against debugging section into
.dynsym.
This happens e.g. with -feliminate-dwarf2-dups, where for libqt.so.2
symbols against .gnu.linkonce.wi.* -> .debug_info sections increase number
of dynamic symbols from 13791 to 60435.
BTW: I wonder whether those symbols couldn't be killed from .symtab during
final link too, what do you think?
g++ 3.1 -O2 -gdwarf-2 -feliminate-dwarf2-dups + .debug_str patch built
libqt.so.2's size went down by this patch from 18.1MB to 15.8MB (and
removing the symbols from .symtab also would get this to 13.5MB), which
is nicer than 18.2MB for the same library built with -O2 -g (ie. stabs).
2001-11-06 Jakub Jelinek <jakub@redhat.com>
* elflink.h (elf_fix_symbol_flags): Avoid putting symbols
defined in debugging sections into .dynsym.
--- bfd/elflink.h.jj Mon Nov 5 11:52:52 2001
+++ bfd/elflink.h Tue Nov 6 19:24:04 2001
@@ -3755,6 +3755,27 @@ elf_fix_symbol_flags (h, eif)
(*bed->elf_backend_hide_symbol) (eif->info, h);
}
+ if (h->dynindx != -1
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ asection *sec = h->root.u.def.section;
+
+ /* Don't put symbols against debugging sections into dynamic symbol
+ section. */
+ if (sec->output_section != NULL
+ && (sec->output_section->flags & SEC_DEBUGGING) != 0)
+ {
+ struct elf_backend_data *bed;
+
+ bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
+ h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+ _bfd_elf_strtab_delref (elf_hash_table (eif->info)->dynstr,
+ h->dynstr_index);
+ (*bed->elf_backend_hide_symbol) (eif->info, h);
+ }
+ }
+
/* If this is a weak defined symbol in a dynamic object, and we know
the real definition in the dynamic object, copy interesting flags
over to the real definition. */
Jakub