ELF2: Include file names in error messages.

llvm-svn: 248724
This commit is contained in:
Rui Ueyama 2015-09-28 18:20:41 +00:00
parent 68b591079a
commit c5e22d906b
2 changed files with 4 additions and 4 deletions

View File

@ -221,7 +221,7 @@ std::unique_ptr<ELFFileBase> createELFFile(MemoryBufferRef MB) {
std::pair<unsigned char, unsigned char> Type = std::pair<unsigned char, unsigned char> Type =
object::getElfArchType(MB.getBuffer()); object::getElfArchType(MB.getBuffer());
if (Type.second != ELF::ELFDATA2LSB && Type.second != ELF::ELFDATA2MSB) if (Type.second != ELF::ELFDATA2LSB && Type.second != ELF::ELFDATA2MSB)
error("Invalid data encoding"); error("Invalid data encoding: " + MB.getBufferIdentifier());
if (Type.first == ELF::ELFCLASS32) { if (Type.first == ELF::ELFCLASS32) {
if (Type.second == ELF::ELFDATA2LSB) if (Type.second == ELF::ELFDATA2LSB)
@ -233,7 +233,7 @@ std::unique_ptr<ELFFileBase> createELFFile(MemoryBufferRef MB) {
return make_unique<T<object::ELF64LE>>(MB); return make_unique<T<object::ELF64LE>>(MB);
return make_unique<T<object::ELF64BE>>(MB); return make_unique<T<object::ELF64BE>>(MB);
} }
error("Invalid file class"); error("Invalid file class: " + MB.getBufferIdentifier());
} }
} // namespace elf2 } // namespace elf2

View File

@ -1,10 +1,10 @@
RUN: not lld -flavor gnu2 %p/Inputs/invalid-data-encoding.elf -o %t2 2>&1 | \ RUN: not lld -flavor gnu2 %p/Inputs/invalid-data-encoding.elf -o %t2 2>&1 | \
RUN: FileCheck --check-prefix=INVALID-DATA-ENC %s RUN: FileCheck --check-prefix=INVALID-DATA-ENC %s
INVALID-DATA-ENC: Invalid data encoding INVALID-DATA-ENC: Invalid data encoding: {{.*}}/invalid-data-encoding.elf
RUN: not lld -flavor gnu2 %p/Inputs/invalid-file-class.elf -o %t2 2>&1 | \ RUN: not lld -flavor gnu2 %p/Inputs/invalid-file-class.elf -o %t2 2>&1 | \
RUN: FileCheck --check-prefix=INVALID-FILE-CLASS %s RUN: FileCheck --check-prefix=INVALID-FILE-CLASS %s
INVALID-FILE-CLASS: Invalid file class INVALID-FILE-CLASS: Invalid file class: {{.*}}/invalid-file-class.elf
RUN: not lld -flavor gnu2 %p/Inputs/invalid-symtab-sh_info.elf -o %t2 2>&1 | \ RUN: not lld -flavor gnu2 %p/Inputs/invalid-symtab-sh_info.elf -o %t2 2>&1 | \
RUN: FileCheck --check-prefix=INVALID-SYMTAB-SHINFO %s RUN: FileCheck --check-prefix=INVALID-SYMTAB-SHINFO %s