Index: lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp =================================================================== --- lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp +++ lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp @@ -79,7 +79,8 @@ case FK_SecRel_4: return COFF::IMAGE_REL_AMD64_SECREL; default: - llvm_unreachable("unsupported relocation type"); + Ctx.reportError(Fixup.getLoc(), "unsupported relocation type"); + return COFF::IMAGE_REL_AMD64_ADDR32; } } else if (getMachine() == COFF::IMAGE_FILE_MACHINE_I386) { switch (FixupKind) { @@ -100,7 +101,8 @@ case FK_SecRel_4: return COFF::IMAGE_REL_I386_SECREL; default: - llvm_unreachable("unsupported relocation type"); + Ctx.reportError(Fixup.getLoc(), "unsupported relocation type"); + return COFF::IMAGE_REL_I386_DIR32; } } else llvm_unreachable("Unsupported COFF machine type."); Index: test/MC/COFF/unsupported-relocations.s =================================================================== --- /dev/null +++ test/MC/COFF/unsupported-relocations.s @@ -0,0 +1,5 @@ +// RUN: not llvm-mc -filetype=obj -triple i386-pc-win32 %s 2>&1 | FileCheck %s +// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-win32 %s 2>&1 | FileCheck %s +// CHECK: unsupported relocation type + .text + mov $_GLOBAL_OFFSET_TABLE_, %eax