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:
parent
de79e7e9c8
commit
27aec8037f
@ -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.");
|
||||
|
5
test/MC/COFF/unsupported-relocations.s
Normal file
5
test/MC/COFF/unsupported-relocations.s
Normal 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
|
Loading…
Reference in New Issue
Block a user