Index: include/llvm/MC/MCObjectStreamer.h =================================================================== --- include/llvm/MC/MCObjectStreamer.h +++ include/llvm/MC/MCObjectStreamer.h @@ -154,6 +154,12 @@ unsigned Size) override; bool mayHaveInstructions(MCSection &Sec) const override; + + bool evaluateAsAbsolute(const MCExpr *Value, int64_t &Res) override { + MCDataFragment *DF = getOrCreateDataFragment(); + flushPendingLabels(DF, DF->getContents().size()); + return Value->evaluateAsAbsolute(Res, getAssembler()); + } }; } // end namespace llvm Index: include/llvm/MC/MCStreamer.h =================================================================== --- include/llvm/MC/MCStreamer.h +++ include/llvm/MC/MCStreamer.h @@ -772,6 +772,11 @@ void Finish(); virtual bool mayHaveInstructions(MCSection &Sec) const { return true; } + + /// \brief Try to evaluate the \p Value as an absolute value. + virtual bool evaluateAsAbsolute(const MCExpr *Value, int64_t &Res) { + return Value->evaluateAsAbsolute(Res); + } }; /// Create a dummy machine code streamer, which does nothing. This is useful for Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -1131,7 +1131,7 @@ if (parseExpression(Expr)) return true; - if (!Expr->evaluateAsAbsolute(Res)) + if (!getStreamer().evaluateAsAbsolute(Expr, Res)) return Error(StartLoc, "expected absolute expression"); return false; Index: test/MC/AsmParser/symbolic-expression.s =================================================================== --- /dev/null +++ test/MC/AsmParser/symbolic-expression.s @@ -0,0 +1,18 @@ +# RUN: llvm-mc -filetype=obj -triple=i386-unknown-elf %s | llvm-objdump -t - | FileCheck %s + +# CHECK: 00000000 .text 00000000 TEST0 +TEST0: + .fill 0x10 +# CHECK: 00000010 .text 00000000 TEST1 +TEST1: + .fill TEST1 - TEST0 + 0x5 +# CHECK: 00000025 .text 00000000 TEST2 +TEST2: + .zero TEST2 - (TEST1 + 0x5) +# CHECK: 00000035 .text 00000000 TEST3 +TEST3: + .align (TEST1 - TEST0) * 8 +# CHECK: 00000080 .text 00000000 TEST4 +TEST4: +# CHECK: 00000015 g *COM* 00000010 a + .comm a, TEST2 - TEST1, TEST1 - TEST0