Change the way how we print out line numbers.

LLD's error messages contain line numbers, function names or section names.
Currently they are formatter as follows.

  foo.c (32): symbol 'foo' not found
  foo.c (function bar): symbol 'foo' not found
  foo.c (.text+0x1234): symbol 'foo' not found

This patch changes them so that they are consistent with Clang's output.

  foo.c:32: symbol 'foo' not found
  foo.c:(function bar): symbol 'foo' not found
  foo.c:(.text+0x1234): symbol 'foo' not found

Differential Revision: https://reviews.llvm.org/D26901

llvm-svn: 287537
This commit is contained in:
Rui Ueyama 2016-11-21 13:49:57 +00:00
parent 68dd881697
commit e8785ba4d7
28 changed files with 54 additions and 54 deletions

View File

@ -91,7 +91,7 @@ std::string elf::ObjectFile<ELFT>::getLineInfo(InputSectionBase<ELFT> *S,
Info);
if (Info.Line == 0)
return "";
return Info.FileName + " (" + std::to_string(Info.Line) + ")";
return Info.FileName + ":" + std::to_string(Info.Line);
}
// Returns "(internal)", "foo.a(bar.o)" or "baz.o".

View File

@ -554,11 +554,11 @@ std::string getLocation(InputSectionBase<ELFT> &S, typename ELFT::uint Offset) {
DefinedRegular<ELFT> *Encl = getSymbolAt(&S, Offset);
if (Encl && Encl->Type == STT_FUNC) {
StringRef Func = getSymbolName(File->getStringTable(), *Encl);
return SrcFile + " (function " + maybeDemangle(Func) + ")";
return SrcFile + ":(function " + maybeDemangle(Func) + ")";
}
// If there's no symbol, print out the offset instead of a symbol name.
return (SrcFile + " (" + S.Name + "+0x" + Twine::utohexstr(Offset) + ")")
return (SrcFile + ":(" + S.Name + "+0x" + Twine::utohexstr(Offset) + ")")
.str();
}

View File

@ -1,7 +1,7 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
// CHECK: {{.*}}.o (.text+0x0): can't create dynamic relocation R_AARCH64_ADD_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_ADD_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
add x0, x0, :lo12:dat
.data

View File

@ -1,7 +1,7 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
// CHECK: {{.*}}.o (.text+0x0): can't create dynamic relocation R_AARCH64_ADR_PREL_LO21 against symbol 'dat' defined in {{.*}}.o
// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_ADR_PREL_LO21 against symbol 'dat' defined in {{.*}}.o
adr x0, dat
.data

View File

@ -1,7 +1,7 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
// CHECK: {{.*}}.o (.text+0x0): can't create dynamic relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol 'dat' defined in {{.*}}.o
// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol 'dat' defined in {{.*}}.o
adrp x0, dat
.data

View File

@ -1,7 +1,7 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
// CHECK: {{.*}}.o (.text+0x0): can't create dynamic relocation R_AARCH64_LDST32_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_LDST32_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
ldr s4, [x0, :lo12:dat]
.data

View File

@ -1,7 +1,7 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
// CHECK: {{.*}}.o (.text+0x0): can't create dynamic relocation R_AARCH64_LDST64_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_LDST64_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
ldr x0, [x0, :lo12:dat]
.data

View File

@ -1,7 +1,7 @@
// REQUIRES: aarch64
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
// CHECK: {{.*}}.o (.text+0x0): can't create dynamic relocation R_AARCH64_LDST8_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_AARCH64_LDST8_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o
ldrsb x0, [x1, :lo12:dat]
.data

View File

@ -29,4 +29,4 @@
// RELATIVE: SYMBOL TABLE:
// RELATIVE: 00001004 .text 00000000 patatino
// ABS: {{.*}}.o (.text+0x0): can't create dynamic relocation R_ARM_TARGET1 against symbol 'patatino' defined in {{.*}}.o
// ABS: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_ARM_TARGET1 against symbol 'patatino' defined in {{.*}}.o

View File

@ -237,8 +237,8 @@ _start:
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: not ld.lld %t %t -o %t2 2>&1 | FileCheck --check-prefix=DUP %s
# DUP: {{.*}} (.text+0x0): duplicate symbol '_start'
# DUP: {{.*}} (.text+0x0): previous definition was here
# DUP: {{.*}}:(.text+0x0): duplicate symbol '_start'
# DUP: {{.*}}:(.text+0x0): previous definition was here
# RUN: not ld.lld %t -o %t -m wrong_emul_fbsd 2>&1 | FileCheck --check-prefix=UNKNOWN_EMUL %s
# UNKNOWN_EMUL: unknown emulation: wrong_emul_fbsd

View File

@ -3,18 +3,18 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
# RUN: not ld.lld %t1.o %t1.o -o %t2 2>&1 | FileCheck -check-prefix=DEMANGLE %s
# DEMANGLE: {{.*}} (.text+0x0): duplicate symbol 'mul(double, double)'
# DEMANGLE-NEXT: {{.*}} (.text+0x0): previous definition was here
# DEMANGLE-NEXT: {{.*}} (.text+0x0): duplicate symbol 'foo'
# DEMANGLE-NEXT: {{.*}} (.text+0x0): previous definition was here
# DEMANGLE: {{.*}}:(.text+0x0): duplicate symbol 'mul(double, double)'
# DEMANGLE-NEXT: {{.*}}:(.text+0x0): previous definition was here
# DEMANGLE-NEXT: {{.*}}:(.text+0x0): duplicate symbol 'foo'
# DEMANGLE-NEXT: {{.*}}:(.text+0x0): previous definition was here
# RUN: not ld.lld %t1.o %t1.o -o %t2 --no-demangle 2>&1 | \
# RUN: FileCheck -check-prefix=NO_DEMANGLE %s
# NO_DEMANGLE: {{.*}} (.text+0x0): duplicate symbol '_Z3muldd'
# NO_DEMANGLE-NEXT: {{.*}} (.text+0x0): previous definition was here
# NO_DEMANGLE-NEXT: {{.*}} (.text+0x0): duplicate symbol 'foo'
# NO_DEMANGLE-NEXT: {{.*}} (.text+0x0): previous definition was here
# NO_DEMANGLE: {{.*}}:(.text+0x0): duplicate symbol '_Z3muldd'
# NO_DEMANGLE-NEXT: {{.*}}:(.text+0x0): previous definition was here
# NO_DEMANGLE-NEXT: {{.*}}:(.text+0x0): duplicate symbol 'foo'
# NO_DEMANGLE-NEXT: {{.*}}:(.text+0x0): previous definition was here
# RUN: not ld.lld %t1.o %t1.o -o %t2 --demangle --no-demangle 2>&1 | \
# RUN: FileCheck -check-prefix=NO_DEMANGLE %s
@ -25,14 +25,14 @@
# RUN: llvm-ar rcs %t3.a %t2.o
# RUN: not ld.lld %t1.o %t3.a -u baz -o %t2 2>&1 | FileCheck -check-prefix=ARCHIVE %s
# ARCHIVE: {{.*}}3.a({{.*}}2.o) (.text+0x0): duplicate symbol 'foo'
# ARCHIVE-NEXT: {{.*}}1.o (.text+0x0): previous definition was here
# ARCHIVE: {{.*}}3.a({{.*}}2.o):(.text+0x0): duplicate symbol 'foo'
# ARCHIVE-NEXT: {{.*}}1.o:(.text+0x0): previous definition was here
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/conflict-debug.s -o %t-dbg.o
# RUN: not ld.lld %t-dbg.o %t-dbg.o -o %t-dbg 2>&1 | FileCheck -check-prefix=DBGINFO %s
# DBGINFO: conflict-debug.s (4): duplicate symbol 'zed'
# DBGINFO-NEXT: conflict-debug.s (4): previous definition was here
# DBGINFO: conflict-debug.s:4: duplicate symbol 'zed'
# DBGINFO-NEXT: conflict-debug.s:4: previous definition was here
.globl _Z3muldd, foo
_Z3muldd:

View File

@ -9,7 +9,7 @@ _start:
call bar
// CHECK: {{.*}}.o (.text+0x1): cannot preempt symbol 'bar' defined in {{.*}}.so
// CHECK: {{.*}}.o:(.text+0x1): cannot preempt symbol 'bar' defined in {{.*}}.so
call zed
// CHECK: symbol 'zed' defined in {{.*}}.so is missing type

View File

@ -7,4 +7,4 @@
.quad foo
// CHECK: {{.*}}.o (.text+0x0): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.so
// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.so

View File

@ -3,8 +3,8 @@
// RUN: ld.lld %t2.o -o %t2.so -shared
// RUN: not ld.lld %t.o %t2.so -o %t.exe -pie 2>&1 | FileCheck %s
// CHECK: {{.*}}.o (.text+0x0): can't create dynamic relocation R_X86_64_64 against symbol 'bar' defined in {{.*}}.so
// CHECK: {{.*}}.o (.text+0x8): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.so
// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_X86_64_64 against symbol 'bar' defined in {{.*}}.so
// CHECK: {{.*}}.o:(.text+0x8): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.so
.global _start
_start:

View File

@ -5,4 +5,4 @@
foo:
.quad foo
// CHECK: {{.*}}.o (.text+0x0): can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment defined in {{.*}}.o
// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment defined in {{.*}}.o

View File

@ -7,4 +7,4 @@
.cfi_personality 0x8c, foo
.cfi_endproc
// CHECK: {{.*}}.o (.eh_frame+0x12): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.o
// CHECK: {{.*}}.o:(.eh_frame+0x12): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.o

View File

@ -22,7 +22,7 @@
// Should not link because of undefined symbol _bar
// RUN: not ld.lld -o %t3 %t.o %tbar.o 2>&1 \
// RUN: | FileCheck --check-prefix=UNDEFINED %s
// UNDEFINED: error: {{.*}} (.bar+0x0): undefined symbol '_bar'
// UNDEFINED: error: {{.*}}:(.bar+0x0): undefined symbol '_bar'
// Should fail if cannot find specified library (without -L switch)
// RUN: not ld.lld -o %t3 %t.o -lls 2>&1 \

View File

@ -2,9 +2,9 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: echo "SECTIONS { }" > %t.script
# RUN: not ld.lld %t.o -script %t.script -o %t 2>&1 | FileCheck %s
# CHECK: error: {{.*}} (.text+0x0): undefined symbol '_edata'
# CHECK: error: {{.*}} (.text+0x8): undefined symbol '_etext'
# CHECK: error: {{.*}} (.text+0x10): undefined symbol '_end'
# CHECK: error: {{.*}}:(.text+0x0): undefined symbol '_edata'
# CHECK: error: {{.*}}:(.text+0x8): undefined symbol '_etext'
# CHECK: error: {{.*}}:(.text+0x10): undefined symbol '_end'
.global _start,_end,_etext,_edata
.text

View File

@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: echo "SECTIONS { }" > %t.script
# RUN: not ld.lld %t.o -script %t.script -o %t 2>&1 | FileCheck %s
# CHECK: error: {{.*}} (.text+0x0): undefined symbol '__ehdr_start'
# CHECK: error: {{.*}}:(.text+0x0): undefined symbol '__ehdr_start'
.text
.global _start, __ehdr_start

View File

@ -11,4 +11,4 @@ define void @_start() {
ret void
}
; CHECK: error: ld-temp.o (function _start): undefined symbol 'foo'
; CHECK: error: ld-temp.o:(function _start): undefined symbol 'foo'

View File

@ -7,6 +7,6 @@
.globl _start
_start:
# CHECK: {{.*}}input1.o (.text+0x1): relocation R_X86_64_PLT32 cannot refer to absolute symbol 'answer' defined in {{.*}}input2.o
# CHECK: {{.*}}input1.o:(.text+0x1): relocation R_X86_64_PLT32 cannot refer to absolute symbol 'answer' defined in {{.*}}input2.o
call answer@PLT

View File

@ -9,7 +9,7 @@
// Should not link because of undefined symbol _bar
// RUN: not ld.lld -o %t/r %t/m.o 2>&1 \
// RUN: | FileCheck --check-prefix=UNDEFINED %s
// UNDEFINED: error: {{.*}} (.text+0x1): undefined symbol '_bar'
// UNDEFINED: error: {{.*}}:(.text+0x1): undefined symbol '_bar'
// We need to be sure that there is no suitable library in the /lib directory
// RUN: not ld.lld -o %t/r %t/m.o -L/lib -l:libls.a 2>&1 \

View File

@ -10,4 +10,4 @@
_start:
call __tls_get_addr
// CHECK: error: {{.*}} (.text+0x1): undefined symbol '__tls_get_addr'
// CHECK: error: {{.*}}:(.text+0x1): undefined symbol '__tls_get_addr'

View File

@ -1,15 +1,15 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s
# CHECK: error: {{.*}} (.data+0x0): undefined symbol 'hidden'
# CHECK: error: {{.*}}:(.data+0x0): undefined symbol 'hidden'
.global hidden
.hidden hidden
# CHECK: error: {{.*}} (.data+0x8): undefined symbol 'internal'
# CHECK: error: {{.*}}:(.data+0x8): undefined symbol 'internal'
.global internal
.internal internal
# CHECK: error: {{.*}} (.data+0x10): undefined symbol 'protected'
# CHECK: error: {{.*}}:(.data+0x10): undefined symbol 'protected'
.global protected
.protected protected

View File

@ -5,17 +5,17 @@
# RUN: llvm-ar rc %t2.a %t2.o
# RUN: not ld.lld %t.o %t2.a %t3.o -o %t.exe 2>&1 | FileCheck %s
# RUN: not ld.lld -pie %t.o %t2.a %t3.o -o %t.exe 2>&1 | FileCheck %s
# CHECK: error: undef.s (.text+0x1): undefined symbol 'foo'
# 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: undef.s:(.text+0x1): undefined symbol 'foo'
# 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'
# RUN: not ld.lld %t.o %t2.a -o %t.exe -no-demangle 2>&1 | \
# RUN: FileCheck -check-prefix=NO-DEMANGLE %s
# NO-DEMANGLE: error: undef.s (.text+0x10): undefined symbol '_Z3fooi'
# NO-DEMANGLE: error: undef.s:(.text+0x10): undefined symbol '_Z3fooi'
.file "undef.s"

View File

@ -6,7 +6,7 @@
## Check that %t2.o contains undefined symbol undef.
# RUN: not ld.lld %t1.o %t2.o -o %t 2>&1 | \
# RUN: FileCheck -check-prefix=UNDCHECK %s
# UNDCHECK: error: {{.*}}2.o (.text+0x1): undefined symbol 'undef'
# UNDCHECK: error: {{.*}}2.o:(.text+0x1): undefined symbol 'undef'
## Error out if unknown option value was set.
# RUN: not ld.lld %t1.o %t2.o -o %t --unresolved-symbols=xxx 2>&1 | \
@ -19,7 +19,7 @@
# RUN: llvm-readobj %t1_1 > /dev/null 2>&1
# RUN: not ld.lld %t2.o -o %t1_2 --unresolved-symbols=ignore-all --no-undefined 2>&1 | \
# RUN: FileCheck -check-prefix=ERRUND %s
# ERRUND: error: {{.*}} (.text+0x1): undefined symbol 'undef'
# ERRUND: error: {{.*}}:(.text+0x1): undefined symbol 'undef'
## Also ignore all should not produce error for symbols from DSOs.
# RUN: ld.lld %t1.o %t.so -o %t1_3 --unresolved-symbols=ignore-all
# RUN: llvm-readobj %t1_3 > /dev/null 2>&1

View File

@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: not ld.lld %t.o %S/Inputs/verneed1.so -o %t 2>&1 | FileCheck %s
# CHECK: error: {{.*}} (.text+0x1): undefined symbol 'f3'
# CHECK: error: {{.*}}:(.text+0x1): undefined symbol 'f3'
.globl _start
_start:
call f3

View File

@ -2,6 +2,6 @@
# RUN: ld.lld -shared %t.o -o %t1.so
# RUN: not ld.lld -z defs -shared %t.o -o %t1.so 2>&1 | FileCheck -check-prefix=ERR %s
# ERR: error: {{.*}} (.text+0x1): undefined symbol 'foo'
# ERR: error: {{.*}}:(.text+0x1): undefined symbol 'foo'
callq foo@PLT