<NME> lazy-arch-conflict.s
<BEF> ADDFILE
<MSG> [LLD][ELF] - Check the architecture of lazy objects earlier.

Our code in LazyObjFile::parse() has an ELFT switch and
adds a lazy object by its ELFT kind.
Though it might be possible to add a file using a different
architecture and make LLD to silently accept it (if the file
is empty or contains only week symbols). That itself, not a
huge issue perhaps (because the error would be reported later
if the file is fetched), but still does not look clean and correct.

It is possible to report an error earlier and clean up the
code. That is what the patch does.

Ideally, we might want to reuse isCompatible from SymbolTable.cpp,
but it is static and accepts a file as an argument, what is not
convenient. Since such a situation should be rare, I think it
should be OK to go with the way chosen in this patch.

Differential revision: https://reviews.llvm.org/D50899


git-svn-id: f6089bf0e6284f307027cef4f64114ee9ebb0424@340257 91177308-0d34-0410-b5e6-96231b3b80d8

<DFF> @@ -0,0 +1,7 @@
+# REQUIRES: x86
+
+# RUN: echo '.globl foo; .weak foo; .quad foo;' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t64.o
+# RUN: echo '.globl foo; foo:' | llvm-mc -filetype=obj -triple=i686-pc-linux - -o %t32.o
+# RUN: not ld.lld %t64.o --start-lib %t32.o --end-lib -o /dev/null 2>&1 | Filecheck %s
+
+# CHECK: error: incompatible file: {{.*}}32.o

{'addition_count': 7, 'commit_subject': '[LLD][ELF] - Check the architecture of lazy objects earlier.', 'deletion_count': 0, 'file_extension': '.s', 'lang': 's', 'license': 'apache-2.0', 'repo_name': 'llvm-mirror/lld'}