mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-13 01:15:32 +00:00
Simplify the handling of .size expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122404 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4d74305a1f
commit
f01212489b
@ -594,26 +594,15 @@ void ELFObjectWriter::WriteSymbol(MCDataFragment *SymtabF,
|
|||||||
|
|
||||||
uint64_t Value = SymbolValue(Data, Layout);
|
uint64_t Value = SymbolValue(Data, Layout);
|
||||||
uint64_t Size = 0;
|
uint64_t Size = 0;
|
||||||
const MCExpr *ESize;
|
|
||||||
|
|
||||||
assert(!(Data.isCommon() && !Data.isExternal()));
|
assert(!(Data.isCommon() && !Data.isExternal()));
|
||||||
|
|
||||||
ESize = Data.getSize();
|
const MCExpr *ESize = Data.getSize();
|
||||||
if (Data.getSize()) {
|
if (ESize) {
|
||||||
MCValue Res;
|
int64_t Res;
|
||||||
if (ESize->getKind() == MCExpr::Binary) {
|
if (!ESize->EvaluateAsAbsolute(Res, Layout))
|
||||||
const MCBinaryExpr *BE = static_cast<const MCBinaryExpr *>(ESize);
|
report_fatal_error("Size expression must be absolute.");
|
||||||
|
Size = Res;
|
||||||
if (BE->EvaluateAsRelocatable(Res, &Layout)) {
|
|
||||||
assert(!Res.getSymA() || !Res.getSymA()->getSymbol().isDefined());
|
|
||||||
assert(!Res.getSymB() || !Res.getSymB()->getSymbol().isDefined());
|
|
||||||
Size = Res.getConstant();
|
|
||||||
}
|
|
||||||
} else if (ESize->getKind() == MCExpr::Constant) {
|
|
||||||
Size = static_cast<const MCConstantExpr *>(ESize)->getValue();
|
|
||||||
} else {
|
|
||||||
assert(0 && "Unsupported size expression");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write out the symbol table entry
|
// Write out the symbol table entry
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
|
|
||||||
|
|
||||||
// Mostly a test that this doesn't crash anymore.
|
|
||||||
|
|
||||||
// CHECK: # Symbol 0x00000004
|
|
||||||
// CHECK-NEXT: (('st_name', 0x00000001) # 'foo'
|
|
||||||
// CHECK-NEXT: ('st_bind', 0x00000001)
|
|
||||||
|
|
||||||
.size foo, .Lbar-foo
|
|
||||||
.long foo
|
|
Loading…
x
Reference in New Issue
Block a user