Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Dec 2014 07:19:24 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r275632 - in stable/9/contrib/binutils/bfd: . po
Message-ID:  <201412090719.sB97JO9F071332@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Tue Dec  9 07:19:24 2014
New Revision: 275632
URL: https://svnweb.freebsd.org/changeset/base/275632

Log:
  MFC r257302 (by rea):
  
  binutils/bfd: fix printf-like format strings for "bfd *" arguments
  
  There is a special format argument '%B' that directly handles values
  of type 'bfd *', they must be used instead of '%s'.  Manifestations
  of this bug can be seen in ld(1) error messages, for example,
    http://lists.freebsd.org/pipermail/freebsd-current/2013-August/043580.html
    http://lists.freebsd.org/pipermail/freebsd-current/2013-October/045404.html
  
  Approved by:	dim
  
  MFC r275386:
  
  Let GNU ld be less obscure about missing symbols and DSOs.  If the BFD
  object looks like a typical shared library, suggest adding '-l<foo>',
  where <foo> has the 'lib' prefix and '.so<bar>' or '.a' suffix removed.
  
  Otherwise, suggest adding '-l:<foo>', where <foo> is the full DT_SONAME.
  
  Submitted by:	Conrad Meyer <conrad.meyer@isilon.com>
  Sponsored by:	EMC / Isilon storage division
  Reviewed by:	emaste
  PR:		194296
  Differential Revision: https://reviews.freebsd.org/D1152

Modified:
  stable/9/contrib/binutils/bfd/elf32-score.c
  stable/9/contrib/binutils/bfd/elflink.c
  stable/9/contrib/binutils/bfd/po/bfd.pot
Directory Properties:
  stable/9/contrib/binutils/   (props changed)

Modified: stable/9/contrib/binutils/bfd/elf32-score.c
==============================================================================
--- stable/9/contrib/binutils/bfd/elf32-score.c	Tue Dec  9 07:15:53 2014	(r275631)
+++ stable/9/contrib/binutils/bfd/elf32-score.c	Tue Dec  9 07:19:24 2014	(r275632)
@@ -2546,7 +2546,7 @@ _bfd_score_elf_check_relocs (bfd *abfd,
 	}
       else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
         {
-          (*_bfd_error_handler) (_("%s: Malformed reloc detected for section %s"), abfd, name);
+          (*_bfd_error_handler) (_("%B: Malformed reloc detected for section %s"), abfd, name);
           bfd_set_error (bfd_error_bad_value);
           return FALSE;
         }

Modified: stable/9/contrib/binutils/bfd/elflink.c
==============================================================================
--- stable/9/contrib/binutils/bfd/elflink.c	Tue Dec  9 07:15:53 2014	(r275631)
+++ stable/9/contrib/binutils/bfd/elflink.c	Tue Dec  9 07:19:24 2014	(r275632)
@@ -4356,9 +4356,38 @@ elf_link_add_object_symbols (bfd *abfd, 
 		 --no-add-needed is used.  */
 	      if ((elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0)
 		{
+		  bfd_boolean looks_soish;
+		  const char *print_name;
+		  int print_len;
+		  size_t len, lend = 0;
+
+		  looks_soish = FALSE;
+		  print_name = soname;
+		  print_len = strlen(soname);
+		  if (strncmp(soname, "lib", 3) == 0)
+		    {
+		      len = print_len;
+		      if (len > 5 && strcmp(soname + len - 2, ".a") == 0)
+			lend = len - 5;
+		      else
+			{
+			  while (len > 6 && (ISDIGIT(soname[len - 1]) ||
+					     soname[len - 1] == '.'))
+			    len--;
+			  if (strncmp(soname + len - 3, ".so", 3) == 0)
+			    lend = len - 6;
+			}
+		      if (lend != 0)
+			{
+			  print_name = soname + 3;
+			  print_len = lend;
+			  looks_soish = TRUE;
+		    	}
+		    }
+
 		  (*_bfd_error_handler)
-		    (_("%s: invalid DSO for symbol `%s' definition"),
-		     abfd, name);
+		    (_("undefined reference to symbol `%s' (try adding -l%s%.*s)"),
+		    name, looks_soish? "" : ":", print_len, print_name);
 		  bfd_set_error (bfd_error_bad_value);
 		  goto error_free_vers;
 		}

Modified: stable/9/contrib/binutils/bfd/po/bfd.pot
==============================================================================
--- stable/9/contrib/binutils/bfd/po/bfd.pot	Tue Dec  9 07:15:53 2014	(r275631)
+++ stable/9/contrib/binutils/bfd/po/bfd.pot	Tue Dec  9 07:19:24 2014	(r275632)
@@ -1572,7 +1572,7 @@ msgstr ""
 
 #: elf32-score.c:2549
 #, c-format
-msgid "%s: Malformed reloc detected for section %s"
+msgid "%B: Malformed reloc detected for section %s"
 msgstr ""
 
 #: elf32-score.c:2600
@@ -2438,9 +2438,9 @@ msgstr ""
 msgid "Warning: size of symbol `%s' changed from %lu in %B to %lu in %B"
 msgstr ""
 
-#: elflink.c:4309
+#: elflink.c:4389
 #, c-format
-msgid "%s: invalid DSO for symbol `%s' definition"
+msgid "undefined reference to symbol `%s' (try adding -l%s%.*s)"
 msgstr ""
 
 #: elflink.c:5535



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412090719.sB97JO9F071332>