[PATCH] D27506: [ELF] - Print absolute file name in errors when possible.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 01:03:15 PST 2016


grimar created this revision.
grimar added reviewers: ruiu, rafael, evgeny777.
grimar added subscribers: llvm-commits, grimar.

Currently LLD prints basename of source file name in error messages,
for example:
	$ mkdir foo
	$ echo 'void _start(void) { foobar(); }' > foo/bar.c
	$ gcc -g -c foo/bar.c
	$ bin/ld.lld -o out bar.o 
	bin/ld.lld: error: bar.c:1: undefined symbol 'foobar'
	$
This should say:
	bin/ld.lld: error: foo/bar.c:1: undefined symbol 'foobar'

This is PR31299


https://reviews.llvm.org/D27506

Files:
  ELF/InputFiles.cpp
  test/ELF/Inputs/undef-debug.s
  test/ELF/undef.s


Index: test/ELF/undef.s
===================================================================
--- test/ELF/undef.s
+++ test/ELF/undef.s
@@ -9,9 +9,9 @@
 # CHECK: error: undef.s:(.text+0x6): undefined symbol 'bar'
 # CHECK: error: undef.s:(.text+0x10): undefined symbol 'foo(int)'
 # CHECK: error: {{.*}}2.a({{.*}}.o):(.text+0x0): undefined symbol 'zed2'
-# CHECK: error: undef-debug.s:3: undefined symbol 'zed3'
-# CHECK: error: undef-debug.s:7: undefined symbol 'zed4'
-# CHECK: error: undef-debug.s:11: undefined symbol 'zed5'
+# CHECK: error: folder\undef-debug.s:3: undefined symbol 'zed3'
+# CHECK: error: folder\undef-debug.s:7: undefined symbol 'zed4'
+# CHECK: error: folder\undef-debug.s:11: undefined symbol 'zed5'
 
 # RUN: not ld.lld %t.o %t2.a -o %t.exe -no-demangle 2>&1 | \
 # RUN:   FileCheck -check-prefix=NO-DEMANGLE %s
Index: test/ELF/Inputs/undef-debug.s
===================================================================
--- test/ELF/Inputs/undef-debug.s
+++ test/ELF/Inputs/undef-debug.s
@@ -1,4 +1,4 @@
-.file 1 "undef-debug.s"
+.file 1 "folder/undef-debug.s"
 .loc 1 3
         .quad zed3
 
Index: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ ELF/InputFiles.cpp
@@ -86,9 +86,9 @@
   // Use fake address calcuated by adding section file offset and offset in
   // section. See comments for ObjectInfo class.
   DILineInfo Info;
-  DILineInfoSpecifier Spec;
-  Tbl->getFileLineInfoForAddress(S->Offset + Offset, nullptr, Spec.FLIKind,
-                                 Info);
+  Tbl->getFileLineInfoForAddress(
+      S->Offset + Offset, nullptr,
+      DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, Info);
   if (Info.Line == 0)
     return "";
   return Info.FileName + ":" + std::to_string(Info.Line);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27506.80550.patch
Type: text/x-patch
Size: 1806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161207/a59085ab/attachment.bin>


More information about the llvm-commits mailing list