From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: ld error message %C format
Date: Wed, 18 May 2011 15:48:00 -0000 [thread overview]
Message-ID: <20110518154757.GQ20800@bubble.grove.modra.org> (raw)
How do people feel about extending typical linker error messages like
the following
tmpdir/dump0.o: In function `foo':
./compressed1.c:13: undefined reference to `bar'
to always include the section and offset information?
tmpdir/dump0.o: In function `foo':
./compressed1.c:13:(.text+0x8): undefined reference to `bar'
When debugging toolchain problems, the section and offset is often
more useful than the source information. I've checked that this
change doesn't seem to break emacs parsing of error messages.
* ldmisc.c (vfinfo <%C>): Always print section+offset.
Index: ld/ldmisc.c
===================================================================
RCS file: /cvs/src/src/ld/ldmisc.c,v
retrieving revision 1.39
diff -u -p -r1.39 ldmisc.c
--- ld/ldmisc.c 28 Feb 2011 18:34:52 -0000 1.39
+++ ld/ldmisc.c 14 May 2011 11:32:38 -0000
@@ -276,6 +276,7 @@ vfinfo (FILE *fp, const char *fmt, va_li
const char *functionname;
unsigned int linenumber;
bfd_boolean discard_last;
+ bfd_boolean done;
abfd = va_arg (arg, bfd *);
section = va_arg (arg, asection *);
@@ -343,15 +344,21 @@ vfinfo (FILE *fp, const char *fmt, va_li
if (filename != NULL)
fprintf (fp, "%s:", filename);
+ done = fmt[-1] != 'C';
if (functionname != NULL && fmt[-1] == 'G')
lfinfo (fp, "%T", functionname);
else if (filename != NULL && linenumber != 0)
- fprintf (fp, "%u", linenumber);
+ fprintf (fp, "%u%s", linenumber, ":" + done);
else
- lfinfo (fp, "(%A+0x%v)", section, offset);
+ done = FALSE;
}
else
- lfinfo (fp, "%B:(%A+0x%v)", abfd, section, offset);
+ {
+ lfinfo (fp, "%B:", abfd);
+ done = FALSE;
+ }
+ if (!done)
+ lfinfo (fp, "(%A+0x%v)", section, offset);
if (discard_last)
{
Index: ld/testsuite/ld-cris/undef2.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/undef2.d,v
retrieving revision 1.1
diff -u -p -r1.1 undef2.d
--- ld/testsuite/ld-cris/undef2.d 7 Feb 2005 02:53:32 -0000 1.1
+++ ld/testsuite/ld-cris/undef2.d 14 May 2011 10:41:43 -0000
@@ -3,4 +3,4 @@
# target: cris-*-*elf* cris-*-*aout*
# as: --em=crisaout
# ld: -mcrisaout
-# error: .o:/blah/foo.c:96: undefined reference to `globsym1'$
+# error: .o:/blah/foo.c:96:\(\.text\+0x4\): undefined reference to `globsym1'$
Index: ld/testsuite/ld-cris/undef3.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/undef3.d,v
retrieving revision 1.1
diff -u -p -r1.1 undef3.d
--- ld/testsuite/ld-cris/undef3.d 7 Feb 2005 02:53:32 -0000 1.1
+++ ld/testsuite/ld-cris/undef3.d 14 May 2011 10:41:43 -0000
@@ -3,4 +3,4 @@
#target: cris-*-*elf* cris-*-*aout*
#as: --em=criself
#ld: -mcriself
-#error: .o:/blah/foo.c:96: undefined reference to `globsym1'$
+#error: .o:/blah/foo.c:96:\(\.text\+0x4\): undefined reference to `globsym1'$
Index: ld/testsuite/ld-i386/compressed1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-i386/compressed1.d,v
retrieving revision 1.1
diff -u -p -r1.1 compressed1.d
--- ld/testsuite/ld-i386/compressed1.d 15 Jul 2010 00:42:23 -0000 1.1
+++ ld/testsuite/ld-i386/compressed1.d 14 May 2011 10:41:44 -0000
@@ -1,7 +1,7 @@
#name: undefined symbol with compressed debug sections
#as: --32
#ld: -e foo -melf_i386 --noinhibit-exec
-#warning: .*/compressed1.c:13: undefined reference to .bar.
+#warning: .*/compressed1.c:13.*: undefined reference to .bar.
#nm: -n
#...
Index: ld/testsuite/ld-ia64/line.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-ia64/line.exp,v
retrieving revision 1.1
diff -u -p -r1.1 line.exp
--- ld/testsuite/ld-ia64/line.exp 2 Sep 2007 13:29:20 -0000 1.1
+++ ld/testsuite/ld-ia64/line.exp 14 May 2011 10:41:44 -0000
@@ -52,6 +52,6 @@ proc checkund { string testname } {
}
}
-set ml "undefined.c:9: undefined reference to `*this_function_is_not_defined'"
+set ml "undefined.c:9*: undefined reference to `*this_function_is_not_defined'"
checkund $ml $testline
Index: ld/testsuite/ld-undefined/undefined.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-undefined/undefined.exp,v
retrieving revision 1.32
diff -u -p -r1.32 undefined.exp
--- ld/testsuite/ld-undefined/undefined.exp 6 Apr 2011 17:09:56 -0000 1.32
+++ ld/testsuite/ld-undefined/undefined.exp 14 May 2011 10:41:44 -0000
@@ -90,7 +90,7 @@ if ![is_elf_format] {
#setup_xfail "arm*-*-pe*"
}
-set ml "undefined.c:9: undefined reference to `*this_function_is_not_defined'"
+set ml "undefined.c:9*: undefined reference to `*this_function_is_not_defined'"
# With targets that use elf/dwarf2, such as the arm-elf
# toolchain, the code in bfd/elf.c:_bfd_elf_find_nearest_line() is called
# in order to locate the file name/line number where the undefined
Index: ld/testsuite/ld-x86-64/compressed1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-x86-64/compressed1.d,v
retrieving revision 1.1
diff -u -p -r1.1 compressed1.d
--- ld/testsuite/ld-x86-64/compressed1.d 15 Jul 2010 00:42:23 -0000 1.1
+++ ld/testsuite/ld-x86-64/compressed1.d 14 May 2011 10:41:44 -0000
@@ -1,7 +1,7 @@
#name: undefined symbol with compressed debug sections
#as: --64
#ld: -e foo -melf_x86_64 --noinhibit-exec
-#warning: .*/compressed1.c:13: undefined reference to .bar.
+#warning: .*/compressed1.c:13.*: undefined reference to .bar.
#nm: -n
#...
Index: ld/testsuite/ld-x86-64/line.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-x86-64/line.exp,v
retrieving revision 1.2
diff -u -p -r1.2 line.exp
--- ld/testsuite/ld-x86-64/line.exp 2 Sep 2007 13:29:20 -0000 1.2
+++ ld/testsuite/ld-x86-64/line.exp 14 May 2011 10:41:44 -0000
@@ -52,6 +52,6 @@ proc checkund { string testname } {
}
}
-set ml "undefined.c:9: undefined reference to `*this_function_is_not_defined'"
+set ml "undefined.c:9*: undefined reference to `*this_function_is_not_defined'"
checkund $ml $testline
--
Alan Modra
Australia Development Lab, IBM
next reply other threads:[~2011-05-18 15:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 15:48 Alan Modra [this message]
2011-05-18 15:51 ` H.J. Lu
2011-05-18 16:04 ` Jason Duerstock
2011-05-18 16:19 ` Andreas Schwab
2011-05-18 23:33 ` Alan Modra
2011-05-19 0:10 ` Jason Duerstock
2011-05-18 23:59 ` Ian Lance Taylor
2011-05-20 0:00 ` Alan Modra
2011-05-20 0:24 ` Ian Lance Taylor
2011-05-23 6:13 ` Alan Modra
2011-05-24 1:24 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110518154757.GQ20800@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).