Reviewed by Rafael EspĂndola.
llvm-svn: 239312
--- /dev/null
+//===- MCSymbolCOFF.h - ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_MC_MCSYMBOLCOFF_H
+#define LLVM_MC_MCSYMBOLCOFF_H
+
+#include "llvm/MC/MCSymbol.h"
+#include "llvm/Support/COFF.h"
+
+namespace llvm {
+class MCSymbolCOFF : public MCSymbol {
+
+public:
+ MCSymbolCOFF(const StringMapEntry<bool> *Name, bool isTemporary)
+ : MCSymbol(SymbolKindCOFF, Name, isTemporary) {}
+
+ uint16_t getType() const {
+ return (getFlags() & COFF::SF_TypeMask) >> COFF::SF_TypeShift;
+ }
+ void setType(uint16_t Type) const {
+ modifyFlags(Type << COFF::SF_TypeShift, COFF::SF_TypeMask);
+ }
+
+ static bool classof(const MCSymbol *S) { return S->isCOFF(); }
+};
+}
+
+#endif
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCStreamer.h"
+#include "llvm/MC/MCSymbolCOFF.h"
#include "llvm/MC/MCSymbolELF.h"
#include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h"
MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
bool IsTemporary) {
- bool IsELF = MOFI && MOFI->getObjectFileType() == MCObjectFileInfo::IsELF;
- if (IsELF)
- return new (*this) MCSymbolELF(Name, IsTemporary);
+ if (MOFI) {
+ switch (MOFI->getObjectFileType()) {
+ case MCObjectFileInfo::IsCOFF:
+ return new (*this) MCSymbolCOFF(Name, IsTemporary);
+ case MCObjectFileInfo::IsELF:
+ return new (*this) MCSymbolELF(Name, IsTemporary);
+ case MCObjectFileInfo::IsMachO:
+ return new (*this) MCSymbol(MCSymbol::SymbolKindUnset, Name, IsTemporary);
+ }
+ }
return new (*this) MCSymbol(MCSymbol::SymbolKindUnset, Name, IsTemporary);
}
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionCOFF.h"
-#include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCSymbolCOFF.h"
#include "llvm/MC/MCValue.h"
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Support/COFF.h"
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
coff_symbol->Data.Value = getSymbolValue(Symbol, Layout);
- coff_symbol->Data.Type =
- (Symbol.getFlags() & COFF::SF_TypeMask) >> COFF::SF_TypeShift;
+ const MCSymbolCOFF &SymbolCOFF = cast<MCSymbolCOFF>(Symbol);
+ coff_symbol->Data.Type = SymbolCOFF.getType();
coff_symbol->Data.StorageClass =
(Symbol.getFlags() & COFF::SF_ClassMask) >> COFF::SF_ClassShift;
// MS LINK expects to be able to replace all references to a function with a
// thunk to implement their /INCREMENTAL feature. Make sure we don't optimize
// away any relocations to functions.
- if ((((SymA.getFlags() & COFF::SF_TypeMask) >> COFF::SF_TypeShift) >>
- COFF::SCT_COMPLEX_TYPE_SHIFT) == COFF::IMAGE_SYM_DTYPE_FUNCTION)
+ uint16_t Type = cast<MCSymbolCOFF>(SymA).getType();
+ if ((Type >> COFF::SCT_COMPLEX_TYPE_SHIFT) == COFF::IMAGE_SYM_DTYPE_FUNCTION)
return false;
return MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB,
InSet, IsPCRel);
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionCOFF.h"
#include "llvm/MC/MCStreamer.h"
-#include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCSymbolCOFF.h"
#include "llvm/MC/MCValue.h"
#include "llvm/MC/MCWinCOFFStreamer.h"
#include "llvm/Support/COFF.h"
FatalError("type value '" + Twine(Type) + "' out of range");
getAssembler().registerSymbol(*CurSymbol);
- CurSymbol->modifyFlags(Type << COFF::SF_TypeShift, COFF::SF_TypeMask);
+ cast<MCSymbolCOFF>(CurSymbol)->setType((uint16_t)Type);
}
void MCWinCOFFStreamer::EndCOFFSymbolDef() {