[PATCH] D42827: Don't accept unsuitable ELF files such as executables or core files.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 16:32:23 PST 2018


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD324041: Don't accept unsuitable ELF files such as executables or core files. (authored by ruiu, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42827?vs=132499&id=132506#toc

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D42827

Files:
  ELF/Driver.cpp
  test/ELF/invalid/Inputs/too-short.elf
  test/ELF/invalid/executable.s
  test/ELF/invalid/too-short.s


Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -228,11 +228,15 @@
     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");
   }
 }
 
Index: test/ELF/invalid/executable.s
===================================================================
--- test/ELF/invalid/executable.s
+++ 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
Index: test/ELF/invalid/too-short.s
===================================================================
--- test/ELF/invalid/too-short.s
+++ test/ELF/invalid/too-short.s
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42827.132506.patch
Type: text/x-patch
Size: 1321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180202/b33fa05b/attachment-0001.bin>


More information about the llvm-commits mailing list