Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -644,14 +644,31 @@ Symbols.push_back(createSymbol(KeptComdats, *Obj, Sym)); } -template +// 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 static void checkCompatibility(InputFile *FileP) { + auto *F = dyn_cast>(FileP); + assert(F && "file compatibility check for zero pointer is performed"); + if (F->getELFKind() == Config->EKind && F->getEMachine() == Config->EMachine) + return; + StringRef A = F->getName(); + StringRef B = Config->Emulation; + if (B.empty()) + B = Config->FirstElf->getName(); + error(A + " is incompatible with " + B); +} + +template