From: Ian Lance Taylor Date: Mon, 2 Oct 1995 18:11:12 +0000 (+0000) Subject: * elflink.h (elf_link_add_object_symbols): Don't let a weak X-Git-Tag: gdb-4_18~10681 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d7c42c988b599c12302a1d5786be79b7097248e;p=platform%2Fupstream%2Fbinutils.git * elflink.h (elf_link_add_object_symbols): Don't let a weak dynamic symbol override a common symbol. Don't change the size or type if they have been set and the new symbol is not a definition. Warn if the size or type changes. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a9177f3..114a99a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +Mon Oct 2 14:08:55 1995 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Don't let a weak + dynamic symbol override a common symbol. Don't change the size or + type if they have been set and the new symbol is not a definition. + Warn if the size or type changes. + Sun Oct 1 01:34:41 1995 Jeff Law (law@hurl.cygnus.com * som.c (som_begin_writing): Don't write the symbol table or diff --git a/bfd/elflink.h b/bfd/elflink.h index f4674f4..1aaa17e 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -666,8 +666,13 @@ elf_link_add_object_symbols (abfd, info) if (dynamic && definition) { if (h->root.type == bfd_link_hash_defined - || h->root.type == bfd_link_hash_defweak) - sec = bfd_und_section_ptr; + || h->root.type == bfd_link_hash_defweak + || (h->root.type == bfd_link_hash_common + && bind == STB_WEAK)) + { + sec = bfd_und_section_ptr; + definition = false; + } } /* Similarly, if we are not looking at a dynamic object, and @@ -742,16 +747,27 @@ elf_link_add_object_symbols (abfd, info) int new_flag; /* Remember the symbol size and type. */ - if (sym.st_size != 0) + if (sym.st_size != 0 + && (definition || h->size == 0)) { - /* FIXME: We should probably somehow give a warning if - the symbol size changes. */ + if (h->size != 0 && h->size != sym.st_size) + (*_bfd_error_handler) + ("Warning: size of symbol `%s' changed from %lu to %lu in %s", + name, (unsigned long) h->size, (unsigned long) sym.st_size, + bfd_get_filename (abfd)); + h->size = sym.st_size; } - if (ELF_ST_TYPE (sym.st_info) != STT_NOTYPE) + if (ELF_ST_TYPE (sym.st_info) != STT_NOTYPE + && (definition || h->type == STT_NOTYPE)) { - /* FIXME: We should probably somehow give a warning if - the symbol type changes. */ + if (h->type != STT_NOTYPE + && h->type != ELF_ST_TYPE (sym.st_info)) + (*_bfd_error_handler) + ("Warning: type of symbol `%s' changed from %d to %d in %s", + name, h->type, ELF_ST_TYPE (sym.st_info), + bfd_get_filename (abfd)); + h->type = ELF_ST_TYPE (sym.st_info); }