[lld] r324041 - Don't accept unsuitable ELF files such as executables or core files.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 1 16:27:49 PST 2018
Author: ruiu
Date: Thu Feb 1 16:27:49 2018
New Revision: 324041
URL: http://llvm.org/viewvc/llvm-project?rev=324041&view=rev
Log:
Don't accept unsuitable ELF files such as executables or core files.
Differential Revision: https://reviews.llvm.org/D42827
Added:
lld/trunk/test/ELF/invalid/executable.s
Removed:
lld/trunk/test/ELF/invalid/Inputs/too-short.elf
lld/trunk/test/ELF/invalid/too-short.s
Modified:
lld/trunk/ELF/Driver.cpp
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=324041&r1=324040&r2=324041&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Feb 1 16:27:49 2018
@@ -228,11 +228,15 @@ void LinkerDriver::addFile(StringRef Pat
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<LazyObjFile>(MBRef, "", 0));
else
Files.push_back(createObjectFile(MBRef));
+ break;
+ default:
+ error(Path + ": unknown file type");
}
}
Removed: lld/trunk/test/ELF/invalid/Inputs/too-short.elf
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/Inputs/too-short.elf?rev=324040&view=auto
==============================================================================
Binary file - no diff available.
Added: lld/trunk/test/ELF/invalid/executable.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/executable.s?rev=324041&view=auto
==============================================================================
--- lld/trunk/test/ELF/invalid/executable.s (added)
+++ lld/trunk/test/ELF/invalid/executable.s Thu Feb 1 16:27:49 2018
@@ -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
Removed: lld/trunk/test/ELF/invalid/too-short.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/too-short.s?rev=324040&view=auto
==============================================================================
--- lld/trunk/test/ELF/invalid/too-short.s (original)
+++ lld/trunk/test/ELF/invalid/too-short.s (removed)
@@ -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
More information about the llvm-commits
mailing list