Index: ELF/EhFrame.cpp =================================================================== --- ELF/EhFrame.cpp +++ ELF/EhFrame.cpp @@ -18,6 +18,7 @@ #include "EhFrame.h" #include "Error.h" +#include "InputFiles.h" #include "InputSection.h" #include "Relocations.h" #include "Strings.h" @@ -44,7 +45,9 @@ private: template void failOn(const P *Loc, const Twine &Msg) { - fatal(IS->getLocation((const uint8_t *)Loc - IS->Data.data()) + ": " + Msg); + fatal(toString(IS->getFile()) + ": " + Msg, + "location is " + + IS->getLocation((const uint8_t *)Loc - IS->Data.data())); } uint8_t readByte(); Index: ELF/Error.h =================================================================== --- ELF/Error.h +++ ELF/Error.h @@ -37,9 +37,9 @@ void log(const Twine &Msg); void message(const Twine &Msg); -void warn(const Twine &Msg); -void error(const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg); +void warn(const Twine &Msg, const Twine &Note = ""); +void error(const Twine &Msg, const Twine &Note = ""); +LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg, const Twine &Note = ""); LLVM_ATTRIBUTE_NORETURN void exitLld(int Val); Index: ELF/Error.cpp =================================================================== --- ELF/Error.cpp +++ ELF/Error.cpp @@ -57,22 +57,30 @@ outs().flush(); } -void elf::warn(const Twine &Msg) { +static void printMsgWithNote(StringRef Prefix, const Twine &Msg, + const Twine &Note, raw_ostream::Colors C) { + print(Prefix, C); + *ErrorOS << Msg << "\n"; + if (Note.isTriviallyEmpty()) + return; + print("note: ", C); + *ErrorOS << Note << "\n"; +} + +void elf::warn(const Twine &Msg, const Twine &Note) { if (Config->FatalWarnings) { - error(Msg); + error(Msg, Note); return; } std::lock_guard Lock(Mu); - print("warning: ", raw_ostream::MAGENTA); - *ErrorOS << Msg << "\n"; + printMsgWithNote("warning: ", Msg, Note, raw_ostream::MAGENTA); } -void elf::error(const Twine &Msg) { +void elf::error(const Twine &Msg, const Twine &Note) { std::lock_guard Lock(Mu); if (Config->ErrorLimit == 0 || ErrorCount < Config->ErrorLimit) { - print("error: ", raw_ostream::RED); - *ErrorOS << Msg << "\n"; + printMsgWithNote("error: ", Msg, Note, raw_ostream::RED); } else if (ErrorCount == Config->ErrorLimit) { print("error: ", raw_ostream::RED); *ErrorOS << "too many errors emitted, stopping now" @@ -95,10 +103,9 @@ _exit(Val); } -void elf::fatal(const Twine &Msg) { +void elf::fatal(const Twine &Msg, const Twine &Note) { std::lock_guard Lock(Mu); - print("error: ", raw_ostream::RED); - *ErrorOS << Msg << "\n"; + printMsgWithNote("error: ", Msg, Note, raw_ostream::RED); exitLld(1); } Index: ELF/InputSection.h =================================================================== --- ELF/InputSection.h +++ ELF/InputSection.h @@ -146,7 +146,8 @@ void uncompress(); - // Returns a source location string. Used to construct an error message. + // Returns detailed information about source location. Used to construct an + // error message. std::string getLocation(uintX_t Offset); void relocate(uint8_t *Buf, uint8_t *BufEnd); Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -161,29 +161,32 @@ return nullptr; } +// Find a function symbol that encloses a given location. If there's no symbol, +// returns the offset in the section. +template +static std::string getFunctionName(const InputSectionBase *IS, + typename ELFT::uint Offset) { + for (SymbolBody *B : IS->getFile()->getSymbols()) + if (auto *D = dyn_cast>(B)) + if (D->Section == IS && D->Type == STT_FUNC) + if (D->Value <= Offset && Offset < D->Value + D->Size) + return "function " + toString(*D); + return (IS->Name + "+0x" + utohexstr(Offset)).str(); +} + // Returns a source location string. Used to construct an error message. template std::string InputSectionBase::getLocation(typename ELFT::uint Offset) { - // First check if we can get desired values from debugging information. std::string LineInfo = File->getLineInfo(this, Offset); if (!LineInfo.empty()) return LineInfo; // File->SourceFile contains STT_FILE symbol that contains a - // source file name. If it's missing, we use an object file name. - std::string SrcFile = File->SourceFile; - if (SrcFile.empty()) - SrcFile = toString(File); - - // Find a function symbol that encloses a given location. - for (SymbolBody *B : File->getSymbols()) - if (auto *D = dyn_cast>(B)) - if (D->Section == this && D->Type == STT_FUNC) - if (D->Value <= Offset && Offset < D->Value + D->Size) - return SrcFile + ":(function " + toString(*D) + ")"; - - // If there's no symbol, print out the offset in the section. - return (SrcFile + ":(" + Name + "+0x" + utohexstr(Offset) + ")").str(); + // source file name. If we have it, we use it in the output. + std::string FuncName = getFunctionName(this, Offset); + if (File->SourceFile.empty()) + return "(" + FuncName + ")"; + return (File->SourceFile + "(" + FuncName + ")").str(); } template @@ -465,7 +468,8 @@ SymbolBody &Sym = this->File->getRelocTargetSym(Rel); if (Target->getRelExpr(Type, Sym) != R_ABS) { - error(this->getLocation(Offset) + ": has non-ABS reloc"); + error(toString(getFile()) + ": has non-ABS reloc", + "location is " + getLocation(Offset)); return; } Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -356,9 +356,10 @@ return true; if (&Body == ElfSym::MipsGpDisp) return true; - error(S.getLocation(RelOff) + ": relocation " + toString(Type) + - " cannot refer to absolute symbol '" + toString(Body) + - "' defined in " + toString(Body.File)); + error(toString(S.getFile()) + ": relocation " + toString(Type) + + " cannot refer to absolute symbol '" + toString(Body) + + "' defined in " + toString(Body.File), + "location is " + S.getLocation(RelOff)); return true; } @@ -528,16 +529,18 @@ // only memory. We can hack around it if we are producing an executable and // the refered symbol can be preemepted to refer to the executable. if (Config->Shared || (Config->pic() && !isRelExpr(Expr))) { - error(S.getLocation(RelOff) + ": can't create dynamic relocation " + - toString(Type) + " against " + - (Body.getName().empty() ? "local symbol in readonly segment" - : "symbol '" + toString(Body) + "'") + - " defined in " + toString(Body.File)); + error(toString(S.getFile()) + ": can't create dynamic relocation " + + toString(Type) + " against " + + (Body.getName().empty() ? "local symbol in readonly segment" + : "symbol '" + toString(Body) + "'") + + " defined in " + toString(Body.File), + "location is " + S.getLocation(RelOff)); return Expr; } if (Body.getVisibility() != STV_DEFAULT) { - error(S.getLocation(RelOff) + ": cannot preempt symbol '" + toString(Body) + - "' defined in " + toString(Body.File)); + error(toString(S.getFile()) + ": cannot preempt symbol '" + toString(Body) + + "' defined in " + toString(Body.File), + "location is " + S.getLocation(RelOff)); return Expr; } if (Body.isObject()) { @@ -619,13 +622,14 @@ return; std::string Msg = - S.getLocation(Offset) + ": undefined symbol '" + toString(Sym) + "'"; + toString(S.getFile()) + ": undefined symbol '" + toString(Sym) + "'"; + std::string Note = "location is " + S.getLocation(Offset); if (Config->UnresolvedSymbols == UnresolvedPolicy::WarnAll || (Config->UnresolvedSymbols == UnresolvedPolicy::Warn && CanBeExternal)) - warn(Msg); + warn(Msg, Note); else - error(Msg); + error(Msg, Note); } template @@ -761,9 +765,12 @@ } else { // We don't know anything about the finaly symbol. Just ask the dynamic // linker to handle the relocation for us. - if (!Target->isPicRel(Type)) - error(C.getLocation(Offset) + ": relocation " + toString(Type) + - " cannot be used against shared object; recompile with -fPIC."); + if (!Target->isPicRel(Type)) { + error( + toString(C.getFile()) + ": relocation " + toString(Type) + + " cannot be used against shared object; recompile with -fPIC.", + "location is " + C.getLocation(Offset)); + } AddDyn({Target->getDynRel(Type), &C, Offset, false, &Body, Addend}); // MIPS ABI turns using of GOT and dynamic relocations inside out. Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -349,15 +349,15 @@ return S; } -static void print(const Twine &Msg) { +static void print(const Twine &Msg, const Twine &Note) { if (Config->AllowMultipleDefinition) - warn(Msg); + warn(Msg, Note); else - error(Msg); + error(Msg, Note); } static void reportDuplicate(SymbolBody *Existing, InputFile *NewFile) { - print("duplicate symbol " + conflictMsg(Existing, NewFile)); + print("duplicate symbol " + conflictMsg(Existing, NewFile), ""); } template @@ -370,11 +370,13 @@ return; } - std::string OldLoc = D->Section->getLocation(D->Value); - std::string NewLoc = ErrSec->getLocation(ErrOffset); - - print(NewLoc + ": duplicate symbol '" + toString(*Existing) + "'"); - print(OldLoc + ": previous definition was here"); + std::string Note = + "definition found in " + D->Section->getLocation(D->Value) + + "\nprevious definition was here: " + toString(D->Section->getFile()) + + "\ndefinition found in " + ErrSec->getLocation(ErrOffset); + print(toString(ErrSec->getFile()) + ": duplicate symbol '" + + toString(*Existing) + "'", + Note); } template Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -59,7 +59,10 @@ static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) | V); } static void or32be(uint8_t *P, int32_t V) { write32be(P, read32be(P) | V); } -template static std::string getErrorLoc(uint8_t *Loc) { +// Returns file name and detailed information about source location, +// used to construct error messages with notes. +template +static std::pair getErrorLoc(uint8_t *Loc) { for (InputSectionData *D : Symtab::X->Sections) { auto *IS = dyn_cast_or_null>(D); if (!IS || !IS->OutSec) @@ -67,12 +70,12 @@ uint8_t *ISLoc = cast>(IS->OutSec)->Loc + IS->OutSecOff; if (ISLoc <= Loc && Loc < ISLoc + IS->getSize()) - return IS->getLocation(Loc - ISLoc) + ": "; + return {toString(IS->getFile()), IS->getLocation(Loc - ISLoc)}; } - return ""; + return {}; } -static std::string getErrorLocation(uint8_t *Loc) { +static std::pair getErrorLocation(uint8_t *Loc) { switch (Config->EKind) { case ELF32LEKind: return getErrorLoc(Loc); @@ -87,32 +90,33 @@ } } +static void reportError(uint8_t *Loc, const Twine &Msg) { + std::pair L = getErrorLocation(Loc); + error(L.first + ": " + Msg, "location is " + L.second); +} + template static void checkInt(uint8_t *Loc, int64_t V, uint32_t Type) { if (!isInt(V)) - error(getErrorLocation(Loc) + "relocation " + toString(Type) + - " out of range"); + reportError(Loc, "relocation " + toString(Type) + " out of range"); } template static void checkUInt(uint8_t *Loc, uint64_t V, uint32_t Type) { if (!isUInt(V)) - error(getErrorLocation(Loc) + "relocation " + toString(Type) + - " out of range"); + reportError(Loc, "relocation " + toString(Type) + " out of range"); } template static void checkIntUInt(uint8_t *Loc, uint64_t V, uint32_t Type) { if (!isInt(V) && !isUInt(V)) - error(getErrorLocation(Loc) + "relocation " + toString(Type) + - " out of range"); + reportError(Loc, "relocation " + toString(Type) + " out of range"); } template static void checkAlignment(uint8_t *Loc, uint64_t V, uint32_t Type) { if ((V & (N - 1)) != 0) - error(getErrorLocation(Loc) + "improper alignment for relocation " + - toString(Type)); + reportError(Loc, "improper alignment for relocation " + toString(Type)); } namespace { @@ -838,8 +842,9 @@ memcpy(Inst, "\x48\xc7", 2); *RegSlot = 0xc0 | Reg; } else { - error(getErrorLocation(Loc - 3) + - "R_X86_64_GOTTPOFF must be used in MOVQ or ADDQ instructions only"); + reportError( + Loc - 3, + "R_X86_64_GOTTPOFF must be used in MOVQ or ADDQ instructions only"); } // The original code used a PC relative relocation. @@ -1086,7 +1091,7 @@ or32be(Loc, Val & 0x3FFFFFC); break; default: - error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type)); + reportError(Loc, "unrecognized reloc " + Twine(Type)); } } @@ -1264,7 +1269,7 @@ break; } default: - error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type)); + reportError(Loc, "unrecognized reloc " + Twine(Type)); } } @@ -1515,7 +1520,7 @@ or32AArch64Imm(Loc, Val); break; default: - error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type)); + reportError(Loc, "unrecognized reloc " + Twine(Type)); } } @@ -1625,7 +1630,7 @@ write32le(Loc, Val >> 32); break; default: - error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type)); + reportError(Loc, "unrecognized reloc " + Twine(Type)); } } @@ -1949,7 +1954,7 @@ (Val & 0x00ff)); // imm8 break; default: - error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type)); + reportError(Loc, "unrecognized reloc " + Twine(Type)); } } @@ -2311,8 +2316,7 @@ return std::make_pair(Type2, Val); if (Type2 == R_MIPS_SUB && (Type3 == R_MIPS_HI16 || Type3 == R_MIPS_LO16)) return std::make_pair(Type3, -Val); - error(getErrorLocation(Loc) + "unsupported relocations combination " + - Twine(Type)); + reportError(Loc, "unsupported relocations combination " + Twine(Type)); return std::make_pair(Type & 0xff, Val); } @@ -2407,7 +2411,7 @@ applyMipsPcReloc(Loc, Type, Val); break; default: - error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type)); + reportError(Loc, "unrecognized reloc " + Twine(Type)); } } Index: test/ELF/Inputs/conflict-debug2.s =================================================================== --- test/ELF/Inputs/conflict-debug2.s +++ test/ELF/Inputs/conflict-debug2.s @@ -0,0 +1,4 @@ +.file "conflict-debug.s" +.globl zed +zed: + nop Index: test/ELF/aarch64-fpic-abs16.s =================================================================== --- test/ELF/aarch64-fpic-abs16.s +++ test/ELF/aarch64-fpic-abs16.s @@ -1,7 +1,8 @@ // 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: {{.*}}:(.data+0x0): relocation R_AARCH64_ABS16 cannot be used against shared object; recompile with -fPIC. +// CHECK: {{.*}}: relocation R_AARCH64_ABS16 cannot be used against shared object; recompile with -fPIC. +// CHECK-NEXT: note: location is (.data+0x0) .data .hword foo Index: test/ELF/aarch64-fpic-add_abs_lo12_nc.s =================================================================== --- test/ELF/aarch64-fpic-add_abs_lo12_nc.s +++ test/ELF/aarch64-fpic-add_abs_lo12_nc.s @@ -1,7 +1,8 @@ // 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: can't create dynamic relocation R_AARCH64_ADD_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o +// CHECK-NEXT: note: location is (.text+0x0) add x0, x0, :lo12:dat .data Index: test/ELF/aarch64-fpic-adr_prel_lo21.s =================================================================== --- test/ELF/aarch64-fpic-adr_prel_lo21.s +++ test/ELF/aarch64-fpic-adr_prel_lo21.s @@ -1,7 +1,8 @@ // 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: can't create dynamic relocation R_AARCH64_ADR_PREL_LO21 against symbol 'dat' defined in {{.*}}.o +// CHECK-NEXT: note: location is (.text+0x0) adr x0, dat .data Index: test/ELF/aarch64-fpic-adr_prel_pg_hi21.s =================================================================== --- test/ELF/aarch64-fpic-adr_prel_pg_hi21.s +++ test/ELF/aarch64-fpic-adr_prel_pg_hi21.s @@ -1,7 +1,8 @@ // 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: can't create dynamic relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol 'dat' defined in {{.*}}.o +// CHECK-NEXT: note: location is (.text+0x0) adrp x0, dat .data Index: test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s =================================================================== --- test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s +++ test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s @@ -1,7 +1,8 @@ // 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: can't create dynamic relocation R_AARCH64_LDST32_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o +// CHECK-NEXT: note: location is (.text+0x0) ldr s4, [x0, :lo12:dat] .data Index: test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s =================================================================== --- test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s +++ test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s @@ -1,7 +1,8 @@ // 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: can't create dynamic relocation R_AARCH64_LDST64_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o +// CHECK-NEXT: note: location is (.text+0x0) ldr x0, [x0, :lo12:dat] .data Index: test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s =================================================================== --- test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s +++ test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s @@ -1,7 +1,8 @@ // 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: can't create dynamic relocation R_AARCH64_LDST8_ABS_LO12_NC against symbol 'dat' defined in {{.*}}.o +// CHECK-NEXT: note: location is (.text+0x0) ldrsb x0, [x1, :lo12:dat] .data Index: test/ELF/aarch64-fpic-prel16.s =================================================================== --- test/ELF/aarch64-fpic-prel16.s +++ test/ELF/aarch64-fpic-prel16.s @@ -1,7 +1,8 @@ // 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: {{.*}}:(.data+0x0): relocation R_AARCH64_PREL16 cannot be used against shared object; recompile with -fPIC. +// CHECK: {{.*}}.o: relocation R_AARCH64_PREL16 cannot be used against shared object; recompile with -fPIC. +// CHECK-NEXT: note: location is (.data+0x0) .data .hword foo - . Index: test/ELF/aarch64-fpic-prel32.s =================================================================== --- test/ELF/aarch64-fpic-prel32.s +++ test/ELF/aarch64-fpic-prel32.s @@ -1,7 +1,8 @@ // 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: {{.*}}:(.data+0x0): relocation R_AARCH64_PREL32 cannot be used against shared object; recompile with -fPIC. +// CHECK: {{.*}}.o: relocation R_AARCH64_PREL32 cannot be used against shared object; recompile with -fPIC. +// CHECK-NEXT: note: location is (.data+0x0) .data .word foo - . Index: test/ELF/aarch64-fpic-prel64.s =================================================================== --- test/ELF/aarch64-fpic-prel64.s +++ test/ELF/aarch64-fpic-prel64.s @@ -1,7 +1,8 @@ // 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: {{.*}}:(.data+0x0): relocation R_AARCH64_PREL64 cannot be used against shared object; recompile with -fPIC. +// CHECK: {{.*}}: relocation R_AARCH64_PREL64 cannot be used against shared object; recompile with -fPIC. +// CHECK-NEXT: note: location is (.data+0x0) .data .xword foo - . Index: test/ELF/arm-branch-error.s =================================================================== --- test/ELF/arm-branch-error.s +++ test/ELF/arm-branch-error.s @@ -15,5 +15,8 @@ beq too_far3 // CHECK: R_ARM_CALL out of range +// CHECK-NEXT: note: location is (.text+0x0) // CHECK-NEXT: R_ARM_JUMP24 out of range +// CHECK-NEXT: note: location is (.text+0x4) // CHECK-NEXT: R_ARM_JUMP24 out of range +// CHECK-NEXT: note: location is (.text+0x8) Index: test/ELF/arm-target1.s =================================================================== --- test/ELF/arm-target1.s +++ test/ELF/arm-target1.s @@ -29,4 +29,5 @@ // 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: can't create dynamic relocation R_ARM_TARGET1 against symbol 'patatino' defined in {{.*}}.o +// ABS-NEXT: note: location is (.text+0x0) Index: test/ELF/arm-thumb-branch-error.s =================================================================== --- test/ELF/arm-thumb-branch-error.s +++ test/ELF/arm-thumb-branch-error.s @@ -14,6 +14,9 @@ b too_far2 beq.w too_far3 -// CHECK: R_ARM_THM_CALL out of range +// CHECK: R_ARM_THM_CALL out of range +// CHECK-NEXT: note: location is (.text+0x0) // CHECK-NEXT: R_ARM_THM_JUMP24 out of range +// CHECK-NEXT: note: location is (.text+0x4) // CHECK-NEXT: R_ARM_THM_JUMP19 out of range +// CHECK-NEXT: note: location is (.text+0x8) Index: test/ELF/basic.s =================================================================== --- test/ELF/basic.s +++ test/ELF/basic.s @@ -238,8 +238,10 @@ # 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: {{.*}}: duplicate symbol '_start' +# DUP-NEXT: note: definition found in (.text+0x0) +# DUP-NEXT: previous definition was here: {{.*}} +# DUP-NEXT: definition found in (.text+0x0) # 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 Index: test/ELF/conflict.s =================================================================== --- test/ELF/conflict.s +++ test/ELF/conflict.s @@ -3,18 +3,26 @@ # 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: error: {{.*}}: duplicate symbol 'mul(double, double)' +# DEMANGLE-NEXT: note: definition found in (.text+0x0) +# DEMANGLE-NEXT: previous definition was here: {{.*}} +# DEMANGLE-NEXT: definition found in (.text+0x0) +# DEMANGLE-NEXT: error: {{.*}}: duplicate symbol 'foo' +# DEMANGLE-NEXT: note: definition found in (.text+0x0) +# DEMANGLE-NEXT: previous definition was here: {{.*}} +# DEMANGLE-NEXT: definition found in (.text+0x0) # 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: error: {{.*}}: duplicate symbol '_Z3muldd' +# NO_DEMANGLE-NEXT: note: definition found in (.text+0x0) +# NO_DEMANGLE-NEXT: previous definition was here: {{.*}} +# NO_DEMANGLE-NEXT: definition found in (.text+0x0) +# NO_DEMANGLE-NEXT: error: {{.*}}: duplicate symbol 'foo' +# NO_DEMANGLE-NEXT: note: definition found in (.text+0x0) +# NO_DEMANGLE-NEXT: previous definition was here: {{.*}} +# NO_DEMANGLE-NEXT: definition found in (.text+0x0) # RUN: not ld.lld %t1.o %t1.o -o %t2 --demangle --no-demangle 2>&1 | \ # RUN: FileCheck -check-prefix=NO_DEMANGLE %s @@ -25,14 +33,28 @@ # 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): duplicate symbol 'foo' +# ARCHIVE-NEXT: note: definition found in (.text+0x0) +# ARCHIVE-NEXT: previous definition was here: {{.*}}1.o +# ARCHIVE-NEXT: definition found in (.text+0x0) # 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: {{.*}}.o: duplicate symbol 'zed' +# DBGINFO-NEXT: note: definition found in conflict-debug.s:4 +# DBGINFO-NEXT: previous definition was here: {{.*}}.o +# DBGINFO-NEXT: definition found in conflict-debug.s:4 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/conflict-debug2.s -o %t-dbg2.o +# RUN: echo "call zed" > %t-dbg1.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t-dbg1.s -o %t-dbg1.o +# RUN: llvm-ar rcs %t-dbg2.a %t-dbg2.o +# RUN: not ld.lld %t-dbg2.a %t-dbg1.o %t-dbg2.o -o %t2 2>&1 | FileCheck -check-prefix=ARCHIVE2 %s +# ARCHIVE2: {{.*}}-dbg2.o: duplicate symbol 'zed' +# ARCHIVE2: note: definition found in conflict-debug.s(.text+0x0) +# ARCHIVE2-NEXT: previous definition was here: {{.*}}-dbg2.a({{.*}}-dbg2.o) +# ARCHIVE2-NEXT: definition found in conflict-debug.s(.text+0x0) .globl _Z3muldd, foo _Z3muldd: Index: test/ELF/copy-errors.s =================================================================== --- test/ELF/copy-errors.s +++ test/ELF/copy-errors.s @@ -9,7 +9,8 @@ call bar -// CHECK: {{.*}}.o:(.text+0x1): cannot preempt symbol 'bar' defined in {{.*}}.so +// CHECK: {{.*}}.o: cannot preempt symbol 'bar' defined in {{.*}}.so +// CHECK-NEXT: note: location is (.text+0x1) call zed // CHECK: symbol 'zed' defined in {{.*}}.so is missing type Index: test/ELF/copy-in-shared.s =================================================================== --- test/ELF/copy-in-shared.s +++ test/ELF/copy-in-shared.s @@ -7,4 +7,5 @@ .quad foo -// CHECK: {{.*}}.o:(.text+0x0): can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.so +// CHECK: {{.*}}.o: can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.so +// CHECK-NEXT: note: location is (.text+0x0) Index: test/ELF/copy-rel-pie-error.s =================================================================== --- test/ELF/copy-rel-pie-error.s +++ test/ELF/copy-rel-pie-error.s @@ -3,8 +3,10 @@ // 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: can't create dynamic relocation R_X86_64_64 against symbol 'bar' defined in {{.*}}.so +// CHECK-NEXT: note: location is (.text+0x0) +// CHECK: {{.*}}.o: can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.so +// CHECK-NEXT: note: location is (.text+0x8) .global _start _start: Index: test/ELF/dynamic-reloc-in-ro.s =================================================================== --- test/ELF/dynamic-reloc-in-ro.s +++ test/ELF/dynamic-reloc-in-ro.s @@ -5,4 +5,5 @@ 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: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment defined in {{.*}}.o +// CHECK-NEXT: note: location is (.text+0x0) Index: test/ELF/eh-frame-dyn-rel.s =================================================================== --- test/ELF/eh-frame-dyn-rel.s +++ test/ELF/eh-frame-dyn-rel.s @@ -7,4 +7,5 @@ .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: can't create dynamic relocation R_X86_64_64 against symbol 'foo' defined in {{.*}}.o +// CHECK-NEXT: note: location is (.eh_frame+0x12) Index: test/ELF/invalid-cie-length.s =================================================================== --- test/ELF/invalid-cie-length.s +++ test/ELF/invalid-cie-length.s @@ -6,4 +6,5 @@ .section .eh_frame .byte 0 -// CHECK: {{.*}}:(.eh_frame+0x0): CIE/FDE too small +// CHECK: {{.*}}: CIE/FDE too small +// CHECK-NEXT: note: location is (.eh_frame+0x0) Index: test/ELF/invalid-cie-length2.s =================================================================== --- test/ELF/invalid-cie-length2.s +++ test/ELF/invalid-cie-length2.s @@ -6,4 +6,5 @@ .section .eh_frame .long 42 -// CHECK: {{.*}}:(.eh_frame+0x0): CIE/FDE ends past the end of the section +// CHECK: {{.*}}: CIE/FDE ends past the end of the section +// CHECK-NEXT: note: location is (.eh_frame+0x0) Index: test/ELF/invalid-cie-length3.s =================================================================== --- test/ELF/invalid-cie-length3.s +++ test/ELF/invalid-cie-length3.s @@ -6,4 +6,5 @@ .section .eh_frame .long 0xFFFFFFFC -// CHECK: {{.*}}:(.eh_frame+0x0): CIE/FDE ends past the end of the section +// CHECK: {{.*}}: CIE/FDE ends past the end of the section +// CHECK-NEXT: note: location is (.eh_frame+0x0) Index: test/ELF/invalid-cie-length4.s =================================================================== --- test/ELF/invalid-cie-length4.s +++ test/ELF/invalid-cie-length4.s @@ -7,4 +7,5 @@ .long 0xFFFFFFFF .byte 0 -// CHECK: {{.*}}:(.eh_frame+0x0): CIE/FDE too large +// CHECK: {{.*}}: CIE/FDE too large +// CHECK-NEXT: note: location is (.eh_frame+0x0) Index: test/ELF/libsearch.s =================================================================== --- test/ELF/libsearch.s +++ test/ELF/libsearch.s @@ -22,7 +22,8 @@ // 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: {{.*}}: undefined symbol '_bar' +// UNDEFINED-NEXT: note: location is (.bar+0x0) // Should fail if cannot find specified library (without -L switch) // RUN: not ld.lld -o %t3 %t.o -lls 2>&1 \ Index: test/ELF/linkerscript/edata-etext.s =================================================================== --- test/ELF/linkerscript/edata-etext.s +++ test/ELF/linkerscript/edata-etext.s @@ -2,9 +2,12 @@ # 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: {{.*}}: undefined symbol '_edata' +# CHECK-NEXT: note: location is (.text+0x0) +# CHECK-NEXT: error: {{.*}}: undefined symbol '_etext' +# CHECK-NEXT: note: location is (.text+0x8) +# CHECK-NEXT: error: {{.*}}: undefined symbol '_end' +# CHECK-NEXT: note: location is (.text+0x10) .global _start,_end,_etext,_edata .text Index: test/ELF/linkerscript/ehdr_start.s =================================================================== --- test/ELF/linkerscript/ehdr_start.s +++ test/ELF/linkerscript/ehdr_start.s @@ -3,7 +3,8 @@ # 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: {{.*}}: undefined symbol '__ehdr_start' +# CHECK-NEXT: note: location is (.text+0x0) .text .global _start, __ehdr_start Index: test/ELF/lto/combined-lto-object-name.ll =================================================================== --- test/ELF/lto/combined-lto-object-name.ll +++ test/ELF/lto/combined-lto-object-name.ll @@ -11,4 +11,5 @@ ret void } -; CHECK: error: ld-temp.o:(function _start): undefined symbol 'foo' +; CHECK: error: lto.tmp: undefined symbol 'foo' +; CHECK: note: location is ld-temp.o(function _start) Index: test/ELF/mips-align-err.s =================================================================== --- test/ELF/mips-align-err.s +++ test/ELF/mips-align-err.s @@ -4,7 +4,8 @@ # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mcpu=mips32r6 %S/Inputs/mips-align-err.s -o %t2.o # RUN: not ld.lld %t.o %t2.o -o %t.exe 2>&1 | FileCheck %s -# CHECK: {{.*}}:(.text+0x1): improper alignment for relocation R_MIPS_PC16 +# CHECK: {{.*}}: improper alignment for relocation R_MIPS_PC16 +# CHECK-NEXT: note: location is (.text+0x1) .globl __start __start: Index: test/ELF/non-abs-reloc.s =================================================================== --- test/ELF/non-abs-reloc.s +++ test/ELF/non-abs-reloc.s @@ -1,7 +1,8 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s -// CHECK: {{.*}}:(.dummy+0x0): has non-ABS reloc +// CHECK: {{.*}}: has non-ABS reloc +// CHECK-NEXT: note: location is (.dummy+0x0) .globl _start _start: Index: test/ELF/relocation-relative-absolute.s =================================================================== --- test/ELF/relocation-relative-absolute.s +++ test/ELF/relocation-relative-absolute.s @@ -7,6 +7,7 @@ .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: relocation R_X86_64_PLT32 cannot refer to absolute symbol 'answer' defined in {{.*}}input2.o +# CHECK-NEXT: note: location is (.text+0x1) call answer@PLT Index: test/ELF/sysroot.s =================================================================== --- test/ELF/sysroot.s +++ test/ELF/sysroot.s @@ -9,7 +9,8 @@ // 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: {{.*}}: undefined symbol '_bar' +// UNDEFINED-NEXT: note: location is (.text+0x1) // 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 \ Index: test/ELF/tls-static.s =================================================================== --- test/ELF/tls-static.s +++ test/ELF/tls-static.s @@ -10,4 +10,5 @@ _start: call __tls_get_addr -// CHECK: error: {{.*}}:(.text+0x1): undefined symbol '__tls_get_addr' +// CHECK: error: {{.*}}: undefined symbol '__tls_get_addr' +// CHECK-NEXT: note: location is (.text+0x1) Index: test/ELF/undef-shared.s =================================================================== --- test/ELF/undef-shared.s +++ test/ELF/undef-shared.s @@ -1,15 +1,18 @@ # 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: {{.*}}: undefined symbol 'hidden' +# CHECK-NEXT: note: location is (.data+0x0) .global hidden .hidden hidden -# CHECK: error: {{.*}}:(.data+0x8): undefined symbol 'internal' +# CHECK: error: {{.*}}: undefined symbol 'internal' +# CHECK-NEXT: note: location is (.data+0x8) .global internal .internal internal -# CHECK: error: {{.*}}:(.data+0x10): undefined symbol 'protected' +# CHECK: error: {{.*}}: undefined symbol 'protected' +# CHECK-NEXT: note: location is (.data+0x10) .global protected .protected protected Index: test/ELF/undef.s =================================================================== --- test/ELF/undef.s +++ test/ELF/undef.s @@ -5,17 +5,25 @@ # 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: dir{{/|\\}}undef-debug.s:3: undefined symbol 'zed3' -# CHECK: error: dir{{/|\\}}undef-debug.s:7: undefined symbol 'zed4' -# CHECK: error: dir{{/|\\}}undef-debug.s:11: undefined symbol 'zed5' +# CHECK: error: {{.*}}.o: undefined symbol 'foo' +# CHECK-NEXT: note: location is undef.s(.text+0x1) +# CHECK: error: {{.*}}.o: undefined symbol 'bar' +# CHECK-NEXT: note: location is undef.s(.text+0x6) +# CHECK: error: {{.*}}.o: undefined symbol 'foo(int)' +# CHECK-NEXT: note: location is undef.s(.text+0x10) +# CHECK: error: {{.*}}2.a({{.*}}.o): undefined symbol 'zed2' +# CHECK-NEXT: note: location is (.text+0x0) +# CHECK: error: {{.*}}.o: undefined symbol 'zed3' +# CHECK-NEXT: note: location is dir{{/|\\}}undef-debug.s:3 +# CHECK: error: {{.*}}.o: undefined symbol 'zed4' +# CHECK-NEXT: note: location is dir{{/|\\}}undef-debug.s:7 +# CHECK: error: {{.*}}.o: undefined symbol 'zed5' +# CHECK-NEXT: note: location is dir{{/|\\}}undef-debug.s:11 # 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: {{.*}}.o: undefined symbol '_Z3fooi' +# NO-DEMANGLE-NEXT: note: location is undef.s(.text+0x10) .file "undef.s" Index: test/ELF/unresolved-symbols.s =================================================================== --- test/ELF/unresolved-symbols.s +++ test/ELF/unresolved-symbols.s @@ -6,7 +6,8 @@ ## 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: undefined symbol 'undef' +# UNDCHECK-NEXT: note: location is (.text+0x1) ## 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 +20,8 @@ # 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: {{.*}}: undefined symbol 'undef' +# ERRUND-NEXT: note: location is (.text+0x1) ## 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 Index: test/ELF/verneed-local.s =================================================================== --- test/ELF/verneed-local.s +++ test/ELF/verneed-local.s @@ -2,7 +2,9 @@ # 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: {{.*}}: undefined symbol 'f3' +# CHECK-NEXT: note: location is (.text+0x1) + .globl _start _start: call f3 Index: test/ELF/warn-unresolved-symbols.s =================================================================== --- test/ELF/warn-unresolved-symbols.s +++ test/ELF/warn-unresolved-symbols.s @@ -31,10 +31,12 @@ # RUN: ld.lld -shared %t1.o -o %t10.so --warn-unresolved-symbols 2>&1 | \ # RUN: FileCheck -allow-empty -check-prefix=NOWARN %s -# ERRUND: error: {{.*}}:(.text+0x1): undefined symbol 'undef' -# WARNUND: warning: {{.*}}:(.text+0x1): undefined symbol 'undef' -# NOERR-NOT: error: {{.*}}:(.text+0x1): undefined symbol 'undef' -# NOWARN-NOT: warning: {{.*}}:(.text+0x1): undefined symbol 'undef' +# ERRUND: error: {{.*}}: undefined symbol 'undef' +# ERRUND-NEXT: note: location is (.text+0x1) +# WARNUND: warning: {{.*}}: undefined symbol 'undef' +# WARNUND-NEXT: note: location is (.text+0x1) +# NOERR-NOT: undefined symbol 'undef' +# NOWARN-NOT: undefined symbol 'undef' .globl _start _start: Index: test/ELF/x86-64-dyn-rel-error.s =================================================================== --- test/ELF/x86-64-dyn-rel-error.s +++ test/ELF/x86-64-dyn-rel-error.s @@ -9,4 +9,5 @@ .data .long bar -// CHECK: {{.*}}:(.data+0x0): relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC. +// CHECK: {{.*}}: relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC. +// CHECK-NEXT: note: location is (.data+0x0) Index: test/ELF/x86-64-dyn-rel-error2.s =================================================================== --- test/ELF/x86-64-dyn-rel-error2.s +++ test/ELF/x86-64-dyn-rel-error2.s @@ -9,4 +9,5 @@ .data .long bar - . -// CHECK: {{.*}}:(.data+0x0): relocation R_X86_64_PC32 cannot be used against shared object; recompile with -fPIC. +// CHECK: {{.*}}: relocation R_X86_64_PC32 cannot be used against shared object; recompile with -fPIC. +// CHECK-NEXT: note: location is (.data+0x0) Index: test/ELF/x86-64-reloc-32-fpic.s =================================================================== --- test/ELF/x86-64-reloc-32-fpic.s +++ test/ELF/x86-64-reloc-32-fpic.s @@ -1,7 +1,8 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o # RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s -# CHECK: {{.*}}:(.data+0x0): relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC. +# CHECK: {{.*}}: relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC. +# CHECK-NEXT: note: location is (.data+0x0) .data .long _shared Index: test/ELF/x86-64-reloc-error.s =================================================================== --- test/ELF/x86-64-reloc-error.s +++ test/ELF/x86-64-reloc-error.s @@ -6,5 +6,7 @@ movl $big, %edx movq $foo - 0x1000000000000, %rdx -# CHECK: {{.*}}:(.text+0x1): relocation R_X86_64_32 out of range -# CHECK: {{.*}}:(.text+0x8): relocation R_X86_64_32S out of range +# CHECK: {{.*}}: relocation R_X86_64_32 out of range +# CHECK-NEXT: note: location is (.text+0x1) +# CHECK-NEXT: {{.*}}: relocation R_X86_64_32S out of range +# CHECK-NEXT: note: location is (.text+0x8) Index: test/ELF/x86-64-reloc-pc32-fpic.s =================================================================== --- test/ELF/x86-64-reloc-pc32-fpic.s +++ test/ELF/x86-64-reloc-pc32-fpic.s @@ -1,7 +1,8 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o # RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s -# CHECK: {{.*}}:(.data+0x1): relocation R_X86_64_PC32 cannot be used against shared object; recompile with -fPIC. +# CHECK: {{.*}}: relocation R_X86_64_PC32 cannot be used against shared object; recompile with -fPIC. +# CHECK-NEXT: note: location is (.data+0x1) .data call _shared Index: test/ELF/x86-64-reloc-range.s =================================================================== --- test/ELF/x86-64-reloc-range.s +++ test/ELF/x86-64-reloc-range.s @@ -1,8 +1,9 @@ // RUN: llvm-mc %s -o %t.o -triple x86_64-pc-linux -filetype=obj // RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s -// CHECK: {{.*}}:(.text+0x3): relocation R_X86_64_PC32 out of range -// CHECK-NOT: relocation +// CHECK: {{.*}}: relocation R_X86_64_PC32 out of range +// CHECK-NEXT: note: location is (.text+0x3) +// CHECK-NOT: relocation lea foo(%rip), %rax lea foo(%rip), %rax Index: test/ELF/zdefs.s =================================================================== --- test/ELF/zdefs.s +++ test/ELF/zdefs.s @@ -2,6 +2,7 @@ # 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: {{.*}}: undefined symbol 'foo' +# ERR-NEXT: note: location is (.text+0x1) callq foo@PLT