* 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.
This commit is contained in:
Ian Lance Taylor 1995-10-02 18:11:12 +00:00
parent 8055e7a883
commit 3d7c42c988
2 changed files with 31 additions and 8 deletions

View file

@ -1,3 +1,10 @@
Mon Oct 2 14:08:55 1995 Ian Lance Taylor <ian@cygnus.com>
* 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

View file

@ -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);
}