aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2016-06-29 09:46:00 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2016-06-29 09:46:00 +0000
commit4371250a7ee5ab5fde2929e99f68c2c59d8c2683 (patch)
tree36d89e90262b1f6f2dd8e8b0707cd3452d227d5c
parentcbe9851d306f3c31ecd3643c1dab931a0e06b4c1 (diff)
[ELF] - Check the input bitcode files for compatibility.
Previously BC files were not checked for the same platform etc, That lead to confusing error "Invalid section header entry size (e_shentsize) in ELF header" when mixing files for different architectures. Patch fixes PR28324. Differential revision: http://reviews.llvm.org/D21832 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@274113 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--ELF/SymbolTable.cpp5
-rw-r--r--test/ELF/lto/mix-platforms.ll10
2 files changed, 12 insertions, 3 deletions
diff --git a/ELF/SymbolTable.cpp b/ELF/SymbolTable.cpp
index e5052281c..ab5ff8b78 100644
--- a/ELF/SymbolTable.cpp
+++ b/ELF/SymbolTable.cpp
@@ -33,9 +33,8 @@ using namespace lld::elf;
// All input object files must be for the same architecture
// (e.g. it does not make sense to link x86 object files with
// MIPS object files.) This function checks for that error.
-template <class ELFT> static bool isCompatible(InputFile *FileP) {
- auto *F = dyn_cast<ELFFileBase<ELFT>>(FileP);
- if (!F)
+template <class ELFT> static bool isCompatible(InputFile *F) {
+ if (!isa<ELFFileBase<ELFT>>(F) && !isa<BitcodeFile>(F))
return true;
if (F->EKind == Config->EKind && F->EMachine == Config->EMachine)
return true;
diff --git a/test/ELF/lto/mix-platforms.ll b/test/ELF/lto/mix-platforms.ll
new file mode 100644
index 000000000..b4a892f0a
--- /dev/null
+++ b/test/ELF/lto/mix-platforms.ll
@@ -0,0 +1,10 @@
+; REQUIRES: x86
+; RUN: llvm-mc %p/Inputs/shared.s -o %t386.o -filetype=obj -triple=i386-pc-linux
+; RUN: ld.lld %t386.o -o %ti386.so -shared
+; RUN: llvm-as %s -o %tx64.o
+; RUN: not ld.lld %ti386.so %tx64.o -o %t 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: {{.*}}x64.o is incompatible with {{.*}}i386.so