[lld] r287753 - [ELF] Refactor several error messages
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 23 02:07:47 PST 2016
Author: evgeny777
Date: Wed Nov 23 04:07:46 2016
New Revision: 287753
URL: http://llvm.org/viewvc/llvm-project?rev=287753&view=rev
Log:
[ELF] Refactor several error messages
Differential revision: https://reviews.llvm.org/D26970
Added:
lld/trunk/test/ELF/non-abs-reloc.s
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/invalid/invalid-elf.test
lld/trunk/test/ELF/merge-string-error.s
lld/trunk/test/ELF/relocation-past-merge-end.s
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=287753&r1=287752&r2=287753&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Nov 23 04:07:46 2016
@@ -773,12 +773,12 @@ static InputFile *createELFFile(MemoryBu
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(MemoryBu
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;
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=287753&r1=287752&r2=287753&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Nov 23 04:07:46 2016
@@ -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 InputSectio
// 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>::relocateNonAllo
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;
}
Modified: lld/trunk/test/ELF/invalid/invalid-elf.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-elf.test?rev=287753&r1=287752&r2=287753&view=diff
==============================================================================
--- lld/trunk/test/ELF/invalid/invalid-elf.test (original)
+++ lld/trunk/test/ELF/invalid/invalid-elf.test Wed Nov 23 04:07:46 2016
@@ -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
Modified: lld/trunk/test/ELF/merge-string-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/merge-string-error.s?rev=287753&r1=287752&r2=287753&view=diff
==============================================================================
--- lld/trunk/test/ELF/merge-string-error.s (original)
+++ lld/trunk/test/ELF/merge-string-error.s Wed Nov 23 04:07:46 2016
@@ -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
Added: lld/trunk/test/ELF/non-abs-reloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/non-abs-reloc.s?rev=287753&view=auto
==============================================================================
--- lld/trunk/test/ELF/non-abs-reloc.s (added)
+++ lld/trunk/test/ELF/non-abs-reloc.s Wed Nov 23 04:07:46 2016
@@ -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 at gotpcrel
Modified: lld/trunk/test/ELF/relocation-past-merge-end.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-past-merge-end.s?rev=287753&r1=287752&r2=287753&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocation-past-merge-end.s (original)
+++ lld/trunk/test/ELF/relocation-past-merge-end.s Wed Nov 23 04:07:46 2016
@@ -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
More information about the llvm-commits
mailing list