mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
Add a common error checking for some invalid expressions.
This refactors a bit of duplicated code and fixes an assertion failure on ELF. llvm-svn: 306035
This commit is contained in:
parent
acb1b94192
commit
5d34780d4b
@ -633,9 +633,6 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
|
||||
MCContext &Ctx = Asm.getContext();
|
||||
|
||||
if (const MCSymbolRefExpr *RefB = Target.getSymB()) {
|
||||
assert(RefB->getKind() == MCSymbolRefExpr::VK_None &&
|
||||
"Should not have constructed this");
|
||||
|
||||
// Let A, B and C being the components of Target and R be the location of
|
||||
// the fixup. If the fixup is not pcrel, we want to compute (A - B + C).
|
||||
// If it is pcrel, we want to compute (A - B + C - R).
|
||||
|
@ -193,14 +193,23 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
|
||||
// FIXME: This code has some duplication with recordRelocation. We should
|
||||
// probably merge the two into a single callback that tries to evaluate a
|
||||
// fixup and records a relocation if one is needed.
|
||||
|
||||
// On error claim to have completely evaluated the fixup, to prevent any
|
||||
// further processing from being done.
|
||||
const MCExpr *Expr = Fixup.getValue();
|
||||
MCContext &Ctx = getContext();
|
||||
Value = 0;
|
||||
if (!Expr->evaluateAsRelocatable(Target, &Layout, &Fixup)) {
|
||||
getContext().reportError(Fixup.getLoc(), "expected relocatable expression");
|
||||
// Claim to have completely evaluated the fixup, to prevent any further
|
||||
// processing from being done.
|
||||
Value = 0;
|
||||
Ctx.reportError(Fixup.getLoc(), "expected relocatable expression");
|
||||
return true;
|
||||
}
|
||||
if (const MCSymbolRefExpr *RefB = Target.getSymB()) {
|
||||
if (RefB->getKind() != MCSymbolRefExpr::VK_None) {
|
||||
Ctx.reportError(Fixup.getLoc(),
|
||||
"unsupported subtraction of qualified symbol");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsPCRel = Backend.getFixupKindInfo(
|
||||
Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsPCRel;
|
||||
|
@ -153,8 +153,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
||||
const MCSymbol *B_Base = Asm.getAtom(*B);
|
||||
|
||||
// Neither symbol can be modified.
|
||||
if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
|
||||
Target.getSymB()->getKind() != MCSymbolRefExpr::VK_None) {
|
||||
if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None) {
|
||||
Asm.getContext().reportError(Fixup.getLoc(),
|
||||
"unsupported relocation of modified symbol");
|
||||
return;
|
||||
|
@ -15,10 +15,10 @@ Lend:
|
||||
|
||||
add w0, w1, #(Lend - var@TLVPPAGEOFF)
|
||||
cmp w0, #(Lend - var@TLVPPAGEOFF)
|
||||
// CHECK: error: unknown AArch64 fixup kind!
|
||||
// CHECK: error: unsupported subtraction of qualified symbol
|
||||
// CHECK-NEXT: add w0, w1, #(Lend - var@TLVPPAGEOFF)
|
||||
// CHECK-NEXT: ^
|
||||
// CHECK: error: unknown AArch64 fixup kind!
|
||||
// CHECK: error: unsupported subtraction of qualified symbol
|
||||
// CHECK-NEXT: cmp w0, #(Lend - var@TLVPPAGEOFF)
|
||||
// CHECK-NEXT: ^
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o /dev/null 2>%t
|
||||
// RUN: FileCheck --input-file=%t %s
|
||||
|
||||
// CHECK: symbol '__executable_start' can not be undefined in a subtraction expression
|
||||
|
||||
.data
|
||||
x:
|
||||
// CHECK: [[@LINE+1]]:{{[0-9]+}}: error: symbol '__executable_start' can not be undefined in a subtraction expression
|
||||
.quad x-__executable_start
|
||||
|
||||
// CHECK: [[@LINE+1]]:{{[0-9]+}}: error: unsupported subtraction of qualified symbol
|
||||
.long bar - foo@got
|
||||
foo:
|
||||
|
@ -10,7 +10,7 @@
|
||||
mov %rax, thing@TLVP
|
||||
|
||||
// CHECK-ERROR: 3:9: error: 32-bit absolute addressing is not supported in 64-bit mode
|
||||
// CHECK-ERROR: 4:9: error: unsupported relocation of modified symbol
|
||||
// CHECK-ERROR: 4:9: error: unsupported subtraction of qualified symbol
|
||||
// CHECK-ERROR: 5:9: error: unsupported pc-relative relocation of difference
|
||||
// CHECK-ERROR: 6:9: error: unsupported relocation with identical base
|
||||
// CHECK-ERROR: 7:9: error: unsupported relocation with subtraction expression, symbol 'thing' can not be undefined in a subtraction expression
|
||||
|
Loading…
Reference in New Issue
Block a user