mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 21:50:40 +00:00
Produce an error instead of asserting on invalid .sleb128/.uleb128.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
759015d80f
commit
49dba99a89
@ -94,7 +94,7 @@ public:
|
||||
bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const;
|
||||
bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout) const;
|
||||
|
||||
int64_t evaluateKnownAbsolute(const MCAsmLayout &Layout) const;
|
||||
bool evaluateKnownAbsolute(int64_t &Res, const MCAsmLayout &Layout) const;
|
||||
|
||||
/// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable
|
||||
/// value, i.e. an expression of the fixed form (a - b + constant).
|
||||
|
@ -1034,7 +1034,10 @@ bool MCAssembler::relaxInstruction(MCAsmLayout &Layout,
|
||||
|
||||
bool MCAssembler::relaxLEB(MCAsmLayout &Layout, MCLEBFragment &LF) {
|
||||
uint64_t OldSize = LF.getContents().size();
|
||||
int64_t Value = LF.getValue().evaluateKnownAbsolute(Layout);
|
||||
int64_t Value;
|
||||
bool Abs = LF.getValue().evaluateKnownAbsolute(Value, Layout);
|
||||
if (!Abs)
|
||||
report_fatal_error("sleb128 and uleb128 expressions must be absolute");
|
||||
SmallString<8> &Data = LF.getContents();
|
||||
Data.clear();
|
||||
raw_svector_ostream OSE(Data);
|
||||
@ -1050,7 +1053,9 @@ bool MCAssembler::relaxDwarfLineAddr(MCAsmLayout &Layout,
|
||||
MCDwarfLineAddrFragment &DF) {
|
||||
MCContext &Context = Layout.getAssembler().getContext();
|
||||
uint64_t OldSize = DF.getContents().size();
|
||||
int64_t AddrDelta = DF.getAddrDelta().evaluateKnownAbsolute(Layout);
|
||||
int64_t AddrDelta;
|
||||
bool Abs = DF.getAddrDelta().evaluateKnownAbsolute(AddrDelta, Layout);
|
||||
assert(Abs && "We created a line delta with an invalid expression");
|
||||
int64_t LineDelta;
|
||||
LineDelta = DF.getLineDelta();
|
||||
SmallString<8> &Data = DF.getContents();
|
||||
@ -1065,7 +1070,9 @@ bool MCAssembler::relaxDwarfCallFrameFragment(MCAsmLayout &Layout,
|
||||
MCDwarfCallFrameFragment &DF) {
|
||||
MCContext &Context = Layout.getAssembler().getContext();
|
||||
uint64_t OldSize = DF.getContents().size();
|
||||
int64_t AddrDelta = DF.getAddrDelta().evaluateKnownAbsolute(Layout);
|
||||
int64_t AddrDelta;
|
||||
bool Abs = DF.getAddrDelta().evaluateKnownAbsolute(AddrDelta, Layout);
|
||||
assert(Abs && "We created call frame with an invalid expression");
|
||||
SmallString<8> &Data = DF.getContents();
|
||||
Data.clear();
|
||||
raw_svector_ostream OSE(Data);
|
||||
|
@ -406,13 +406,10 @@ bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const {
|
||||
return EvaluateAsAbsolute(Res, &Asm, nullptr, nullptr);
|
||||
}
|
||||
|
||||
int64_t MCExpr::evaluateKnownAbsolute(const MCAsmLayout &Layout) const {
|
||||
int64_t Res;
|
||||
bool Abs =
|
||||
evaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout, nullptr, true);
|
||||
(void)Abs;
|
||||
assert(Abs && "Not actually absolute");
|
||||
return Res;
|
||||
bool MCExpr::evaluateKnownAbsolute(int64_t &Res,
|
||||
const MCAsmLayout &Layout) const {
|
||||
return evaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout, nullptr,
|
||||
true);
|
||||
}
|
||||
|
||||
bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
|
||||
|
5
test/MC/X86/invalid-sleb.s
Normal file
5
test/MC/X86/invalid-sleb.s
Normal file
@ -0,0 +1,5 @@
|
||||
// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t 2>&1 | FileCheck %s
|
||||
|
||||
// CHECK: sleb128 and uleb128 expressions must be absolute
|
||||
|
||||
.sleb128 undefined
|
Loading…
Reference in New Issue
Block a user