MC: permit emitting a symbol value as section relative
[oota-llvm.git] / lib / MC / MCStreamer.cpp
index f3564027bf31c2fdce9440d0a47e0cd66ea627d5..46e80cc0c0d8e97c7787657190139793e9da24c4 100644 (file)
@@ -148,8 +148,15 @@ void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size,
   EmitValueImpl(Value, Size, Loc);
 }
 
-void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size) {
-  EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size);
+void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
+                                 bool IsSectionRelative) {
+  assert((!IsSectionRelative || Size == 4) &&
+         "SectionRelative value requires 4-bytes");
+
+  if (!IsSectionRelative)
+    EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size);
+  else
+    EmitCOFFSecRel32(Sym);
 }
 
 void MCStreamer::EmitGPRel64Value(const MCExpr *Value) {