1 //===- MCSymbolCOFF.h - ----------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_MC_MCSYMBOLCOFF_H 10 #define LLVM_MC_MCSYMBOLCOFF_H 11 12 #include "llvm/BinaryFormat/COFF.h" 13 #include "llvm/MC/MCSymbol.h" 14 #include "llvm/MC/MCSymbolTableEntry.h" 15 #include <cstdint> 16 17 namespace llvm { 18 19 class MCSymbolCOFF : public MCSymbol { 20 /// This corresponds to the e_type field of the COFF symbol. 21 mutable uint16_t Type = 0; 22 23 enum SymbolFlags : uint16_t { 24 SF_ClassMask = 0x00FF, 25 SF_ClassShift = 0, 26 27 SF_SafeSEH = 0x0100, 28 SF_WeakExternalCharacteristicsMask = 0x0E00, 29 SF_WeakExternalCharacteristicsShift = 9, 30 }; 31 32 public: MCSymbolCOFF(const MCSymbolTableEntry * Name,bool isTemporary)33 MCSymbolCOFF(const MCSymbolTableEntry *Name, bool isTemporary) 34 : MCSymbol(SymbolKindCOFF, Name, isTemporary) {} 35 getType()36 uint16_t getType() const { 37 return Type; 38 } setType(uint16_t Ty)39 void setType(uint16_t Ty) const { 40 Type = Ty; 41 } 42 getClass()43 uint16_t getClass() const { 44 return (getFlags() & SF_ClassMask) >> SF_ClassShift; 45 } setClass(uint16_t StorageClass)46 void setClass(uint16_t StorageClass) const { 47 modifyFlags(StorageClass << SF_ClassShift, SF_ClassMask); 48 } 49 getWeakExternalCharacteristics()50 COFF::WeakExternalCharacteristics getWeakExternalCharacteristics() const { 51 return static_cast<COFF::WeakExternalCharacteristics>((getFlags() & SF_WeakExternalCharacteristicsMask) >> 52 SF_WeakExternalCharacteristicsShift); 53 } setWeakExternalCharacteristics(COFF::WeakExternalCharacteristics Characteristics)54 void setWeakExternalCharacteristics(COFF::WeakExternalCharacteristics Characteristics) const { 55 modifyFlags(Characteristics << SF_WeakExternalCharacteristicsShift, 56 SF_WeakExternalCharacteristicsMask); 57 } setIsWeakExternal(bool WeakExt)58 void setIsWeakExternal(bool WeakExt) const { 59 IsWeakExternal = WeakExt; 60 } 61 isSafeSEH()62 bool isSafeSEH() const { 63 return getFlags() & SF_SafeSEH; 64 } setIsSafeSEH()65 void setIsSafeSEH() const { 66 modifyFlags(SF_SafeSEH, SF_SafeSEH); 67 } 68 classof(const MCSymbol * S)69 static bool classof(const MCSymbol *S) { return S->isCOFF(); } 70 }; 71 72 } // end namespace llvm 73 74 #endif // LLVM_MC_MCSYMBOLCOFF_H 75