This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Add --report-line-number-with-parentheses to linker


Hi,

Some IDE expects line number in linker messages surrounded by
parentheses. That is instead of

/tmp/prog.c:12: undefined reference to `library_func1'
/tmp/prog.c:13: undefined reference to `library_func2'
/tmp/prog.c:18: undefined reference to `global'
/tmp/prog.c:19: undefined reference to `puts'
/tmp/prog.c:22: undefined reference to `puts'
/tmp/prog.c:28: undefined reference to `global'
/tmp/prog.c:29: undefined reference to `puts'
/tmp/prog.c:32: undefined reference to `puts'
/tmp/prog.c:38: undefined reference to `puts'
/tmp/prog.c:42: undefined reference to `printf'

It expects:

tmp/prog.c(12): undefined reference to `library_func1'
/tmp/prog.c(13): undefined reference to `library_func2'
/tmp/prog.c(18): undefined reference to `global'
/tmp/prog.c(19): undefined reference to `puts'
/tmp/prog.c(22): undefined reference to `puts'
/tmp/prog.c(28): undefined reference to `global'
/tmp/prog.c(29): undefined reference to `puts'
/tmp/prog.c(32): undefined reference to `puts'
/tmp/prog.c(38): undefined reference to `puts'
/tmp/prog.c(42): undefined reference to `printf'

This patch adds --report-line-number-with-parentheses to support it.
OK to install?

Thanks.


H.J.
---
2009-07-24  H.J. Lu  <hongjiu.lu@intel.com>

	* ld.h (ld_config_type): Add report_line_number_with_parentheses.

	* ld.texinfo: Document --report-line-number-with-parentheses.

	* ldmisc.c (vfinfo): Handle config.report_line_number_with_parentheses.

	* lexsup.c (option_values): Add OPTION_REPORT_LINE_NUMBER_WITH_PARENTHESES.
	(ld_options): Add --report-line-number-with-parentheses.
	(parse_args): Handle OPTION_REPORT_LINE_NUMBER_WITH_PARENTHESES.

	* NEWS: Mention --report-line-number-with-parentheses.

--- ld/NEWS.parentheses	2009-07-23 15:57:28.000000000 -0700
+++ ld/NEWS	2009-07-23 16:42:44.000000000 -0700
@@ -4,6 +4,9 @@
   be passed on to the dynamic linker which will make sure that in the entire
   process there is just one symbol with the given name and type in use.
 
+* New option, --report-line-number-with-parentheses, to report line
+  number with parentheses.
+
 * PE targets now support a GNU extension to allow the alignment of common
   common symbols to be specified.  This support uses custom options in
   the .drectve section, which will be disregarded by the native tools.
--- ld/ld.h.parentheses	2009-07-20 09:50:35.000000000 -0700
+++ ld/ld.h	2009-07-23 16:42:44.000000000 -0700
@@ -262,6 +262,9 @@ typedef struct {
      on the command line.  */
   bfd_boolean only_cmd_line_lib_dirs;
 
+  /* If set, report line number with parentheses.  */
+  bfd_boolean report_line_number_with_parentheses;
+
   /* The rpath separation character.  Usually ':'.  */
   char rpath_separator;
 
--- ld/ld.texinfo.parentheses	2009-07-20 09:50:35.000000000 -0700
+++ ld/ld.texinfo	2009-07-23 16:42:44.000000000 -0700
@@ -1559,6 +1559,10 @@ On platforms where this is not supported
 but ignored.
 @end ifset
 
+@cindex report line number with parentheses
+@item --report-line-number-with-parentheses
+Report line number with parentheses in linker messages.
+
 @cindex retaining specified symbols
 @cindex stripping all but some symbols
 @cindex symbols, retaining selectively
--- ld/ldmisc.c.parentheses	2009-07-20 09:50:35.000000000 -0700
+++ ld/ldmisc.c	2009-07-23 16:50:43.000000000 -0700
@@ -339,12 +339,22 @@ vfinfo (FILE *fp, const char *fmt, va_li
 		      lfinfo (fp, "%B:", abfd);
 
 		    if (filename != NULL)
-		      fprintf (fp, "%s:", filename);
+		      {
+			if (config.report_line_number_with_parentheses)
+			  fprintf (fp, "%s", filename);
+			else
+			  fprintf (fp, "%s:", filename);
+		      }
 
 		    if (functionname != NULL && fmt[-1] == 'G')
 		      lfinfo (fp, "%T", functionname);
 		    else if (filename != NULL && linenumber != 0)
-		      fprintf (fp, "%u", linenumber);
+		      {
+			if (config.report_line_number_with_parentheses)
+			  fprintf (fp, "(%u)", linenumber);
+			else
+			  fprintf (fp, "%u", linenumber);
+		      }
 		    else
 		      lfinfo (fp, "(%A+0x%v)", section, offset);
 		  }
--- ld/lexsup.c.parentheses	2009-07-20 09:50:35.000000000 -0700
+++ ld/lexsup.c	2009-07-23 16:42:44.000000000 -0700
@@ -166,6 +166,7 @@ enum option_values
   OPTION_WARN_SHARED_TEXTREL,
   OPTION_WARN_ALTERNATE_EM,
   OPTION_REDUCE_MEMORY_OVERHEADS,
+  OPTION_REPORT_LINE_NUMBER_WITH_PARENTHESES,
   OPTION_DEFAULT_SCRIPT
 };
 
@@ -466,6 +467,10 @@ static const struct ld_option ld_options
     TWO_DASHES },
   { {"relax", no_argument, NULL, OPTION_RELAX},
     '\0', NULL, N_("Relax branches on certain targets"), TWO_DASHES },
+  { {"report-line-number-with-parentheses", no_argument, NULL,
+     OPTION_REPORT_LINE_NUMBER_WITH_PARENTHESES},
+    '\0', NULL, N_("Report line number with parentheses"),
+    TWO_DASHES },
   { {"retain-symbols-file", required_argument, NULL,
      OPTION_RETAIN_SYMBOLS_FILE},
     '\0', N_("FILE"), N_("Keep only symbols listed in FILE"), TWO_DASHES },
@@ -1476,6 +1481,10 @@ parse_args (unsigned argc, char **argv)
               einfo (_("%P%X: --hash-size needs a numeric argument\n"));
           }
           break;
+
+        case OPTION_REPORT_LINE_NUMBER_WITH_PARENTHESES:
+	  config.report_line_number_with_parentheses = TRUE;
+	  break;
 	}
     }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]