aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/binutils/binutils-2.20.1/201_elflink_improve_noaddneeded_errors.patch
blob: 85675a3d9e8d8285d2d399ef8fb2bd365ce1e1a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /bin/sh /usr/share/dpatch/dpatch-run
## 201_elflink_improve_errors.dpatch by  <kirr@landau.phys.spbu.ru>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Improves error messages regarding -no-add-needed cases; needed for 
## DP: later elflink patches
## DP: Upstream status: submitted upstream for binutils-2_20-branch

2010-08-07  Kirill Smelkov  <kirr@landau.phys.spbu.ru>

	Backport from mainline:
	2009-11-05  Nick Clifton  <nickc@redhat.com>

	* 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.

@DPATCH@
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 4a348de..10eee8c 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -3866,6 +3866,7 @@ error_free_dyn:
       bfd_boolean common;
       unsigned int old_alignment;
       bfd *old_bfd;
+      bfd * undef_bfd = NULL;
 
       override = FALSE;
 
@@ -4097,6 +4098,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,
@@ -4437,9 +4452,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;
 		}
 
-- 
1.7.2.1.44.g721e7