aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-11-05 15:34:18 +0000
committerNick Clifton <nickc@redhat.com>2009-11-05 15:34:18 +0000
commit3cbc5de02ae9955c10dc678bc2bba84da97d9905 (patch)
tree01ec6c689d1e7abe6f800966694b6d2d0f24ef56 /bfd/elflink.c
parentcdcf946711bb98cea719b882f818ad15af47cc2d (diff)
downloadgdb-3cbc5de02ae9955c10dc678bc2bba84da97d9905.zip
gdb-3cbc5de02ae9955c10dc678bc2bba84da97d9905.tar.gz
gdb-3cbc5de02ae9955c10dc678bc2bba84da97d9905.tar.bz2
* elflink.c (elf_link_add_object_symbols): Improve error
message generated when a symbol is left unresolved because a --no-add-needed command line option has prevented the inclusion of the DSO defining it.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 65bba87..cd016b7 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -3877,6 +3877,7 @@ error_free_dyn:
bfd_boolean common;
unsigned int old_alignment;
bfd *old_bfd;
+ bfd * undef_bfd = NULL;
override = FALSE;
@@ -4108,6 +4109,20 @@ error_free_dyn:
name = newname;
}
+ /* If this is a definition of a previously undefined symbol
+ make a note of the bfd that contained the reference in
+ case we need to refer to it later on in error messages. */
+ if (! bfd_is_und_section (sec))
+ {
+ h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
+
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ && h->root.u.undef.abfd)
+ undef_bfd = h->root.u.undef.abfd;
+ }
+
if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec,
&value, &old_alignment,
sym_hash, &skip, &override,
@@ -4447,9 +4462,12 @@ error_free_dyn:
if ((elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0)
{
(*_bfd_error_handler)
- (_("%B: invalid DSO for symbol `%s' definition"),
+ (_("%B: undefined reference to symbol '%s'"),
+ undef_bfd == NULL ? info->output_bfd : undef_bfd, name);
+ (*_bfd_error_handler)
+ (_("note: '%s' is defined in DSO %B so try adding it to the linker command line"),
abfd, name);
- bfd_set_error (bfd_error_bad_value);
+ bfd_set_error (bfd_error_invalid_operation);
goto error_free_vers;
}