1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[COFF] [X86] Don't use llvm_unreachable for unsupported relocation types

This can happen if assembling a reference to _GLOBAL_OFFSET_TABLE_.

While it doesn't make sense to try to assemble that for COFF,
the fact that we previously used llvm_unreachable meant that the code
had undefined behaviour if something tried to assemble that.

The configure script of libgmp would try to assemble such a snippet
(which should signal a failure). If llvm is built without assertions,
the undefined behaviour meant a (near) infinite loop.

Differential Revision: https://reviews.llvm.org/D52903

llvm-svn: 343811
This commit is contained in:
Martin Storsjo 2018-10-04 20:43:38 +00:00
parent de79e7e9c8
commit 27aec8037f
2 changed files with 9 additions and 2 deletions

View File

@ -79,7 +79,8 @@ unsigned X86WinCOFFObjectWriter::getRelocType(MCContext &Ctx,
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 @@ unsigned X86WinCOFFObjectWriter::getRelocType(MCContext &Ctx,
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.");

View File

@ -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