diff options
author | Eugene Leviant <eleviant@accesssoftek.com> | 2016-11-23 10:07:46 +0000 |
---|---|---|
committer | Eugene Leviant <eleviant@accesssoftek.com> | 2016-11-23 10:07:46 +0000 |
commit | c3a44b2fbea997c3b814d4beace4d85f5eee524e (patch) | |
tree | 6eff2aa31cf26e5fe0859b332d758b5a35d8a4cc | |
parent | 48ac304c8ebc3c924bf427fcdad49ba9a3eb7ab1 (diff) | |
download | bcm5719-llvm-c3a44b2fbea997c3b814d4beace4d85f5eee524e.tar.gz bcm5719-llvm-c3a44b2fbea997c3b814d4beace4d85f5eee524e.zip |
[ELF] Refactor several error messages
Differential revision: https://reviews.llvm.org/D26970
llvm-svn: 287753
-rw-r--r-- | lld/ELF/InputFiles.cpp | 6 | ||||
-rw-r--r-- | lld/ELF/InputSection.cpp | 5 | ||||
-rw-r--r-- | lld/test/ELF/invalid/invalid-elf.test | 4 | ||||
-rw-r--r-- | lld/test/ELF/merge-string-error.s | 2 | ||||
-rw-r--r-- | lld/test/ELF/non-abs-reloc.s | 11 | ||||
-rw-r--r-- | lld/test/ELF/relocation-past-merge-end.s | 2 |
6 files changed, 21 insertions, 9 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index f697fd25de1..fb290490db1 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -773,12 +773,12 @@ static InputFile *createELFFile(MemoryBufferRef MB) { unsigned char Endian; std::tie(Size, Endian) = getElfArchType(MB.getBuffer()); if (Endian != ELFDATA2LSB && Endian != ELFDATA2MSB) - fatal("invalid data encoding: " + MB.getBufferIdentifier()); + fatal(MB.getBufferIdentifier() + ": invalid data encoding"); size_t BufSize = MB.getBuffer().size(); if ((Size == ELFCLASS32 && BufSize < sizeof(Elf32_Ehdr)) || (Size == ELFCLASS64 && BufSize < sizeof(Elf64_Ehdr))) - fatal("file is too short"); + fatal(MB.getBufferIdentifier() + ": file is too short"); InputFile *Obj; if (Size == ELFCLASS32 && Endian == ELFDATA2LSB) @@ -790,7 +790,7 @@ static InputFile *createELFFile(MemoryBufferRef MB) { else if (Size == ELFCLASS64 && Endian == ELFDATA2MSB) Obj = make<T<ELF64BE>>(MB); else - fatal("invalid file class: " + MB.getBufferIdentifier()); + fatal(MB.getBufferIdentifier() + ": invalid file class"); if (!Config->FirstElf) Config->FirstElf = Obj; diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 27d1033b2ec..77247897bc5 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -15,6 +15,7 @@ #include "LinkerScript.h" #include "Memory.h" #include "OutputSections.h" +#include "Relocations.h" #include "SyntheticSections.h" #include "Target.h" #include "Thunks.h" @@ -97,7 +98,7 @@ template <class ELFT> size_t InputSectionBase<ELFT>::getSize() const { // Returns a string for an error message. template <class SectionT> static std::string getName(SectionT *Sec) { - return (Sec->getFile()->getName() + "(" + Sec->Name + ")").str(); + return (Sec->getFile()->getName() + ":(" + Sec->Name + ")").str(); } template <class ELFT> @@ -455,7 +456,7 @@ void InputSection<ELFT>::relocateNonAlloc(uint8_t *Buf, ArrayRef<RelTy> Rels) { SymbolBody &Sym = this->File->getRelocTargetSym(Rel); if (Target->getRelExpr(Type, Sym) != R_ABS) { - error(getName(this) + " has non-ABS reloc"); + error(getLocation(*this, Offset) + ": has non-ABS reloc"); return; } diff --git a/lld/test/ELF/invalid/invalid-elf.test b/lld/test/ELF/invalid/invalid-elf.test index d49ab2f3cac..e03450ed289 100644 --- a/lld/test/ELF/invalid/invalid-elf.test +++ b/lld/test/ELF/invalid/invalid-elf.test @@ -2,11 +2,11 @@ # RUN: not ld.lld %t %p/Inputs/data-encoding.a -o %t2 2>&1 | \ # RUN: FileCheck --check-prefix=INVALID-DATA-ENC %s -# INVALID-DATA-ENC: invalid data encoding: test.o +# INVALID-DATA-ENC: test.o: invalid data encoding # RUN: not ld.lld %t %p/Inputs/file-class.a -o %t2 2>&1 | \ # RUN: FileCheck --check-prefix=INVALID-FILE-CLASS %s -# INVALID-FILE-CLASS: invalid file class: test.o +# INVALID-FILE-CLASS: test.o: invalid file class # RUN: not ld.lld %p/Inputs/symtab-sh_info.elf -o %t2 2>&1 | \ # RUN: FileCheck --check-prefix=INVALID-SYMTAB-SHINFO %s diff --git a/lld/test/ELF/merge-string-error.s b/lld/test/ELF/merge-string-error.s index 3a985232537..78895cecca9 100644 --- a/lld/test/ELF/merge-string-error.s +++ b/lld/test/ELF/merge-string-error.s @@ -8,4 +8,4 @@ .data .long .rodata.str1.1 + 4 -// CHECK: merge-string-error.s.tmp.o(.rodata.str1.1): entry is past the end of the section +// CHECK: merge-string-error.s.tmp.o:(.rodata.str1.1): entry is past the end of the section diff --git a/lld/test/ELF/non-abs-reloc.s b/lld/test/ELF/non-abs-reloc.s new file mode 100644 index 00000000000..ef9ba446613 --- /dev/null +++ b/lld/test/ELF/non-abs-reloc.s @@ -0,0 +1,11 @@ +// 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 + +.globl _start +_start: + nop + +.section .dummy + .long foo@gotpcrel diff --git a/lld/test/ELF/relocation-past-merge-end.s b/lld/test/ELF/relocation-past-merge-end.s index 0900d0e7d4d..d08bde7b9f6 100644 --- a/lld/test/ELF/relocation-past-merge-end.s +++ b/lld/test/ELF/relocation-past-merge-end.s @@ -1,7 +1,7 @@ // REQUIRES: x86 // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux // RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s -// CHECK: relocation-past-merge-end.s.tmp.o(.foo): entry is past the end of the section +// CHECK: relocation-past-merge-end.s.tmp.o:(.foo): entry is past the end of the section .data .long .foo + 10 |