[PATCH] D88448: [ms] [llvm-ml] Use cleaner COFF symbol handling
Eric Astor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 14:17:19 PDT 2020
epastor created this revision.
epastor added reviewers: thakis, rnk.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
epastor requested review of this revision.
Rather than directly controlling the streamer, use MCSymbolCOFF's interface for type, etc.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88448
Files:
llvm/lib/MC/MCParser/COFFMasmParser.cpp
llvm/lib/MC/MCWinCOFFStreamer.cpp
Index: llvm/lib/MC/MCWinCOFFStreamer.cpp
===================================================================
--- llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -311,13 +311,11 @@
void MCWinCOFFStreamer::emitWeakReference(MCSymbol *AliasS,
const MCSymbol *Symbol) {
auto *Alias = cast<MCSymbolCOFF>(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,
Index: llvm/lib/MC/MCParser/COFFMasmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/COFFMasmParser.cpp
+++ 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 <cassert>
@@ -345,13 +346,11 @@
nextLoc = getTok().getLoc();
}
}
- MCSymbol *Sym = getContext().getOrCreateSymbol(Label);
+ MCSymbolCOFF *Sym = cast<MCSymbolCOFF>(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) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88448.294806.patch
Type: text/x-patch
Size: 2007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200928/a58eb04e/attachment.bin>
More information about the llvm-commits
mailing list