diff --git a/llvm/lib/MC/MCParser/COFFMasmParser.cpp b/llvm/lib/MC/MCParser/COFFMasmParser.cpp --- a/llvm/lib/MC/MCParser/COFFMasmParser.cpp +++ b/llvm/lib/MC/MCParser/COFFMasmParser.cpp @@ -21,6 +21,7 @@ #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSectionCOFF.h" #include "llvm/MC/MCStreamer.h" +#include "llvm/MC/MCSymbolCOFF.h" #include "llvm/MC/SectionKind.h" #include "llvm/Support/SMLoc.h" #include @@ -345,13 +346,11 @@ nextLoc = getTok().getLoc(); } } - MCSymbol *Sym = getContext().getOrCreateSymbol(Label); + MCSymbolCOFF *Sym = cast(getContext().getOrCreateSymbol(Label)); - // Define symbol as simple function - getStreamer().BeginCOFFSymbolDef(Sym); - getStreamer().EmitCOFFSymbolStorageClass(2); - getStreamer().EmitCOFFSymbolType(0x20); - getStreamer().EndCOFFSymbolDef(); + // Define symbol as simple external function + Sym->setExternal(true); + Sym->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT); bool Framed = false; if (getLexer().is(AsmToken::Identifier) && diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp --- a/llvm/lib/MC/MCWinCOFFStreamer.cpp +++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp @@ -311,13 +311,11 @@ void MCWinCOFFStreamer::emitWeakReference(MCSymbol *AliasS, const MCSymbol *Symbol) { auto *Alias = cast(AliasS); - Alias->setIsWeakExternal(); + emitSymbolAttribute(Alias, MCSA_Weak); - BeginCOFFSymbolDef(AliasS); - EmitCOFFSymbolStorageClass( - COFF::SymbolStorageClass::IMAGE_SYM_CLASS_WEAK_EXTERNAL); - EmitCOFFSymbolType(COFF::SymbolBaseType::IMAGE_SYM_TYPE_NULL); - EndCOFFSymbolDef(); + getAssembler().registerSymbol(*Symbol); + Alias->setVariableValue(MCSymbolRefExpr::create( + Symbol, MCSymbolRefExpr::VK_WEAKREF, getContext())); } void MCWinCOFFStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,