diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index bb523cefedc..b6e1223bc41 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -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(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(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 diff --git a/test/MC/ELF/size.s b/test/MC/ELF/size.s deleted file mode 100644 index ceb9486c302..00000000000 --- a/test/MC/ELF/size.s +++ /dev/null @@ -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