diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 4b7f90253f2a..f63340e9bd43 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -228,11 +228,15 @@ void LinkerDriver::addFile(StringRef Path, bool WithLOption) { Files.push_back( createSharedFile(MBRef, WithLOption ? path::filename(Path) : Path)); return; - default: + case file_magic::bitcode: + case file_magic::elf_relocatable: if (InLib) Files.push_back(make(MBRef, "", 0)); else Files.push_back(createObjectFile(MBRef)); + break; + default: + error(Path + ": unknown file type"); } } diff --git a/lld/test/ELF/invalid/Inputs/too-short.elf b/lld/test/ELF/invalid/Inputs/too-short.elf deleted file mode 100644 index 077f392f1dc4..000000000000 Binary files a/lld/test/ELF/invalid/Inputs/too-short.elf and /dev/null differ diff --git a/lld/test/ELF/invalid/executable.s b/lld/test/ELF/invalid/executable.s new file mode 100644 index 000000000000..33ef564adc5c --- /dev/null +++ b/lld/test/ELF/invalid/executable.s @@ -0,0 +1,9 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld -o %t1.exe %t.o +# RUN: not ld.lld -o %t2.exe %t1.exe 2>&1 | FileCheck %s +# CHECK: unknown file type + +.global _start +_start: + ret diff --git a/lld/test/ELF/invalid/too-short.s b/lld/test/ELF/invalid/too-short.s deleted file mode 100644 index deaf8218d6e0..000000000000 --- a/lld/test/ELF/invalid/too-short.s +++ /dev/null @@ -1,5 +0,0 @@ -# REQUIRES: x86 - -## too-short.elf file is a truncated ELF. -# RUN: not ld.lld %S/Inputs/too-short.elf -o %t 2>&1 | FileCheck %s -# CHECK: file is too short