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:
Rafael Espindola 2010-12-22 16:03:00 +00:00
parent 4d74305a1f
commit f01212489b
2 changed files with 6 additions and 27 deletions

View File

@ -594,26 +594,15 @@ void ELFObjectWriter::WriteSymbol(MCDataFragment *SymtabF,
uint64_t Value = SymbolValue(Data, Layout);
uint64_t Size = 0;
const MCExpr *ESize;
assert(!(Data.isCommon() && !Data.isExternal()));
ESize = Data.getSize();
if (Data.getSize()) {
MCValue Res;
if (ESize->getKind() == MCExpr::Binary) {
const MCBinaryExpr *BE = static_cast<const MCBinaryExpr *>(ESize);
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");
}
const MCExpr *ESize = Data.getSize();
if (ESize) {
int64_t Res;
if (!ESize->EvaluateAsAbsolute(Res, Layout))
report_fatal_error("Size expression must be absolute.");
Size = Res;
}
// Write out the symbol table entry

View File

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