Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 1 | //===-- llvm/MC/WinCOFFStreamer.cpp -----------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains an implementation of a Win32 COFF object file streamer. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #define DEBUG_TYPE "WinCOFFStreamer" |
| 15 | |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 16 | #include "llvm/MC/MCStreamer.h" |
Evan Cheng | 78c10ee | 2011-07-25 23:24:55 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCAsmBackend.h" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCAsmLayout.h" |
| 19 | #include "llvm/MC/MCAssembler.h" |
| 20 | #include "llvm/MC/MCCodeEmitter.h" |
| 21 | #include "llvm/MC/MCContext.h" |
| 22 | #include "llvm/MC/MCExpr.h" |
| 23 | #include "llvm/MC/MCObjectStreamer.h" |
| 24 | #include "llvm/MC/MCSection.h" |
| 25 | #include "llvm/MC/MCSectionCOFF.h" |
| 26 | #include "llvm/MC/MCSymbol.h" |
| 27 | #include "llvm/MC/MCValue.h" |
| 28 | #include "llvm/MC/MCWin64EH.h" |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 29 | #include "llvm/Support/COFF.h" |
| 30 | #include "llvm/Support/Debug.h" |
| 31 | #include "llvm/Support/ErrorHandling.h" |
Evan Cheng | 3e74d6f | 2011-08-24 18:08:43 +0000 | [diff] [blame] | 32 | #include "llvm/Support/TargetRegistry.h" |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 33 | #include "llvm/Support/raw_ostream.h" |
Rafael Espindola | 8f7d12c | 2011-12-17 01:14:52 +0000 | [diff] [blame] | 34 | |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 35 | using namespace llvm; |
| 36 | |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 37 | namespace { |
| 38 | class WinCOFFStreamer : public MCObjectStreamer { |
| 39 | public: |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 40 | MCSymbol const *CurSymbol; |
| 41 | |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 42 | WinCOFFStreamer(MCContext &Context, |
Evan Cheng | 78c10ee | 2011-07-25 23:24:55 +0000 | [diff] [blame] | 43 | MCAsmBackend &MAB, |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 44 | MCCodeEmitter &CE, |
| 45 | raw_ostream &OS); |
| 46 | |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 47 | void AddCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 48 | unsigned ByteAlignment, bool External); |
| 49 | |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 50 | // MCStreamer interface |
| 51 | |
Rafael Espindola | d80781b | 2010-09-15 21:48:40 +0000 | [diff] [blame] | 52 | virtual void InitSections(); |
Eli Bendersky | 030f63a | 2013-01-14 19:04:57 +0000 | [diff] [blame] | 53 | virtual void InitToTextSection(); |
Rafael Espindola | ba21024 | 2010-11-28 16:22:59 +0000 | [diff] [blame] | 54 | virtual void EmitLabel(MCSymbol *Symbol); |
Reed Kotler | 2c3a464 | 2012-12-16 04:00:45 +0000 | [diff] [blame] | 55 | virtual void EmitDebugLabel(MCSymbol *Symbol); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 56 | virtual void EmitAssemblerFlag(MCAssemblerFlag Flag); |
Jim Grosbach | ce79299 | 2010-11-05 22:08:08 +0000 | [diff] [blame] | 57 | virtual void EmitThumbFunc(MCSymbol *Func); |
Saleem Abdulrasool | 1c9cd02 | 2013-08-09 01:52:03 +0000 | [diff] [blame^] | 58 | virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 59 | virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue); |
| 60 | virtual void BeginCOFFSymbolDef(MCSymbol const *Symbol); |
| 61 | virtual void EmitCOFFSymbolStorageClass(int StorageClass); |
| 62 | virtual void EmitCOFFSymbolType(int Type); |
| 63 | virtual void EndCOFFSymbolDef(); |
Rafael Espindola | 8f7d12c | 2011-12-17 01:14:52 +0000 | [diff] [blame] | 64 | virtual void EmitCOFFSecRel32(MCSymbol const *Symbol); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 65 | virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value); |
| 66 | virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 67 | unsigned ByteAlignment); |
Benjamin Kramer | 36a1601 | 2011-09-01 23:04:27 +0000 | [diff] [blame] | 68 | virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 69 | unsigned ByteAlignment); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 70 | virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol, |
Evan Cheng | c90a1fc | 2012-06-22 20:14:46 +0000 | [diff] [blame] | 71 | uint64_t Size,unsigned ByteAlignment); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 72 | virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 73 | uint64_t Size, unsigned ByteAlignment); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 74 | virtual void EmitFileDirective(StringRef Filename); |
Charles Davis | 3185f5c | 2011-05-22 03:01:05 +0000 | [diff] [blame] | 75 | virtual void EmitWin64EHHandlerData(); |
Rafael Espindola | 99b4237 | 2012-01-07 03:13:18 +0000 | [diff] [blame] | 76 | virtual void FinishImpl(); |
Michael J. Spencer | 192d136 | 2010-10-09 15:44:27 +0000 | [diff] [blame] | 77 | |
Chandler Carruth | 5da3665 | 2013-01-31 23:29:57 +0000 | [diff] [blame] | 78 | static bool classof(const MCStreamer *S) { |
| 79 | return S->getKind() == SK_WinCOFFStreamer; |
| 80 | } |
| 81 | |
Michael J. Spencer | 192d136 | 2010-10-09 15:44:27 +0000 | [diff] [blame] | 82 | private: |
Rafael Espindola | f89671d | 2010-11-01 16:27:31 +0000 | [diff] [blame] | 83 | virtual void EmitInstToData(const MCInst &Inst) { |
Michael J. Spencer | f94cfb6 | 2013-01-03 01:09:22 +0000 | [diff] [blame] | 84 | MCDataFragment *DF = getOrCreateDataFragment(); |
| 85 | |
| 86 | SmallVector<MCFixup, 4> Fixups; |
| 87 | SmallString<256> Code; |
| 88 | raw_svector_ostream VecOS(Code); |
| 89 | getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, Fixups); |
| 90 | VecOS.flush(); |
| 91 | |
| 92 | // Add the fixups and data. |
| 93 | for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { |
| 94 | Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size()); |
| 95 | DF->getFixups().push_back(Fixups[i]); |
| 96 | } |
| 97 | DF->getContents().append(Code.begin(), Code.end()); |
Rafael Espindola | f89671d | 2010-11-01 16:27:31 +0000 | [diff] [blame] | 98 | } |
| 99 | |
Michael J. Spencer | 192d136 | 2010-10-09 15:44:27 +0000 | [diff] [blame] | 100 | void SetSection(StringRef Section, |
| 101 | unsigned Characteristics, |
| 102 | SectionKind Kind) { |
| 103 | SwitchSection(getContext().getCOFFSection(Section, Characteristics, Kind)); |
| 104 | } |
| 105 | |
| 106 | void SetSectionText() { |
| 107 | SetSection(".text", |
| 108 | COFF::IMAGE_SCN_CNT_CODE |
| 109 | | COFF::IMAGE_SCN_MEM_EXECUTE |
| 110 | | COFF::IMAGE_SCN_MEM_READ, |
| 111 | SectionKind::getText()); |
| 112 | EmitCodeAlignment(4, 0); |
| 113 | } |
| 114 | |
| 115 | void SetSectionData() { |
| 116 | SetSection(".data", |
| 117 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
| 118 | | COFF::IMAGE_SCN_MEM_READ |
| 119 | | COFF::IMAGE_SCN_MEM_WRITE, |
| 120 | SectionKind::getDataRel()); |
| 121 | EmitCodeAlignment(4, 0); |
| 122 | } |
| 123 | |
| 124 | void SetSectionBSS() { |
| 125 | SetSection(".bss", |
| 126 | COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
| 127 | | COFF::IMAGE_SCN_MEM_READ |
| 128 | | COFF::IMAGE_SCN_MEM_WRITE, |
| 129 | SectionKind::getBSS()); |
| 130 | EmitCodeAlignment(4, 0); |
| 131 | } |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 132 | }; |
| 133 | } // end anonymous namespace. |
| 134 | |
Chandler Carruth | 5da3665 | 2013-01-31 23:29:57 +0000 | [diff] [blame] | 135 | WinCOFFStreamer::WinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB, |
| 136 | MCCodeEmitter &CE, raw_ostream &OS) |
| 137 | : MCObjectStreamer(SK_WinCOFFStreamer, Context, MAB, OS, &CE), |
| 138 | CurSymbol(NULL) {} |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 139 | |
| 140 | void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 141 | unsigned ByteAlignment, bool External) { |
| 142 | assert(!Symbol->isInSection() && "Symbol must not already have a section!"); |
| 143 | |
| 144 | std::string SectionName(".bss$linkonce"); |
| 145 | SectionName.append(Symbol->getName().begin(), Symbol->getName().end()); |
| 146 | |
| 147 | MCSymbolData &SymbolData = getAssembler().getOrCreateSymbolData(*Symbol); |
| 148 | |
| 149 | unsigned Characteristics = |
| 150 | COFF::IMAGE_SCN_LNK_COMDAT | |
| 151 | COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA | |
| 152 | COFF::IMAGE_SCN_MEM_READ | |
| 153 | COFF::IMAGE_SCN_MEM_WRITE; |
| 154 | |
| 155 | int Selection = COFF::IMAGE_COMDAT_SELECT_LARGEST; |
| 156 | |
| 157 | const MCSection *Section = MCStreamer::getContext().getCOFFSection( |
Nico Rieck | 8064628 | 2013-07-06 12:13:10 +0000 | [diff] [blame] | 158 | SectionName, Characteristics, SectionKind::getBSS(), Selection); |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 159 | |
| 160 | MCSectionData &SectionData = getAssembler().getOrCreateSectionData(*Section); |
| 161 | |
| 162 | if (SectionData.getAlignment() < ByteAlignment) |
| 163 | SectionData.setAlignment(ByteAlignment); |
| 164 | |
| 165 | SymbolData.setExternal(External); |
| 166 | |
| 167 | Symbol->setSection(*Section); |
| 168 | |
| 169 | if (ByteAlignment != 1) |
| 170 | new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, &SectionData); |
| 171 | |
| 172 | SymbolData.setFragment(new MCFillFragment(0, 0, Size, &SectionData)); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | // MCStreamer interface |
| 176 | |
Eli Bendersky | 030f63a | 2013-01-14 19:04:57 +0000 | [diff] [blame] | 177 | void WinCOFFStreamer::InitToTextSection() { |
| 178 | SetSectionText(); |
| 179 | } |
| 180 | |
Rafael Espindola | d80781b | 2010-09-15 21:48:40 +0000 | [diff] [blame] | 181 | void WinCOFFStreamer::InitSections() { |
Michael J. Spencer | 192d136 | 2010-10-09 15:44:27 +0000 | [diff] [blame] | 182 | SetSectionText(); |
| 183 | SetSectionData(); |
| 184 | SetSectionBSS(); |
| 185 | SetSectionText(); |
Rafael Espindola | d80781b | 2010-09-15 21:48:40 +0000 | [diff] [blame] | 186 | } |
| 187 | |
Rafael Espindola | ba21024 | 2010-11-28 16:22:59 +0000 | [diff] [blame] | 188 | void WinCOFFStreamer::EmitLabel(MCSymbol *Symbol) { |
Rafael Espindola | ba21024 | 2010-11-28 16:22:59 +0000 | [diff] [blame] | 189 | assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); |
Rafael Espindola | ea4afa9 | 2010-11-28 17:18:55 +0000 | [diff] [blame] | 190 | MCObjectStreamer::EmitLabel(Symbol); |
Rafael Espindola | ba21024 | 2010-11-28 16:22:59 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Reed Kotler | 2c3a464 | 2012-12-16 04:00:45 +0000 | [diff] [blame] | 193 | void WinCOFFStreamer::EmitDebugLabel(MCSymbol *Symbol) { |
| 194 | EmitLabel(Symbol); |
| 195 | } |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 196 | void WinCOFFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 197 | llvm_unreachable("not implemented"); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 198 | } |
| 199 | |
Jim Grosbach | ce79299 | 2010-11-05 22:08:08 +0000 | [diff] [blame] | 200 | void WinCOFFStreamer::EmitThumbFunc(MCSymbol *Func) { |
| 201 | llvm_unreachable("not implemented"); |
| 202 | } |
| 203 | |
Saleem Abdulrasool | 1c9cd02 | 2013-08-09 01:52:03 +0000 | [diff] [blame^] | 204 | bool WinCOFFStreamer::EmitSymbolAttribute(MCSymbol *Symbol, |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 205 | MCSymbolAttr Attribute) { |
Michael J. Spencer | d47f4a9 | 2010-10-09 11:00:37 +0000 | [diff] [blame] | 206 | assert(Symbol && "Symbol must be non-null!"); |
| 207 | assert((Symbol->isInSection() |
| 208 | ? Symbol->getSection().getVariant() == MCSection::SV_COFF |
| 209 | : true) && "Got non COFF section in the COFF backend!"); |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 210 | switch (Attribute) { |
| 211 | case MCSA_WeakReference: |
Michael J. Spencer | 4cee289 | 2010-10-16 08:25:57 +0000 | [diff] [blame] | 212 | case MCSA_Weak: { |
| 213 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
| 214 | SD.modifyFlags(COFF::SF_WeakExternal, COFF::SF_WeakExternal); |
| 215 | SD.setExternal(true); |
| 216 | } |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 217 | break; |
| 218 | |
| 219 | case MCSA_Global: |
| 220 | getAssembler().getOrCreateSymbolData(*Symbol).setExternal(true); |
| 221 | break; |
| 222 | |
| 223 | default: |
Saleem Abdulrasool | 1c9cd02 | 2013-08-09 01:52:03 +0000 | [diff] [blame^] | 224 | return false; |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 225 | } |
Saleem Abdulrasool | 1c9cd02 | 2013-08-09 01:52:03 +0000 | [diff] [blame^] | 226 | |
| 227 | return true; |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | void WinCOFFStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 231 | llvm_unreachable("not implemented"); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | void WinCOFFStreamer::BeginCOFFSymbolDef(MCSymbol const *Symbol) { |
Michael J. Spencer | d47f4a9 | 2010-10-09 11:00:37 +0000 | [diff] [blame] | 235 | assert((Symbol->isInSection() |
| 236 | ? Symbol->getSection().getVariant() == MCSection::SV_COFF |
| 237 | : true) && "Got non COFF section in the COFF backend!"); |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 238 | assert(CurSymbol == NULL && "EndCOFFSymbolDef must be called between calls " |
| 239 | "to BeginCOFFSymbolDef!"); |
| 240 | CurSymbol = Symbol; |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | void WinCOFFStreamer::EmitCOFFSymbolStorageClass(int StorageClass) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 244 | assert(CurSymbol != NULL && "BeginCOFFSymbolDef must be called first!"); |
| 245 | assert((StorageClass & ~0xFF) == 0 && "StorageClass must only have data in " |
| 246 | "the first byte!"); |
| 247 | |
| 248 | getAssembler().getOrCreateSymbolData(*CurSymbol).modifyFlags( |
| 249 | StorageClass << COFF::SF_ClassShift, |
| 250 | COFF::SF_ClassMask); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | void WinCOFFStreamer::EmitCOFFSymbolType(int Type) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 254 | assert(CurSymbol != NULL && "BeginCOFFSymbolDef must be called first!"); |
| 255 | assert((Type & ~0xFFFF) == 0 && "Type must only have data in the first 2 " |
| 256 | "bytes"); |
| 257 | |
| 258 | getAssembler().getOrCreateSymbolData(*CurSymbol).modifyFlags( |
| 259 | Type << COFF::SF_TypeShift, |
| 260 | COFF::SF_TypeMask); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | void WinCOFFStreamer::EndCOFFSymbolDef() { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 264 | assert(CurSymbol != NULL && "BeginCOFFSymbolDef must be called first!"); |
| 265 | CurSymbol = NULL; |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 266 | } |
| 267 | |
Rafael Espindola | 8f7d12c | 2011-12-17 01:14:52 +0000 | [diff] [blame] | 268 | void WinCOFFStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) |
| 269 | { |
| 270 | MCDataFragment *DF = getOrCreateDataFragment(); |
| 271 | |
Eli Bendersky | 64d9a32 | 2012-12-07 19:13:57 +0000 | [diff] [blame] | 272 | DF->getFixups().push_back( |
| 273 | MCFixup::Create(DF->getContents().size(), |
| 274 | MCSymbolRefExpr::Create (Symbol, getContext ()), |
| 275 | FK_SecRel_4)); |
Rafael Espindola | 8f7d12c | 2011-12-17 01:14:52 +0000 | [diff] [blame] | 276 | DF->getContents().resize(DF->getContents().size() + 4, 0); |
| 277 | } |
| 278 | |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 279 | void WinCOFFStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 280 | llvm_unreachable("not implemented"); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | void WinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 284 | unsigned ByteAlignment) { |
Michael J. Spencer | d47f4a9 | 2010-10-09 11:00:37 +0000 | [diff] [blame] | 285 | assert((Symbol->isInSection() |
| 286 | ? Symbol->getSection().getVariant() == MCSection::SV_COFF |
| 287 | : true) && "Got non COFF section in the COFF backend!"); |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 288 | AddCommonSymbol(Symbol, Size, ByteAlignment, true); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 289 | } |
| 290 | |
Benjamin Kramer | 36a1601 | 2011-09-01 23:04:27 +0000 | [diff] [blame] | 291 | void WinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 292 | unsigned ByteAlignment) { |
Michael J. Spencer | d47f4a9 | 2010-10-09 11:00:37 +0000 | [diff] [blame] | 293 | assert((Symbol->isInSection() |
| 294 | ? Symbol->getSection().getVariant() == MCSection::SV_COFF |
| 295 | : true) && "Got non COFF section in the COFF backend!"); |
Benjamin Kramer | 36a1601 | 2011-09-01 23:04:27 +0000 | [diff] [blame] | 296 | AddCommonSymbol(Symbol, Size, ByteAlignment, false); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | void WinCOFFStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, |
Evan Cheng | c90a1fc | 2012-06-22 20:14:46 +0000 | [diff] [blame] | 300 | uint64_t Size,unsigned ByteAlignment) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 301 | llvm_unreachable("not implemented"); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | void WinCOFFStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, |
| 305 | uint64_t Size, unsigned ByteAlignment) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 306 | llvm_unreachable("not implemented"); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 307 | } |
| 308 | |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 309 | void WinCOFFStreamer::EmitFileDirective(StringRef Filename) { |
| 310 | // Ignore for now, linkers don't care, and proper debug |
| 311 | // info will be a much large effort. |
| 312 | } |
| 313 | |
Charles Davis | 3185f5c | 2011-05-22 03:01:05 +0000 | [diff] [blame] | 314 | void WinCOFFStreamer::EmitWin64EHHandlerData() { |
| 315 | MCStreamer::EmitWin64EHHandlerData(); |
| 316 | |
| 317 | // We have to emit the unwind info now, because this directive |
| 318 | // actually switches to the .xdata section! |
| 319 | MCWin64EHUnwindEmitter::EmitUnwindInfo(*this, getCurrentW64UnwindInfo()); |
| 320 | } |
| 321 | |
Rafael Espindola | 99b4237 | 2012-01-07 03:13:18 +0000 | [diff] [blame] | 322 | void WinCOFFStreamer::FinishImpl() { |
Charles Davis | 38ea9ee | 2011-05-22 04:15:07 +0000 | [diff] [blame] | 323 | EmitW64Tables(); |
Rafael Espindola | 99b4237 | 2012-01-07 03:13:18 +0000 | [diff] [blame] | 324 | MCObjectStreamer::FinishImpl(); |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | namespace llvm |
| 328 | { |
| 329 | MCStreamer *createWinCOFFStreamer(MCContext &Context, |
Evan Cheng | 78c10ee | 2011-07-25 23:24:55 +0000 | [diff] [blame] | 330 | MCAsmBackend &MAB, |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 331 | MCCodeEmitter &CE, |
Michael J. Spencer | e2195d8 | 2010-07-31 06:22:29 +0000 | [diff] [blame] | 332 | raw_ostream &OS, |
| 333 | bool RelaxAll) { |
Evan Cheng | 78c10ee | 2011-07-25 23:24:55 +0000 | [diff] [blame] | 334 | WinCOFFStreamer *S = new WinCOFFStreamer(Context, MAB, CE, OS); |
Michael J. Spencer | e2195d8 | 2010-07-31 06:22:29 +0000 | [diff] [blame] | 335 | S->getAssembler().setRelaxAll(RelaxAll); |
| 336 | return S; |
Chris Lattner | eb72dca | 2010-07-11 22:05:00 +0000 | [diff] [blame] | 337 | } |
| 338 | } |