Nick Lewycky | c1f9694 | 2013-03-09 09:31:44 +0000 | [diff] [blame] | 1 | //===- lib/MC/MCELFStreamer.cpp - ELF Object Output -----------------------===// |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 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 assembles .s files and emits ELF .o object files. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Logan Chien | 59ff070 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCELFStreamer.h" |
Peter Collingbourne | adac407 | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/STLExtras.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/SmallPtrSet.h" |
David Peixotto | 7266731 | 2013-11-25 19:11:13 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCAsmBackend.h" |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCAsmLayout.h" |
Rafael Espindola | 7b61ddf | 2014-10-15 16:12:52 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCAsmInfo.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCAssembler.h" |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCCodeEmitter.h" |
Rafael Espindola | 81a6274 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 22 | #include "llvm/MC/MCContext.h" |
Tim Northover | 5cc3dc8 | 2012-12-07 16:50:23 +0000 | [diff] [blame] | 23 | #include "llvm/MC/MCELF.h" |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 24 | #include "llvm/MC/MCELFSymbolFlags.h" |
| 25 | #include "llvm/MC/MCExpr.h" |
| 26 | #include "llvm/MC/MCInst.h" |
Rafael Espindola | e308c0c | 2014-01-23 22:49:25 +0000 | [diff] [blame] | 27 | #include "llvm/MC/MCObjectFileInfo.h" |
Rafael Espindola | 81a6274 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 28 | #include "llvm/MC/MCObjectStreamer.h" |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 29 | #include "llvm/MC/MCSection.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 30 | #include "llvm/MC/MCSectionELF.h" |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 31 | #include "llvm/MC/MCSymbol.h" |
Rafael Espindola | 1614597 | 2010-11-01 14:28:48 +0000 | [diff] [blame] | 32 | #include "llvm/MC/MCValue.h" |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 33 | #include "llvm/Support/Debug.h" |
| 34 | #include "llvm/Support/ELF.h" |
| 35 | #include "llvm/Support/ErrorHandling.h" |
Rafael Espindola | cd584a8 | 2015-03-19 01:50:16 +0000 | [diff] [blame] | 36 | #include "llvm/Support/TargetRegistry.h" |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 37 | #include "llvm/Support/raw_ostream.h" |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 38 | |
| 39 | using namespace llvm; |
| 40 | |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 41 | bool MCELFStreamer::isBundleLocked() const { |
Rafael Espindola | 983bec6 | 2015-05-27 21:04:14 +0000 | [diff] [blame] | 42 | return getCurrentSectionOnly()->isBundleLocked(); |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Logan Chien | 59ff070 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 45 | MCELFStreamer::~MCELFStreamer() { |
Rafael Espindola | 81a6274 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 48 | void MCELFStreamer::mergeFragment(MCDataFragment *DF, |
| 49 | MCEncodedFragmentWithFixups *EF) { |
| 50 | MCAssembler &Assembler = getAssembler(); |
| 51 | |
| 52 | if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) { |
| 53 | uint64_t FSize = EF->getContents().size(); |
| 54 | |
| 55 | if (FSize > Assembler.getBundleAlignSize()) |
| 56 | report_fatal_error("Fragment can't be larger than a bundle size"); |
| 57 | |
| 58 | uint64_t RequiredBundlePadding = computeBundlePadding( |
| 59 | Assembler, EF, DF->getContents().size(), FSize); |
| 60 | |
| 61 | if (RequiredBundlePadding > UINT8_MAX) |
| 62 | report_fatal_error("Padding cannot exceed 255 bytes"); |
| 63 | |
| 64 | if (RequiredBundlePadding > 0) { |
| 65 | SmallString<256> Code; |
| 66 | raw_svector_ostream VecOS(Code); |
| 67 | MCObjectWriter *OW = Assembler.getBackend().createObjectWriter(VecOS); |
| 68 | |
| 69 | EF->setBundlePadding(static_cast<uint8_t>(RequiredBundlePadding)); |
| 70 | |
| 71 | Assembler.writeFragmentPadding(*EF, FSize, OW); |
| 72 | VecOS.flush(); |
| 73 | delete OW; |
| 74 | |
| 75 | DF->getContents().append(Code.begin(), Code.end()); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | flushPendingLabels(DF, DF->getContents().size()); |
| 80 | |
| 81 | for (unsigned i = 0, e = EF->getFixups().size(); i != e; ++i) { |
| 82 | EF->getFixups()[i].setOffset(EF->getFixups()[i].getOffset() + |
| 83 | DF->getContents().size()); |
| 84 | DF->getFixups().push_back(EF->getFixups()[i]); |
| 85 | } |
| 86 | DF->setHasInstructions(true); |
| 87 | DF->getContents().append(EF->getContents().begin(), EF->getContents().end()); |
| 88 | } |
| 89 | |
Rafael Espindola | 7b61ddf | 2014-10-15 16:12:52 +0000 | [diff] [blame] | 90 | void MCELFStreamer::InitSections(bool NoExecStack) { |
Rafael Espindola | f667d92 | 2010-09-15 21:48:40 +0000 | [diff] [blame] | 91 | // This emulates the same behavior of GNU as. This makes it easier |
| 92 | // to compare the output as the major sections are in the same order. |
Rafael Espindola | 7b61ddf | 2014-10-15 16:12:52 +0000 | [diff] [blame] | 93 | MCContext &Ctx = getContext(); |
| 94 | SwitchSection(Ctx.getObjectFileInfo()->getTextSection()); |
Rafael Espindola | 7b51496 | 2014-02-04 18:34:04 +0000 | [diff] [blame] | 95 | EmitCodeAlignment(4); |
Rafael Espindola | 247f951 | 2014-01-24 02:18:40 +0000 | [diff] [blame] | 96 | |
Rafael Espindola | 7b61ddf | 2014-10-15 16:12:52 +0000 | [diff] [blame] | 97 | SwitchSection(Ctx.getObjectFileInfo()->getDataSection()); |
Rafael Espindola | 7b51496 | 2014-02-04 18:34:04 +0000 | [diff] [blame] | 98 | EmitCodeAlignment(4); |
Rafael Espindola | 247f951 | 2014-01-24 02:18:40 +0000 | [diff] [blame] | 99 | |
Rafael Espindola | 7b61ddf | 2014-10-15 16:12:52 +0000 | [diff] [blame] | 100 | SwitchSection(Ctx.getObjectFileInfo()->getBSSSection()); |
Rafael Espindola | 7b51496 | 2014-02-04 18:34:04 +0000 | [diff] [blame] | 101 | EmitCodeAlignment(4); |
Rafael Espindola | 247f951 | 2014-01-24 02:18:40 +0000 | [diff] [blame] | 102 | |
Rafael Espindola | 7b61ddf | 2014-10-15 16:12:52 +0000 | [diff] [blame] | 103 | SwitchSection(Ctx.getObjectFileInfo()->getTextSection()); |
| 104 | |
| 105 | if (NoExecStack) |
| 106 | SwitchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx)); |
Rafael Espindola | f667d92 | 2010-09-15 21:48:40 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 109 | void MCELFStreamer::EmitLabel(MCSymbol *Symbol) { |
Rafael Espindola | 1679580 | 2010-11-28 16:22:59 +0000 | [diff] [blame] | 110 | assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); |
| 111 | |
Rafael Espindola | e5b7415 | 2010-11-28 17:18:55 +0000 | [diff] [blame] | 112 | MCObjectStreamer::EmitLabel(Symbol); |
Rafael Espindola | 75d65b9 | 2010-09-25 05:42:19 +0000 | [diff] [blame] | 113 | |
Rafael Espindola | 84d0318 | 2010-11-11 19:04:55 +0000 | [diff] [blame] | 114 | const MCSectionELF &Section = |
| 115 | static_cast<const MCSectionELF&>(Symbol->getSection()); |
Rafael Espindola | 0e7e34e | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 116 | if (Section.getFlags() & ELF::SHF_TLS) |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 117 | MCELF::SetType(*Symbol, ELF::STT_TLS); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { |
David Peixotto | 7266731 | 2013-11-25 19:11:13 +0000 | [diff] [blame] | 121 | // Let the target do whatever target specific stuff it needs to do. |
| 122 | getAssembler().getBackend().handleAssemblerFlag(Flag); |
| 123 | // Do any generic stuff we need to do. |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 124 | switch (Flag) { |
Jim Grosbach | 5a2c68d | 2010-11-05 22:08:08 +0000 | [diff] [blame] | 125 | case MCAF_SyntaxUnified: return; // no-op here. |
Evan Cheng | 481ebb0 | 2011-07-27 00:38:12 +0000 | [diff] [blame] | 126 | case MCAF_Code16: return; // Change parsing mode; no-op here. |
| 127 | case MCAF_Code32: return; // Change parsing mode; no-op here. |
| 128 | case MCAF_Code64: return; // Change parsing mode; no-op here. |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 129 | case MCAF_SubsectionsViaSymbols: |
| 130 | getAssembler().setSubsectionsViaSymbols(true); |
| 131 | return; |
| 132 | } |
| 133 | |
Craig Topper | a2886c2 | 2012-02-07 05:05:23 +0000 | [diff] [blame] | 134 | llvm_unreachable("invalid assembler flag!"); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Derek Schuff | 2a1678a | 2015-04-21 00:14:25 +0000 | [diff] [blame] | 137 | // If bundle aligment is used and there are any instructions in the section, it |
| 138 | // needs to be aligned to at least the bundle size. |
Rafael Espindola | cd62518 | 2015-05-25 18:34:26 +0000 | [diff] [blame] | 139 | static void setSectionAlignmentForBundling(const MCAssembler &Assembler, |
Rafael Espindola | e6e287d | 2015-05-26 14:42:52 +0000 | [diff] [blame] | 140 | MCSection *Section) { |
| 141 | if (Section && Assembler.isBundlingEnabled() && Section->hasInstructions() && |
| 142 | Section->getAlignment() < Assembler.getBundleAlignSize()) |
| 143 | Section->setAlignment(Assembler.getBundleAlignSize()); |
Derek Schuff | 2a1678a | 2015-04-21 00:14:25 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 146 | void MCELFStreamer::ChangeSection(MCSection *Section, |
Peter Collingbourne | 2f495b9 | 2013-04-17 21:18:16 +0000 | [diff] [blame] | 147 | const MCExpr *Subsection) { |
Rafael Espindola | 983bec6 | 2015-05-27 21:04:14 +0000 | [diff] [blame] | 148 | MCSection *CurSection = getCurrentSectionOnly(); |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 149 | if (CurSection && isBundleLocked()) |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 150 | report_fatal_error("Unterminated .bundle_lock when changing a section"); |
Rafael Espindola | b661302 | 2014-10-17 01:48:58 +0000 | [diff] [blame] | 151 | |
| 152 | MCAssembler &Asm = getAssembler(); |
Derek Schuff | 2a1678a | 2015-04-21 00:14:25 +0000 | [diff] [blame] | 153 | // Ensure the previous section gets aligned if necessary. |
| 154 | setSectionAlignmentForBundling(Asm, CurSection); |
Rafael Espindola | b661302 | 2014-10-17 01:48:58 +0000 | [diff] [blame] | 155 | auto *SectionELF = static_cast<const MCSectionELF *>(Section); |
| 156 | const MCSymbol *Grp = SectionELF->getGroup(); |
Rafael Espindola | 7d0ba34 | 2010-11-14 04:17:37 +0000 | [diff] [blame] | 157 | if (Grp) |
Rafael Espindola | b5d316b | 2015-05-29 20:21:02 +0000 | [diff] [blame] | 158 | Asm.registerSymbol(*Grp); |
Rafael Espindola | b661302 | 2014-10-17 01:48:58 +0000 | [diff] [blame] | 159 | |
Peter Collingbourne | 2f495b9 | 2013-04-17 21:18:16 +0000 | [diff] [blame] | 160 | this->MCObjectStreamer::ChangeSection(Section, Subsection); |
Rafael Espindola | 2f9bdd8 | 2015-05-27 20:52:32 +0000 | [diff] [blame] | 161 | MCContext &Ctx = getContext(); |
| 162 | MCSymbol *Begin = Section->getBeginSymbol(); |
| 163 | if (!Begin) { |
| 164 | Begin = Ctx.getOrCreateSectionSymbol(*SectionELF); |
| 165 | Section->setBeginSymbol(Begin); |
Rafael Espindola | b661302 | 2014-10-17 01:48:58 +0000 | [diff] [blame] | 166 | } |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 167 | if (Begin->isUndefined()) { |
Rafael Espindola | b5d316b | 2015-05-29 20:21:02 +0000 | [diff] [blame] | 168 | Asm.registerSymbol(*Begin); |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 169 | MCELF::SetType(*Begin, ELF::STT_SECTION); |
| 170 | } |
Rafael Espindola | 7d0ba34 | 2010-11-14 04:17:37 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Rafael Espindola | 1614597 | 2010-11-01 14:28:48 +0000 | [diff] [blame] | 173 | void MCELFStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) { |
Rafael Espindola | b5d316b | 2015-05-29 20:21:02 +0000 | [diff] [blame] | 174 | getAssembler().registerSymbol(*Symbol); |
Jim Grosbach | 13760bd | 2015-05-30 01:25:56 +0000 | [diff] [blame^] | 175 | const MCExpr *Value = MCSymbolRefExpr::create( |
Rafael Espindola | 7fadc0e | 2014-03-20 02:12:01 +0000 | [diff] [blame] | 176 | Symbol, MCSymbolRefExpr::VK_WEAKREF, getContext()); |
Rafael Espindola | 1614597 | 2010-11-01 14:28:48 +0000 | [diff] [blame] | 177 | Alias->setVariableValue(Value); |
| 178 | } |
| 179 | |
Peter Collingbourne | adac407 | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 180 | // When GNU as encounters more than one .type declaration for an object it seems |
| 181 | // to use a mechanism similar to the one below to decide which type is actually |
| 182 | // used in the object file. The greater of T1 and T2 is selected based on the |
| 183 | // following ordering: |
| 184 | // STT_NOTYPE < STT_OBJECT < STT_FUNC < STT_GNU_IFUNC < STT_TLS < anything else |
| 185 | // If neither T1 < T2 nor T2 < T1 according to this ordering, use T2 (the user |
| 186 | // provided type). |
| 187 | static unsigned CombineSymbolTypes(unsigned T1, unsigned T2) { |
Benjamin Kramer | 867bfc5 | 2015-03-07 17:41:00 +0000 | [diff] [blame] | 188 | for (unsigned Type : {ELF::STT_NOTYPE, ELF::STT_OBJECT, ELF::STT_FUNC, |
| 189 | ELF::STT_GNU_IFUNC, ELF::STT_TLS}) { |
| 190 | if (T1 == Type) |
Peter Collingbourne | adac407 | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 191 | return T2; |
Benjamin Kramer | 867bfc5 | 2015-03-07 17:41:00 +0000 | [diff] [blame] | 192 | if (T2 == Type) |
Peter Collingbourne | adac407 | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 193 | return T1; |
| 194 | } |
| 195 | |
| 196 | return T2; |
| 197 | } |
| 198 | |
Saleem Abdulrasool | 4208b61 | 2013-08-09 01:52:03 +0000 | [diff] [blame] | 199 | bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol, |
| 200 | MCSymbolAttr Attribute) { |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 201 | // Indirect symbols are handled differently, to match how 'as' handles |
| 202 | // them. This makes writing matching .o files easier. |
| 203 | if (Attribute == MCSA_IndirectSymbol) { |
| 204 | // Note that we intentionally cannot use the symbol data here; this is |
| 205 | // important for matching the string table that 'as' generates. |
| 206 | IndirectSymbolData ISD; |
| 207 | ISD.Symbol = Symbol; |
Rafael Espindola | 983bec6 | 2015-05-27 21:04:14 +0000 | [diff] [blame] | 208 | ISD.Section = getCurrentSectionOnly(); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 209 | getAssembler().getIndirectSymbols().push_back(ISD); |
Saleem Abdulrasool | 4208b61 | 2013-08-09 01:52:03 +0000 | [diff] [blame] | 210 | return true; |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | // Adding a symbol attribute always introduces the symbol, note that an |
Rafael Espindola | b5d316b | 2015-05-29 20:21:02 +0000 | [diff] [blame] | 214 | // important side effect of calling registerSymbol here is to register |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 215 | // the symbol with the assembler. |
Rafael Espindola | b5d316b | 2015-05-29 20:21:02 +0000 | [diff] [blame] | 216 | getAssembler().registerSymbol(*Symbol); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 217 | |
| 218 | // The implementation of symbol attributes is designed to match 'as', but it |
| 219 | // leaves much to desired. It doesn't really make sense to arbitrarily add and |
| 220 | // remove flags, but 'as' allows this (in particular, see .desc). |
| 221 | // |
| 222 | // In the future it might be worth trying to make these operations more well |
| 223 | // defined. |
| 224 | switch (Attribute) { |
| 225 | case MCSA_LazyReference: |
| 226 | case MCSA_Reference: |
Kevin Enderby | 8be1441 | 2010-11-19 18:39:33 +0000 | [diff] [blame] | 227 | case MCSA_SymbolResolver: |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 228 | case MCSA_PrivateExtern: |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 229 | case MCSA_WeakDefinition: |
Eli Friedman | b20b524 | 2010-08-16 19:15:06 +0000 | [diff] [blame] | 230 | case MCSA_WeakDefAutoPrivate: |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 231 | case MCSA_Invalid: |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 232 | case MCSA_IndirectSymbol: |
Saleem Abdulrasool | 4208b61 | 2013-08-09 01:52:03 +0000 | [diff] [blame] | 233 | return false; |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 234 | |
Jim Grosbach | b7b750d | 2012-09-13 23:11:31 +0000 | [diff] [blame] | 235 | case MCSA_NoDeadStrip: |
Rafael Espindola | eba9022 | 2010-11-14 01:34:31 +0000 | [diff] [blame] | 236 | // Ignore for now. |
| 237 | break; |
| 238 | |
Rafael Espindola | 5fa925e | 2015-01-23 04:44:35 +0000 | [diff] [blame] | 239 | case MCSA_ELF_TypeGnuUniqueObject: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 240 | MCELF::SetType( |
| 241 | *Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT)); |
| 242 | MCELF::SetBinding(*Symbol, ELF::STB_GNU_UNIQUE); |
Rafael Espindola | 4d37b2a | 2015-05-29 21:45:01 +0000 | [diff] [blame] | 243 | Symbol->setExternal(true); |
Rafael Espindola | 5fa925e | 2015-01-23 04:44:35 +0000 | [diff] [blame] | 244 | BindingExplicitlySet.insert(Symbol); |
| 245 | break; |
| 246 | |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 247 | case MCSA_Global: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 248 | MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL); |
Rafael Espindola | 4d37b2a | 2015-05-29 21:45:01 +0000 | [diff] [blame] | 249 | Symbol->setExternal(true); |
Rafael Espindola | f0591c1 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 250 | BindingExplicitlySet.insert(Symbol); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 251 | break; |
| 252 | |
Benjamin Kramer | 5af02b0 | 2010-09-02 17:18:32 +0000 | [diff] [blame] | 253 | case MCSA_WeakReference: |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 254 | case MCSA_Weak: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 255 | MCELF::SetBinding(*Symbol, ELF::STB_WEAK); |
Rafael Espindola | 4d37b2a | 2015-05-29 21:45:01 +0000 | [diff] [blame] | 256 | Symbol->setExternal(true); |
Rafael Espindola | f0591c1 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 257 | BindingExplicitlySet.insert(Symbol); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 258 | break; |
| 259 | |
| 260 | case MCSA_Local: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 261 | MCELF::SetBinding(*Symbol, ELF::STB_LOCAL); |
Rafael Espindola | 4d37b2a | 2015-05-29 21:45:01 +0000 | [diff] [blame] | 262 | Symbol->setExternal(false); |
Rafael Espindola | f0591c1 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 263 | BindingExplicitlySet.insert(Symbol); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 264 | break; |
| 265 | |
| 266 | case MCSA_ELF_TypeFunction: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 267 | MCELF::SetType(*Symbol, |
| 268 | CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_FUNC)); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 269 | break; |
| 270 | |
Roman Divacky | 735cb8b | 2011-12-12 17:34:04 +0000 | [diff] [blame] | 271 | case MCSA_ELF_TypeIndFunction: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 272 | MCELF::SetType(*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), |
| 273 | ELF::STT_GNU_IFUNC)); |
Roman Divacky | 735cb8b | 2011-12-12 17:34:04 +0000 | [diff] [blame] | 274 | break; |
| 275 | |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 276 | case MCSA_ELF_TypeObject: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 277 | MCELF::SetType( |
| 278 | *Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT)); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 279 | break; |
| 280 | |
| 281 | case MCSA_ELF_TypeTLS: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 282 | MCELF::SetType(*Symbol, |
| 283 | CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_TLS)); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 284 | break; |
| 285 | |
| 286 | case MCSA_ELF_TypeCommon: |
Peter Collingbourne | adac407 | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 287 | // TODO: Emit these as a common symbol. |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 288 | MCELF::SetType( |
| 289 | *Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT)); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 290 | break; |
| 291 | |
| 292 | case MCSA_ELF_TypeNoType: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 293 | MCELF::SetType( |
| 294 | *Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_NOTYPE)); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 295 | break; |
| 296 | |
| 297 | case MCSA_Protected: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 298 | MCELF::SetVisibility(*Symbol, ELF::STV_PROTECTED); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 299 | break; |
| 300 | |
| 301 | case MCSA_Hidden: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 302 | MCELF::SetVisibility(*Symbol, ELF::STV_HIDDEN); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 303 | break; |
| 304 | |
| 305 | case MCSA_Internal: |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 306 | MCELF::SetVisibility(*Symbol, ELF::STV_INTERNAL); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 307 | break; |
| 308 | } |
Saleem Abdulrasool | 4208b61 | 2013-08-09 01:52:03 +0000 | [diff] [blame] | 309 | |
| 310 | return true; |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
Rafael Espindola | b5d316b | 2015-05-29 20:21:02 +0000 | [diff] [blame] | 314 | unsigned ByteAlignment) { |
| 315 | getAssembler().registerSymbol(*Symbol); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 316 | |
Rafael Espindola | f0591c1 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 317 | if (!BindingExplicitlySet.count(Symbol)) { |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 318 | MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL); |
Rafael Espindola | 4d37b2a | 2015-05-29 21:45:01 +0000 | [diff] [blame] | 319 | Symbol->setExternal(true); |
Rafael Espindola | f0591c1 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 320 | } |
| 321 | |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 322 | MCELF::SetType(*Symbol, ELF::STT_OBJECT); |
Rafael Espindola | a7d0bed | 2010-11-14 21:11:16 +0000 | [diff] [blame] | 323 | |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 324 | if (MCELF::GetBinding(*Symbol) == ELF_STB_Local) { |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 325 | MCSection *Section = getAssembler().getContext().getELFSection( |
Rafael Espindola | ba31e27 | 2015-01-29 17:33:21 +0000 | [diff] [blame] | 326 | ".bss", ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 327 | |
| 328 | AssignSection(Symbol, Section); |
Rafael Espindola | 9bac6cb | 2010-09-22 17:43:04 +0000 | [diff] [blame] | 329 | |
Duncan P. N. Exon Smith | fd28abc | 2015-05-20 18:25:40 +0000 | [diff] [blame] | 330 | struct LocalCommon L = {Symbol, Size, ByteAlignment}; |
Rafael Espindola | 53f0bf1 | 2010-09-29 14:52:01 +0000 | [diff] [blame] | 331 | LocalCommons.push_back(L); |
Rafael Espindola | f0591c1 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 332 | } else { |
Rafael Espindola | 1467250 | 2015-05-29 17:48:04 +0000 | [diff] [blame] | 333 | Symbol->setCommon(Size, ByteAlignment); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 334 | } |
| 335 | |
Jim Grosbach | 13760bd | 2015-05-30 01:25:56 +0000 | [diff] [blame^] | 336 | Symbol->setSize(MCConstantExpr::create(Size, getContext())); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Logan Chien | 59ff070 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 339 | void MCELFStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) { |
Rafael Espindola | 7c23cba | 2015-05-29 17:24:52 +0000 | [diff] [blame] | 340 | Symbol->setSize(Value); |
Logan Chien | 59ff070 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 341 | } |
| 342 | |
Benjamin Kramer | 6397051 | 2011-09-01 23:04:27 +0000 | [diff] [blame] | 343 | void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 344 | unsigned ByteAlignment) { |
Jason W Kim | 4c1386a | 2010-12-16 03:12:17 +0000 | [diff] [blame] | 345 | // FIXME: Should this be caught and done earlier? |
Rafael Espindola | b5d316b | 2015-05-29 20:21:02 +0000 | [diff] [blame] | 346 | getAssembler().registerSymbol(*Symbol); |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 347 | MCELF::SetBinding(*Symbol, ELF::STB_LOCAL); |
Rafael Espindola | 4d37b2a | 2015-05-29 21:45:01 +0000 | [diff] [blame] | 348 | Symbol->setExternal(false); |
Jason W Kim | 4c1386a | 2010-12-16 03:12:17 +0000 | [diff] [blame] | 349 | BindingExplicitlySet.insert(Symbol); |
Benjamin Kramer | 6397051 | 2011-09-01 23:04:27 +0000 | [diff] [blame] | 350 | EmitCommonSymbol(Symbol, Size, ByteAlignment); |
Jason W Kim | 4c1386a | 2010-12-16 03:12:17 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Kevin Enderby | 96918bc | 2014-04-22 17:27:29 +0000 | [diff] [blame] | 353 | void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, |
| 354 | const SMLoc &Loc) { |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 355 | if (isBundleLocked()) |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 356 | report_fatal_error("Emitting values inside a locked bundle is forbidden"); |
David Meyer | 44ec69e | 2012-02-15 15:09:06 +0000 | [diff] [blame] | 357 | fixSymbolsInTLSFixups(Value); |
Kevin Enderby | 96918bc | 2014-04-22 17:27:29 +0000 | [diff] [blame] | 358 | MCObjectStreamer::EmitValueImpl(Value, Size, Loc); |
David Meyer | 44ec69e | 2012-02-15 15:09:06 +0000 | [diff] [blame] | 359 | } |
| 360 | |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 361 | void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment, |
| 362 | int64_t Value, |
| 363 | unsigned ValueSize, |
| 364 | unsigned MaxBytesToEmit) { |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 365 | if (isBundleLocked()) |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 366 | report_fatal_error("Emitting values inside a locked bundle is forbidden"); |
| 367 | MCObjectStreamer::EmitValueToAlignment(ByteAlignment, Value, |
| 368 | ValueSize, MaxBytesToEmit); |
| 369 | } |
| 370 | |
Joerg Sonnenberger | fc18473 | 2013-10-29 01:06:17 +0000 | [diff] [blame] | 371 | // Add a symbol for the file name of this module. They start after the |
| 372 | // null symbol and don't count as normal symbol, i.e. a non-STT_FILE symbol |
| 373 | // with the same name may appear. |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 374 | void MCELFStreamer::EmitFileDirective(StringRef Filename) { |
Joerg Sonnenberger | fc18473 | 2013-10-29 01:06:17 +0000 | [diff] [blame] | 375 | getAssembler().addFileName(Filename); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 376 | } |
| 377 | |
Rafael Espindola | 5645bad | 2013-10-16 01:05:45 +0000 | [diff] [blame] | 378 | void MCELFStreamer::EmitIdent(StringRef IdentString) { |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 379 | MCSection *Comment = getAssembler().getContext().getELFSection( |
Rafael Espindola | ba31e27 | 2015-01-29 17:33:21 +0000 | [diff] [blame] | 380 | ".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); |
Rafael Espindola | 5645bad | 2013-10-16 01:05:45 +0000 | [diff] [blame] | 381 | PushSection(); |
| 382 | SwitchSection(Comment); |
| 383 | if (!SeenIdent) { |
| 384 | EmitIntValue(0, 1); |
| 385 | SeenIdent = true; |
| 386 | } |
| 387 | EmitBytes(IdentString); |
| 388 | EmitIntValue(0, 1); |
| 389 | PopSection(); |
| 390 | } |
| 391 | |
| 392 | void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) { |
Rafael Espindola | 4e70ac7 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 393 | switch (expr->getKind()) { |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 394 | case MCExpr::Target: |
| 395 | cast<MCTargetExpr>(expr)->fixELFSymbolsInTLSFixups(getAssembler()); |
| 396 | break; |
Rafael Espindola | 4e70ac7 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 397 | case MCExpr::Constant: |
| 398 | break; |
| 399 | |
| 400 | case MCExpr::Binary: { |
| 401 | const MCBinaryExpr *be = cast<MCBinaryExpr>(expr); |
| 402 | fixSymbolsInTLSFixups(be->getLHS()); |
| 403 | fixSymbolsInTLSFixups(be->getRHS()); |
| 404 | break; |
| 405 | } |
| 406 | |
| 407 | case MCExpr::SymbolRef: { |
| 408 | const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(expr); |
Rafael Espindola | e98d483 | 2010-11-24 18:51:21 +0000 | [diff] [blame] | 409 | switch (symRef.getKind()) { |
| 410 | default: |
Rafael Espindola | 4e70ac7 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 411 | return; |
Joerg Sonnenberger | 07de07e | 2011-03-17 00:35:10 +0000 | [diff] [blame] | 412 | case MCSymbolRefExpr::VK_GOTTPOFF: |
| 413 | case MCSymbolRefExpr::VK_INDNTPOFF: |
Rafael Espindola | e98d483 | 2010-11-24 18:51:21 +0000 | [diff] [blame] | 414 | case MCSymbolRefExpr::VK_NTPOFF: |
| 415 | case MCSymbolRefExpr::VK_GOTNTPOFF: |
| 416 | case MCSymbolRefExpr::VK_TLSGD: |
Joerg Sonnenberger | 07de07e | 2011-03-17 00:35:10 +0000 | [diff] [blame] | 417 | case MCSymbolRefExpr::VK_TLSLD: |
Rafael Espindola | e98d483 | 2010-11-24 18:51:21 +0000 | [diff] [blame] | 418 | case MCSymbolRefExpr::VK_TLSLDM: |
| 419 | case MCSymbolRefExpr::VK_TPOFF: |
| 420 | case MCSymbolRefExpr::VK_DTPOFF: |
Bruno Cardoso Lopes | 82b077e | 2011-10-25 18:13:20 +0000 | [diff] [blame] | 421 | case MCSymbolRefExpr::VK_Mips_TLSGD: |
| 422 | case MCSymbolRefExpr::VK_Mips_GOTTPREL: |
| 423 | case MCSymbolRefExpr::VK_Mips_TPREL_HI: |
| 424 | case MCSymbolRefExpr::VK_Mips_TPREL_LO: |
Ulrich Weigand | f11efe7 | 2013-07-01 23:33:29 +0000 | [diff] [blame] | 425 | case MCSymbolRefExpr::VK_PPC_DTPMOD: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 426 | case MCSymbolRefExpr::VK_PPC_TPREL: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 427 | case MCSymbolRefExpr::VK_PPC_TPREL_LO: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 428 | case MCSymbolRefExpr::VK_PPC_TPREL_HI: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 429 | case MCSymbolRefExpr::VK_PPC_TPREL_HA: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 430 | case MCSymbolRefExpr::VK_PPC_TPREL_HIGHER: |
| 431 | case MCSymbolRefExpr::VK_PPC_TPREL_HIGHERA: |
| 432 | case MCSymbolRefExpr::VK_PPC_TPREL_HIGHEST: |
| 433 | case MCSymbolRefExpr::VK_PPC_TPREL_HIGHESTA: |
| 434 | case MCSymbolRefExpr::VK_PPC_DTPREL: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 435 | case MCSymbolRefExpr::VK_PPC_DTPREL_LO: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 436 | case MCSymbolRefExpr::VK_PPC_DTPREL_HI: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 437 | case MCSymbolRefExpr::VK_PPC_DTPREL_HA: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 438 | case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHER: |
| 439 | case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHERA: |
| 440 | case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHEST: |
| 441 | case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHESTA: |
| 442 | case MCSymbolRefExpr::VK_PPC_GOT_TPREL: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 443 | case MCSymbolRefExpr::VK_PPC_GOT_TPREL_LO: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 444 | case MCSymbolRefExpr::VK_PPC_GOT_TPREL_HI: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 445 | case MCSymbolRefExpr::VK_PPC_GOT_TPREL_HA: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 446 | case MCSymbolRefExpr::VK_PPC_GOT_DTPREL: |
| 447 | case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_LO: |
| 448 | case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HI: |
| 449 | case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HA: |
Bill Schmidt | 441907d | 2013-02-26 16:41:03 +0000 | [diff] [blame] | 450 | case MCSymbolRefExpr::VK_PPC_TLS: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 451 | case MCSymbolRefExpr::VK_PPC_GOT_TLSGD: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 452 | case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_LO: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 453 | case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HI: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 454 | case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HA: |
Ulrich Weigand | 52cf8e4 | 2013-07-09 16:41:09 +0000 | [diff] [blame] | 455 | case MCSymbolRefExpr::VK_PPC_TLSGD: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 456 | case MCSymbolRefExpr::VK_PPC_GOT_TLSLD: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 457 | case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO: |
Ulrich Weigand | 876a0d0 | 2013-06-21 14:44:15 +0000 | [diff] [blame] | 458 | case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HI: |
Ulrich Weigand | d51c09f | 2013-06-21 14:42:20 +0000 | [diff] [blame] | 459 | case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HA: |
Ulrich Weigand | 52cf8e4 | 2013-07-09 16:41:09 +0000 | [diff] [blame] | 460 | case MCSymbolRefExpr::VK_PPC_TLSLD: |
Rafael Espindola | e98d483 | 2010-11-24 18:51:21 +0000 | [diff] [blame] | 461 | break; |
| 462 | } |
Rafael Espindola | b5d316b | 2015-05-29 20:21:02 +0000 | [diff] [blame] | 463 | getAssembler().registerSymbol(symRef.getSymbol()); |
Rafael Espindola | e3b2acf | 2015-05-29 18:47:23 +0000 | [diff] [blame] | 464 | MCELF::SetType(symRef.getSymbol(), ELF::STT_TLS); |
Rafael Espindola | 4e70ac7 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 465 | break; |
| 466 | } |
| 467 | |
| 468 | case MCExpr::Unary: |
| 469 | fixSymbolsInTLSFixups(cast<MCUnaryExpr>(expr)->getSubExpr()); |
| 470 | break; |
| 471 | } |
| 472 | } |
| 473 | |
David Woodhouse | 6f3c73f | 2014-01-28 23:12:49 +0000 | [diff] [blame] | 474 | void MCELFStreamer::EmitInstToFragment(const MCInst &Inst, |
| 475 | const MCSubtargetInfo &STI) { |
| 476 | this->MCObjectStreamer::EmitInstToFragment(Inst, STI); |
Eli Bendersky | 4d9ada0 | 2013-01-08 00:22:56 +0000 | [diff] [blame] | 477 | MCRelaxableFragment &F = *cast<MCRelaxableFragment>(getCurrentFragment()); |
Benjamin Kramer | 1f60124 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 478 | |
Rafael Espindola | 3fa6fc1 | 2010-12-02 05:44:06 +0000 | [diff] [blame] | 479 | for (unsigned i = 0, e = F.getFixups().size(); i != e; ++i) |
| 480 | fixSymbolsInTLSFixups(F.getFixups()[i].getValue()); |
Benjamin Kramer | 1f60124 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 481 | } |
| 482 | |
David Woodhouse | 6f3c73f | 2014-01-28 23:12:49 +0000 | [diff] [blame] | 483 | void MCELFStreamer::EmitInstToData(const MCInst &Inst, |
| 484 | const MCSubtargetInfo &STI) { |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 485 | MCAssembler &Assembler = getAssembler(); |
Benjamin Kramer | 1f60124 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 486 | SmallVector<MCFixup, 4> Fixups; |
| 487 | SmallString<256> Code; |
| 488 | raw_svector_ostream VecOS(Code); |
Jim Grosbach | 91df21f | 2015-05-15 19:13:16 +0000 | [diff] [blame] | 489 | Assembler.getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI); |
Benjamin Kramer | 1f60124 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 490 | VecOS.flush(); |
| 491 | |
Rafael Espindola | 4e70ac7 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 492 | for (unsigned i = 0, e = Fixups.size(); i != e; ++i) |
| 493 | fixSymbolsInTLSFixups(Fixups[i].getValue()); |
| 494 | |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 495 | // There are several possibilities here: |
| 496 | // |
| 497 | // If bundling is disabled, append the encoded instruction to the current data |
| 498 | // fragment (or create a new such fragment if the current fragment is not a |
| 499 | // data fragment). |
| 500 | // |
| 501 | // If bundling is enabled: |
Eli Bendersky | cf6009b | 2013-01-15 23:22:09 +0000 | [diff] [blame] | 502 | // - If we're not in a bundle-locked group, emit the instruction into a |
| 503 | // fragment of its own. If there are no fixups registered for the |
| 504 | // instruction, emit a MCCompactEncodedInstFragment. Otherwise, emit a |
| 505 | // MCDataFragment. |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 506 | // - If we're in a bundle-locked group, append the instruction to the current |
| 507 | // data fragment because we want all the instructions in a group to get into |
| 508 | // the same fragment. Be careful not to do that for the first instruction in |
| 509 | // the group, though. |
| 510 | MCDataFragment *DF; |
| 511 | |
| 512 | if (Assembler.isBundlingEnabled()) { |
Rafael Espindola | 983bec6 | 2015-05-27 21:04:14 +0000 | [diff] [blame] | 513 | MCSection &Sec = *getCurrentSectionOnly(); |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 514 | if (Assembler.getRelaxAll() && isBundleLocked()) |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 515 | // If the -mc-relax-all flag is used and we are bundle-locked, we re-use |
| 516 | // the current bundle group. |
| 517 | DF = BundleGroups.back(); |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 518 | else if (Assembler.getRelaxAll() && !isBundleLocked()) |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 519 | // When not in a bundle-locked group and the -mc-relax-all flag is used, |
| 520 | // we create a new temporary fragment which will be later merged into |
| 521 | // the current fragment. |
| 522 | DF = new MCDataFragment(); |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 523 | else if (isBundleLocked() && !Sec.isBundleGroupBeforeFirstInst()) |
Derek Schuff | 8878bcc9 | 2013-02-15 22:50:52 +0000 | [diff] [blame] | 524 | // If we are bundle-locked, we re-use the current fragment. |
| 525 | // The bundle-locking directive ensures this is a new data fragment. |
| 526 | DF = cast<MCDataFragment>(getCurrentFragment()); |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 527 | else if (!isBundleLocked() && Fixups.size() == 0) { |
Eli Bendersky | cf6009b | 2013-01-15 23:22:09 +0000 | [diff] [blame] | 528 | // Optimize memory usage by emitting the instruction to a |
| 529 | // MCCompactEncodedInstFragment when not in a bundle-locked group and |
| 530 | // there are no fixups registered. |
Peter Collingbourne | 2f495b9 | 2013-04-17 21:18:16 +0000 | [diff] [blame] | 531 | MCCompactEncodedInstFragment *CEIF = new MCCompactEncodedInstFragment(); |
| 532 | insert(CEIF); |
Eli Bendersky | cf6009b | 2013-01-15 23:22:09 +0000 | [diff] [blame] | 533 | CEIF->getContents().append(Code.begin(), Code.end()); |
| 534 | return; |
Derek Schuff | 8878bcc9 | 2013-02-15 22:50:52 +0000 | [diff] [blame] | 535 | } else { |
Peter Collingbourne | 2f495b9 | 2013-04-17 21:18:16 +0000 | [diff] [blame] | 536 | DF = new MCDataFragment(); |
| 537 | insert(DF); |
Derek Schuff | 05fb735 | 2014-10-15 17:10:04 +0000 | [diff] [blame] | 538 | } |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 539 | if (Sec.getBundleLockState() == MCSection::BundleLockedAlignToEnd) { |
Derek Schuff | 05fb735 | 2014-10-15 17:10:04 +0000 | [diff] [blame] | 540 | // If this fragment is for a group marked "align_to_end", set a flag |
| 541 | // in the fragment. This can happen after the fragment has already been |
| 542 | // created if there are nested bundle_align groups and an inner one |
| 543 | // is the one marked align_to_end. |
| 544 | DF->setAlignToBundleEnd(true); |
Eli Bendersky | 802b628 | 2013-01-07 21:51:08 +0000 | [diff] [blame] | 545 | } |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 546 | |
| 547 | // We're now emitting an instruction in a bundle group, so this flag has |
| 548 | // to be turned off. |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 549 | Sec.setBundleGroupBeforeFirstInst(false); |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 550 | } else { |
| 551 | DF = getOrCreateDataFragment(); |
| 552 | } |
| 553 | |
Benjamin Kramer | 1f60124 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 554 | // Add the fixups and data. |
| 555 | for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { |
| 556 | Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size()); |
Eli Bendersky | a31a894 | 2012-12-07 19:13:57 +0000 | [diff] [blame] | 557 | DF->getFixups().push_back(Fixups[i]); |
Benjamin Kramer | 1f60124 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 558 | } |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 559 | DF->setHasInstructions(true); |
Benjamin Kramer | 1f60124 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 560 | DF->getContents().append(Code.begin(), Code.end()); |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 561 | |
| 562 | if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) { |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 563 | if (!isBundleLocked()) { |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 564 | mergeFragment(getOrCreateDataFragment(), DF); |
| 565 | delete DF; |
| 566 | } |
| 567 | } |
Benjamin Kramer | 1f60124 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 568 | } |
| 569 | |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 570 | void MCELFStreamer::EmitBundleAlignMode(unsigned AlignPow2) { |
| 571 | assert(AlignPow2 <= 30 && "Invalid bundle alignment"); |
| 572 | MCAssembler &Assembler = getAssembler(); |
Derek Schuff | 05fb735 | 2014-10-15 17:10:04 +0000 | [diff] [blame] | 573 | if (AlignPow2 > 0 && (Assembler.getBundleAlignSize() == 0 || |
| 574 | Assembler.getBundleAlignSize() == 1U << AlignPow2)) |
| 575 | Assembler.setBundleAlignSize(1U << AlignPow2); |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 576 | else |
Derek Schuff | 05fb735 | 2014-10-15 17:10:04 +0000 | [diff] [blame] | 577 | report_fatal_error(".bundle_align_mode cannot be changed once set"); |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 578 | } |
| 579 | |
Eli Bendersky | 802b628 | 2013-01-07 21:51:08 +0000 | [diff] [blame] | 580 | void MCELFStreamer::EmitBundleLock(bool AlignToEnd) { |
Rafael Espindola | 983bec6 | 2015-05-27 21:04:14 +0000 | [diff] [blame] | 581 | MCSection &Sec = *getCurrentSectionOnly(); |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 582 | |
| 583 | // Sanity checks |
| 584 | // |
| 585 | if (!getAssembler().isBundlingEnabled()) |
| 586 | report_fatal_error(".bundle_lock forbidden when bundling is disabled"); |
Derek Schuff | 05fb735 | 2014-10-15 17:10:04 +0000 | [diff] [blame] | 587 | |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 588 | if (!isBundleLocked()) |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 589 | Sec.setBundleGroupBeforeFirstInst(true); |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 590 | |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 591 | if (getAssembler().getRelaxAll() && !isBundleLocked()) { |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 592 | // TODO: drop the lock state and set directly in the fragment |
| 593 | MCDataFragment *DF = new MCDataFragment(); |
| 594 | BundleGroups.push_back(DF); |
| 595 | } |
| 596 | |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 597 | Sec.setBundleLockState(AlignToEnd ? MCSection::BundleLockedAlignToEnd |
| 598 | : MCSection::BundleLocked); |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | void MCELFStreamer::EmitBundleUnlock() { |
Rafael Espindola | 983bec6 | 2015-05-27 21:04:14 +0000 | [diff] [blame] | 602 | MCSection &Sec = *getCurrentSectionOnly(); |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 603 | |
| 604 | // Sanity checks |
| 605 | if (!getAssembler().isBundlingEnabled()) |
| 606 | report_fatal_error(".bundle_unlock forbidden when bundling is disabled"); |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 607 | else if (!isBundleLocked()) |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 608 | report_fatal_error(".bundle_unlock without matching lock"); |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 609 | else if (Sec.isBundleGroupBeforeFirstInst()) |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 610 | report_fatal_error("Empty bundle-locked group is forbidden"); |
| 611 | |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 612 | // When the -mc-relax-all flag is used, we emit instructions to fragments |
| 613 | // stored on a stack. When the bundle unlock is emited, we pop a fragment |
| 614 | // from the stack a merge it to the one below. |
| 615 | if (getAssembler().getRelaxAll()) { |
| 616 | assert(!BundleGroups.empty() && "There are no bundle groups"); |
| 617 | MCDataFragment *DF = BundleGroups.back(); |
| 618 | |
| 619 | // FIXME: Use BundleGroups to track the lock state instead. |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 620 | Sec.setBundleLockState(MCSection::NotBundleLocked); |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 621 | |
Rafael Espindola | c1cd944 | 2015-05-25 14:57:35 +0000 | [diff] [blame] | 622 | // FIXME: Use more separate fragments for nested groups. |
| 623 | if (!isBundleLocked()) { |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 624 | mergeFragment(getOrCreateDataFragment(), DF); |
| 625 | BundleGroups.pop_back(); |
| 626 | delete DF; |
| 627 | } |
| 628 | |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 629 | if (Sec.getBundleLockState() != MCSection::BundleLockedAlignToEnd) |
Petr Hosek | 9e0c890 | 2015-04-12 23:42:25 +0000 | [diff] [blame] | 630 | getOrCreateDataFragment()->setAlignToBundleEnd(false); |
| 631 | } else |
Rafael Espindola | b028cc8 | 2015-05-25 15:04:26 +0000 | [diff] [blame] | 632 | Sec.setBundleLockState(MCSection::NotBundleLocked); |
Eli Bendersky | f483ff9 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 633 | } |
| 634 | |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 635 | void MCELFStreamer::Flush() { |
Rafael Espindola | 53f0bf1 | 2010-09-29 14:52:01 +0000 | [diff] [blame] | 636 | for (std::vector<LocalCommon>::const_iterator i = LocalCommons.begin(), |
| 637 | e = LocalCommons.end(); |
| 638 | i != e; ++i) { |
Duncan P. N. Exon Smith | fd28abc | 2015-05-20 18:25:40 +0000 | [diff] [blame] | 639 | const MCSymbol &Symbol = *i->Symbol; |
Rafael Espindola | 53f0bf1 | 2010-09-29 14:52:01 +0000 | [diff] [blame] | 640 | uint64_t Size = i->Size; |
| 641 | unsigned ByteAlignment = i->ByteAlignment; |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 642 | MCSection &Section = Symbol.getSection(); |
Rafael Espindola | 53f0bf1 | 2010-09-29 14:52:01 +0000 | [diff] [blame] | 643 | |
Rafael Espindola | bb9a71c | 2015-05-26 15:07:25 +0000 | [diff] [blame] | 644 | getAssembler().registerSection(Section); |
| 645 | new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &Section); |
Rafael Espindola | 53f0bf1 | 2010-09-29 14:52:01 +0000 | [diff] [blame] | 646 | |
Rafael Espindola | bb9a71c | 2015-05-26 15:07:25 +0000 | [diff] [blame] | 647 | MCFragment *F = new MCFillFragment(0, 0, Size, &Section); |
Rafael Espindola | 4d37b2a | 2015-05-29 21:45:01 +0000 | [diff] [blame] | 648 | Symbol.setFragment(F); |
Rafael Espindola | 53f0bf1 | 2010-09-29 14:52:01 +0000 | [diff] [blame] | 649 | |
| 650 | // Update the maximum alignment of the section if necessary. |
Rafael Espindola | 967d6a6 | 2015-05-21 21:02:35 +0000 | [diff] [blame] | 651 | if (ByteAlignment > Section.getAlignment()) |
| 652 | Section.setAlignment(ByteAlignment); |
Rafael Espindola | 53f0bf1 | 2010-09-29 14:52:01 +0000 | [diff] [blame] | 653 | } |
| 654 | |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 655 | LocalCommons.clear(); |
| 656 | } |
| 657 | |
| 658 | void MCELFStreamer::FinishImpl() { |
Derek Schuff | 2a1678a | 2015-04-21 00:14:25 +0000 | [diff] [blame] | 659 | // Ensure the last section gets aligned if necessary. |
Rafael Espindola | 983bec6 | 2015-05-27 21:04:14 +0000 | [diff] [blame] | 660 | MCSection *CurSection = getCurrentSectionOnly(); |
Rafael Espindola | e6e287d | 2015-05-26 14:42:52 +0000 | [diff] [blame] | 661 | setSectionAlignmentForBundling(getAssembler(), CurSection); |
Derek Schuff | 2a1678a | 2015-04-21 00:14:25 +0000 | [diff] [blame] | 662 | |
Rafael Espindola | 7f4ccce | 2014-05-12 13:30:10 +0000 | [diff] [blame] | 663 | EmitFrames(nullptr); |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 664 | |
| 665 | Flush(); |
| 666 | |
Rafael Espindola | 0708209 | 2012-01-07 03:13:18 +0000 | [diff] [blame] | 667 | this->MCObjectStreamer::FinishImpl(); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 668 | } |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 669 | |
Rafael Espindola | 24ea09e | 2014-01-26 06:06:37 +0000 | [diff] [blame] | 670 | MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB, |
Rafael Espindola | 5560a4c | 2015-04-14 22:14:34 +0000 | [diff] [blame] | 671 | raw_pwrite_stream &OS, MCCodeEmitter *CE, |
Rafael Espindola | 7b61ddf | 2014-10-15 16:12:52 +0000 | [diff] [blame] | 672 | bool RelaxAll) { |
Rafael Espindola | 24ea09e | 2014-01-26 06:06:37 +0000 | [diff] [blame] | 673 | MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 674 | if (RelaxAll) |
| 675 | S->getAssembler().setRelaxAll(true); |
Matt Fleming | 6c1ad48 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 676 | return S; |
| 677 | } |
Logan Chien | 59ff070 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 678 | |
Tim Northover | 5cc3dc8 | 2012-12-07 16:50:23 +0000 | [diff] [blame] | 679 | void MCELFStreamer::EmitThumbFunc(MCSymbol *Func) { |
| 680 | llvm_unreachable("Generic ELF doesn't support this directive"); |
| 681 | } |
| 682 | |
Logan Chien | 59ff070 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 683 | void MCELFStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { |
| 684 | llvm_unreachable("ELF doesn't support this directive"); |
| 685 | } |
| 686 | |
| 687 | void MCELFStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) { |
| 688 | llvm_unreachable("ELF doesn't support this directive"); |
| 689 | } |
| 690 | |
| 691 | void MCELFStreamer::EmitCOFFSymbolStorageClass(int StorageClass) { |
| 692 | llvm_unreachable("ELF doesn't support this directive"); |
| 693 | } |
| 694 | |
| 695 | void MCELFStreamer::EmitCOFFSymbolType(int Type) { |
| 696 | llvm_unreachable("ELF doesn't support this directive"); |
| 697 | } |
| 698 | |
| 699 | void MCELFStreamer::EndCOFFSymbolDef() { |
| 700 | llvm_unreachable("ELF doesn't support this directive"); |
| 701 | } |
| 702 | |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 703 | void MCELFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol, |
Logan Chien | 59ff070 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 704 | uint64_t Size, unsigned ByteAlignment) { |
| 705 | llvm_unreachable("ELF doesn't support this directive"); |
| 706 | } |
| 707 | |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 708 | void MCELFStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, |
Logan Chien | 59ff070 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 709 | uint64_t Size, unsigned ByteAlignment) { |
| 710 | llvm_unreachable("ELF doesn't support this directive"); |
| 711 | } |