aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1995-10-02 18:11:12 +0000
committerIan Lance Taylor <ian@airs.com>1995-10-02 18:11:12 +0000
commit3d7c42c988b599c12302a1d5786be79b7097248e (patch)
treeadc4d92e6210f81293c99f811223edc29fc483c1 /bfd/elflink.h
parent8055e7a883528d953d6c6bac61a40df86b24ccb5 (diff)
downloadgdb-3d7c42c988b599c12302a1d5786be79b7097248e.zip
gdb-3d7c42c988b599c12302a1d5786be79b7097248e.tar.gz
gdb-3d7c42c988b599c12302a1d5786be79b7097248e.tar.bz2
* 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.
Diffstat (limited to 'bfd/elflink.h')
-rw-r--r--bfd/elflink.h32
1 files changed, 24 insertions, 8 deletions
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);
}