1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Simplify the handling of .size expressions.

llvm-svn: 122404
This commit is contained in:
Rafael Espindola 2010-12-22 16:03:00 +00:00
parent 17e19b2d45
commit 7c995a90fc
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