Nick Lewycky | 462bba3 | 2013-03-09 09:31:44 +0000 | [diff] [blame] | 1 | //===- lib/MC/MCELFStreamer.cpp - ELF Object Output -----------------------===// |
Matt Fleming | 3565a06 | 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 | 6450165 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCELFStreamer.h" |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/SmallPtrSet.h" |
Peter Collingbourne | 01a7b5c | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/STLExtras.h" |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCAssembler.h" |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCCodeEmitter.h" |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCContext.h" |
Tim Northover | 6eb3e87 | 2012-12-07 16:50:23 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCELF.h" |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCELFSymbolFlags.h" |
| 22 | #include "llvm/MC/MCExpr.h" |
| 23 | #include "llvm/MC/MCInst.h" |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 24 | #include "llvm/MC/MCObjectStreamer.h" |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 25 | #include "llvm/MC/MCSection.h" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 26 | #include "llvm/MC/MCSectionELF.h" |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 27 | #include "llvm/MC/MCSymbol.h" |
Rafael Espindola | 484291c | 2010-11-01 14:28:48 +0000 | [diff] [blame] | 28 | #include "llvm/MC/MCValue.h" |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 29 | #include "llvm/Support/Debug.h" |
| 30 | #include "llvm/Support/ELF.h" |
| 31 | #include "llvm/Support/ErrorHandling.h" |
| 32 | #include "llvm/Support/raw_ostream.h" |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 33 | |
| 34 | using namespace llvm; |
| 35 | |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 36 | |
Logan Chien | 6450165 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 37 | inline void MCELFStreamer::SetSection(StringRef Section, unsigned Type, |
| 38 | unsigned Flags, SectionKind Kind) { |
| 39 | SwitchSection(getContext().getELFSection(Section, Type, Flags, Kind)); |
| 40 | } |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 41 | |
Logan Chien | 6450165 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 42 | inline void MCELFStreamer::SetSectionData() { |
| 43 | SetSection(".data", |
| 44 | ELF::SHT_PROGBITS, |
| 45 | ELF::SHF_WRITE | ELF::SHF_ALLOC, |
| 46 | SectionKind::getDataRel()); |
| 47 | EmitCodeAlignment(4, 0); |
| 48 | } |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 49 | |
Logan Chien | 6450165 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 50 | inline void MCELFStreamer::SetSectionText() { |
| 51 | SetSection(".text", |
| 52 | ELF::SHT_PROGBITS, |
| 53 | ELF::SHF_EXECINSTR | ELF::SHF_ALLOC, |
| 54 | SectionKind::getText()); |
| 55 | EmitCodeAlignment(4, 0); |
| 56 | } |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 57 | |
Logan Chien | 6450165 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 58 | inline void MCELFStreamer::SetSectionBss() { |
| 59 | SetSection(".bss", |
| 60 | ELF::SHT_NOBITS, |
| 61 | ELF::SHF_WRITE | ELF::SHF_ALLOC, |
| 62 | SectionKind::getBSS()); |
| 63 | EmitCodeAlignment(4, 0); |
| 64 | } |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 65 | |
Logan Chien | 6450165 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 66 | MCELFStreamer::~MCELFStreamer() { |
Rafael Espindola | f340a29 | 2012-01-07 23:18:39 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Eli Bendersky | 030f63a | 2013-01-14 19:04:57 +0000 | [diff] [blame] | 69 | void MCELFStreamer::InitToTextSection() { |
| 70 | SetSectionText(); |
| 71 | } |
| 72 | |
Rafael Espindola | d80781b | 2010-09-15 21:48:40 +0000 | [diff] [blame] | 73 | void MCELFStreamer::InitSections() { |
| 74 | // This emulates the same behavior of GNU as. This makes it easier |
| 75 | // to compare the output as the major sections are in the same order. |
| 76 | SetSectionText(); |
| 77 | SetSectionData(); |
| 78 | SetSectionBss(); |
| 79 | SetSectionText(); |
| 80 | } |
| 81 | |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 82 | void MCELFStreamer::EmitLabel(MCSymbol *Symbol) { |
Rafael Espindola | ba21024 | 2010-11-28 16:22:59 +0000 | [diff] [blame] | 83 | assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); |
| 84 | |
Rafael Espindola | ea4afa9 | 2010-11-28 17:18:55 +0000 | [diff] [blame] | 85 | MCObjectStreamer::EmitLabel(Symbol); |
Rafael Espindola | 73ffea4 | 2010-09-25 05:42:19 +0000 | [diff] [blame] | 86 | |
Rafael Espindola | e1a2587 | 2010-11-11 19:04:55 +0000 | [diff] [blame] | 87 | const MCSectionELF &Section = |
| 88 | static_cast<const MCSectionELF&>(Symbol->getSection()); |
Rafael Espindola | ea4afa9 | 2010-11-28 17:18:55 +0000 | [diff] [blame] | 89 | MCSymbolData &SD = getAssembler().getSymbolData(*Symbol); |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 90 | if (Section.getFlags() & ELF::SHF_TLS) |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 91 | MCELF::SetType(SD, ELF::STT_TLS); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Reed Kotler | 2c3a464 | 2012-12-16 04:00:45 +0000 | [diff] [blame] | 94 | void MCELFStreamer::EmitDebugLabel(MCSymbol *Symbol) { |
| 95 | EmitLabel(Symbol); |
| 96 | } |
| 97 | |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 98 | void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { |
| 99 | switch (Flag) { |
Jim Grosbach | ce79299 | 2010-11-05 22:08:08 +0000 | [diff] [blame] | 100 | case MCAF_SyntaxUnified: return; // no-op here. |
Evan Cheng | bd27f5a | 2011-07-27 00:38:12 +0000 | [diff] [blame] | 101 | case MCAF_Code16: return; // Change parsing mode; no-op here. |
| 102 | case MCAF_Code32: return; // Change parsing mode; no-op here. |
| 103 | case MCAF_Code64: return; // Change parsing mode; no-op here. |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 104 | case MCAF_SubsectionsViaSymbols: |
| 105 | getAssembler().setSubsectionsViaSymbols(true); |
| 106 | return; |
| 107 | } |
| 108 | |
Craig Topper | 8581438 | 2012-02-07 05:05:23 +0000 | [diff] [blame] | 109 | llvm_unreachable("invalid assembler flag!"); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Rafael Espindola | 7768a9d | 2011-02-16 01:08:29 +0000 | [diff] [blame] | 112 | void MCELFStreamer::ChangeSection(const MCSection *Section) { |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 113 | MCSectionData *CurSection = getCurrentSectionData(); |
| 114 | if (CurSection && CurSection->isBundleLocked()) |
| 115 | report_fatal_error("Unterminated .bundle_lock when changing a section"); |
Rafael Espindola | 1f4f9e3 | 2010-11-14 04:17:37 +0000 | [diff] [blame] | 116 | const MCSymbol *Grp = static_cast<const MCSectionELF *>(Section)->getGroup(); |
| 117 | if (Grp) |
| 118 | getAssembler().getOrCreateSymbolData(*Grp); |
Rafael Espindola | 7768a9d | 2011-02-16 01:08:29 +0000 | [diff] [blame] | 119 | this->MCObjectStreamer::ChangeSection(Section); |
Rafael Espindola | 1f4f9e3 | 2010-11-14 04:17:37 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Rafael Espindola | 484291c | 2010-11-01 14:28:48 +0000 | [diff] [blame] | 122 | void MCELFStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) { |
| 123 | getAssembler().getOrCreateSymbolData(*Symbol); |
| 124 | MCSymbolData &AliasSD = getAssembler().getOrCreateSymbolData(*Alias); |
| 125 | AliasSD.setFlags(AliasSD.getFlags() | ELF_Other_Weakref); |
Rafael Espindola | 94ed5fc | 2010-11-15 16:33:49 +0000 | [diff] [blame] | 126 | const MCExpr *Value = MCSymbolRefExpr::Create(Symbol, getContext()); |
Rafael Espindola | 484291c | 2010-11-01 14:28:48 +0000 | [diff] [blame] | 127 | Alias->setVariableValue(Value); |
| 128 | } |
| 129 | |
Peter Collingbourne | 01a7b5c | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 130 | // When GNU as encounters more than one .type declaration for an object it seems |
| 131 | // to use a mechanism similar to the one below to decide which type is actually |
| 132 | // used in the object file. The greater of T1 and T2 is selected based on the |
| 133 | // following ordering: |
| 134 | // STT_NOTYPE < STT_OBJECT < STT_FUNC < STT_GNU_IFUNC < STT_TLS < anything else |
| 135 | // If neither T1 < T2 nor T2 < T1 according to this ordering, use T2 (the user |
| 136 | // provided type). |
| 137 | static unsigned CombineSymbolTypes(unsigned T1, unsigned T2) { |
| 138 | unsigned TypeOrdering[] = {ELF::STT_NOTYPE, ELF::STT_OBJECT, ELF::STT_FUNC, |
| 139 | ELF::STT_GNU_IFUNC, ELF::STT_TLS}; |
| 140 | for (unsigned i = 0; i != array_lengthof(TypeOrdering); ++i) { |
| 141 | if (T1 == TypeOrdering[i]) |
| 142 | return T2; |
| 143 | if (T2 == TypeOrdering[i]) |
| 144 | return T1; |
| 145 | } |
| 146 | |
| 147 | return T2; |
| 148 | } |
| 149 | |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 150 | void MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol, |
| 151 | MCSymbolAttr Attribute) { |
| 152 | // Indirect symbols are handled differently, to match how 'as' handles |
| 153 | // them. This makes writing matching .o files easier. |
| 154 | if (Attribute == MCSA_IndirectSymbol) { |
| 155 | // Note that we intentionally cannot use the symbol data here; this is |
| 156 | // important for matching the string table that 'as' generates. |
| 157 | IndirectSymbolData ISD; |
| 158 | ISD.Symbol = Symbol; |
| 159 | ISD.SectionData = getCurrentSectionData(); |
| 160 | getAssembler().getIndirectSymbols().push_back(ISD); |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | // Adding a symbol attribute always introduces the symbol, note that an |
| 165 | // important side effect of calling getOrCreateSymbolData here is to register |
| 166 | // the symbol with the assembler. |
| 167 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
| 168 | |
| 169 | // The implementation of symbol attributes is designed to match 'as', but it |
| 170 | // leaves much to desired. It doesn't really make sense to arbitrarily add and |
| 171 | // remove flags, but 'as' allows this (in particular, see .desc). |
| 172 | // |
| 173 | // In the future it might be worth trying to make these operations more well |
| 174 | // defined. |
| 175 | switch (Attribute) { |
| 176 | case MCSA_LazyReference: |
| 177 | case MCSA_Reference: |
Kevin Enderby | e8e98d7 | 2010-11-19 18:39:33 +0000 | [diff] [blame] | 178 | case MCSA_SymbolResolver: |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 179 | case MCSA_PrivateExtern: |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 180 | case MCSA_WeakDefinition: |
Eli Friedman | f8020a3 | 2010-08-16 19:15:06 +0000 | [diff] [blame] | 181 | case MCSA_WeakDefAutoPrivate: |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 182 | case MCSA_Invalid: |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 183 | case MCSA_IndirectSymbol: |
Craig Topper | 8581438 | 2012-02-07 05:05:23 +0000 | [diff] [blame] | 184 | llvm_unreachable("Invalid symbol attribute for ELF!"); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 185 | |
Jim Grosbach | 3f90a4c | 2012-09-13 23:11:31 +0000 | [diff] [blame] | 186 | case MCSA_NoDeadStrip: |
Rafael Espindola | 7e528a1 | 2010-11-14 01:34:31 +0000 | [diff] [blame] | 187 | case MCSA_ELF_TypeGnuUniqueObject: |
| 188 | // Ignore for now. |
| 189 | break; |
| 190 | |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 191 | case MCSA_Global: |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 192 | MCELF::SetBinding(SD, ELF::STB_GLOBAL); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 193 | SD.setExternal(true); |
Rafael Espindola | f7c10a3 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 194 | BindingExplicitlySet.insert(Symbol); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 195 | break; |
| 196 | |
Benjamin Kramer | 230c274 | 2010-09-02 17:18:32 +0000 | [diff] [blame] | 197 | case MCSA_WeakReference: |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 198 | case MCSA_Weak: |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 199 | MCELF::SetBinding(SD, ELF::STB_WEAK); |
Rafael Espindola | 3223f19 | 2010-10-06 16:47:31 +0000 | [diff] [blame] | 200 | SD.setExternal(true); |
Rafael Espindola | f7c10a3 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 201 | BindingExplicitlySet.insert(Symbol); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 202 | break; |
| 203 | |
| 204 | case MCSA_Local: |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 205 | MCELF::SetBinding(SD, ELF::STB_LOCAL); |
Rafael Espindola | f7c10a3 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 206 | SD.setExternal(false); |
| 207 | BindingExplicitlySet.insert(Symbol); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 208 | break; |
| 209 | |
| 210 | case MCSA_ELF_TypeFunction: |
Peter Collingbourne | 01a7b5c | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 211 | MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD), |
| 212 | ELF::STT_FUNC)); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 213 | break; |
| 214 | |
Roman Divacky | a0c17a4 | 2011-12-12 17:34:04 +0000 | [diff] [blame] | 215 | case MCSA_ELF_TypeIndFunction: |
Peter Collingbourne | 01a7b5c | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 216 | MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD), |
| 217 | ELF::STT_GNU_IFUNC)); |
Roman Divacky | a0c17a4 | 2011-12-12 17:34:04 +0000 | [diff] [blame] | 218 | break; |
| 219 | |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 220 | case MCSA_ELF_TypeObject: |
Peter Collingbourne | 01a7b5c | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 221 | MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD), |
| 222 | ELF::STT_OBJECT)); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 223 | break; |
| 224 | |
| 225 | case MCSA_ELF_TypeTLS: |
Peter Collingbourne | 01a7b5c | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 226 | MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD), |
| 227 | ELF::STT_TLS)); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 228 | break; |
| 229 | |
| 230 | case MCSA_ELF_TypeCommon: |
Peter Collingbourne | 01a7b5c | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 231 | // TODO: Emit these as a common symbol. |
| 232 | MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD), |
| 233 | ELF::STT_OBJECT)); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 234 | break; |
| 235 | |
| 236 | case MCSA_ELF_TypeNoType: |
Peter Collingbourne | 01a7b5c | 2013-04-10 16:52:15 +0000 | [diff] [blame] | 237 | MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD), |
| 238 | ELF::STT_NOTYPE)); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 239 | break; |
| 240 | |
| 241 | case MCSA_Protected: |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 242 | MCELF::SetVisibility(SD, ELF::STV_PROTECTED); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 243 | break; |
| 244 | |
| 245 | case MCSA_Hidden: |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 246 | MCELF::SetVisibility(SD, ELF::STV_HIDDEN); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 247 | break; |
| 248 | |
| 249 | case MCSA_Internal: |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 250 | MCELF::SetVisibility(SD, ELF::STV_INTERNAL); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 251 | break; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 256 | unsigned ByteAlignment) { |
| 257 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
| 258 | |
Rafael Espindola | f7c10a3 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 259 | if (!BindingExplicitlySet.count(Symbol)) { |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 260 | MCELF::SetBinding(SD, ELF::STB_GLOBAL); |
Rafael Espindola | f7c10a3 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 261 | SD.setExternal(true); |
| 262 | } |
| 263 | |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 264 | MCELF::SetType(SD, ELF::STT_OBJECT); |
Rafael Espindola | 55d02f3 | 2010-11-14 21:11:16 +0000 | [diff] [blame] | 265 | |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 266 | if (MCELF::GetBinding(SD) == ELF_STB_Local) { |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 267 | const MCSection *Section = getAssembler().getContext().getELFSection(".bss", |
Jim Grosbach | 946227d | 2011-11-15 16:46:22 +0000 | [diff] [blame] | 268 | ELF::SHT_NOBITS, |
| 269 | ELF::SHF_WRITE | |
| 270 | ELF::SHF_ALLOC, |
| 271 | SectionKind::getBSS()); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 272 | Symbol->setSection(*Section); |
Rafael Espindola | 1963572 | 2010-09-22 17:43:04 +0000 | [diff] [blame] | 273 | |
Rafael Espindola | 9e3922e | 2010-09-29 14:52:01 +0000 | [diff] [blame] | 274 | struct LocalCommon L = {&SD, Size, ByteAlignment}; |
| 275 | LocalCommons.push_back(L); |
Rafael Espindola | f7c10a3 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 276 | } else { |
| 277 | SD.setCommon(Size, ByteAlignment); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 278 | } |
| 279 | |
Rafael Espindola | f7c10a3 | 2010-09-21 00:24:38 +0000 | [diff] [blame] | 280 | SD.setSize(MCConstantExpr::Create(Size, getContext())); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Logan Chien | 6450165 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 283 | void MCELFStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) { |
| 284 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
| 285 | SD.setSize(Value); |
| 286 | } |
| 287 | |
Benjamin Kramer | 36a1601 | 2011-09-01 23:04:27 +0000 | [diff] [blame] | 288 | void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 289 | unsigned ByteAlignment) { |
Jason W Kim | f13743b | 2010-12-16 03:12:17 +0000 | [diff] [blame] | 290 | // FIXME: Should this be caught and done earlier? |
| 291 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 292 | MCELF::SetBinding(SD, ELF::STB_LOCAL); |
Jason W Kim | f13743b | 2010-12-16 03:12:17 +0000 | [diff] [blame] | 293 | SD.setExternal(false); |
| 294 | BindingExplicitlySet.insert(Symbol); |
Benjamin Kramer | 36a1601 | 2011-09-01 23:04:27 +0000 | [diff] [blame] | 295 | EmitCommonSymbol(Symbol, Size, ByteAlignment); |
Jason W Kim | f13743b | 2010-12-16 03:12:17 +0000 | [diff] [blame] | 296 | } |
| 297 | |
David Meyer | 5f76926 | 2012-02-15 15:09:06 +0000 | [diff] [blame] | 298 | void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, |
| 299 | unsigned AddrSpace) { |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 300 | if (getCurrentSectionData()->isBundleLocked()) |
| 301 | report_fatal_error("Emitting values inside a locked bundle is forbidden"); |
David Meyer | 5f76926 | 2012-02-15 15:09:06 +0000 | [diff] [blame] | 302 | fixSymbolsInTLSFixups(Value); |
| 303 | MCObjectStreamer::EmitValueImpl(Value, Size, AddrSpace); |
| 304 | } |
| 305 | |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 306 | void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment, |
| 307 | int64_t Value, |
| 308 | unsigned ValueSize, |
| 309 | unsigned MaxBytesToEmit) { |
| 310 | if (getCurrentSectionData()->isBundleLocked()) |
| 311 | report_fatal_error("Emitting values inside a locked bundle is forbidden"); |
| 312 | MCObjectStreamer::EmitValueToAlignment(ByteAlignment, Value, |
| 313 | ValueSize, MaxBytesToEmit); |
| 314 | } |
| 315 | |
David Meyer | 5f76926 | 2012-02-15 15:09:06 +0000 | [diff] [blame] | 316 | |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 317 | // Add a symbol for the file name of this module. This is the second |
| 318 | // entry in the module's symbol table (the first being the null symbol). |
| 319 | void MCELFStreamer::EmitFileDirective(StringRef Filename) { |
| 320 | MCSymbol *Symbol = getAssembler().getContext().GetOrCreateSymbol(Filename); |
Rafael Espindola | 7768a9d | 2011-02-16 01:08:29 +0000 | [diff] [blame] | 321 | Symbol->setSection(*getCurrentSection()); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 322 | Symbol->setAbsolute(); |
| 323 | |
| 324 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
| 325 | |
| 326 | SD.setFlags(ELF_STT_File | ELF_STB_Local | ELF_STV_Default); |
| 327 | } |
| 328 | |
Rafael Espindola | 9755127 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 329 | void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) { |
| 330 | switch (expr->getKind()) { |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 331 | case MCExpr::Target: |
| 332 | cast<MCTargetExpr>(expr)->fixELFSymbolsInTLSFixups(getAssembler()); |
| 333 | break; |
Rafael Espindola | 9755127 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 334 | case MCExpr::Constant: |
| 335 | break; |
| 336 | |
| 337 | case MCExpr::Binary: { |
| 338 | const MCBinaryExpr *be = cast<MCBinaryExpr>(expr); |
| 339 | fixSymbolsInTLSFixups(be->getLHS()); |
| 340 | fixSymbolsInTLSFixups(be->getRHS()); |
| 341 | break; |
| 342 | } |
| 343 | |
| 344 | case MCExpr::SymbolRef: { |
| 345 | const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(expr); |
Rafael Espindola | bf8209d | 2010-11-24 18:51:21 +0000 | [diff] [blame] | 346 | switch (symRef.getKind()) { |
| 347 | default: |
Rafael Espindola | 9755127 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 348 | return; |
Joerg Sonnenberger | d02c8b6 | 2011-03-17 00:35:10 +0000 | [diff] [blame] | 349 | case MCSymbolRefExpr::VK_GOTTPOFF: |
| 350 | case MCSymbolRefExpr::VK_INDNTPOFF: |
Rafael Espindola | bf8209d | 2010-11-24 18:51:21 +0000 | [diff] [blame] | 351 | case MCSymbolRefExpr::VK_NTPOFF: |
| 352 | case MCSymbolRefExpr::VK_GOTNTPOFF: |
| 353 | case MCSymbolRefExpr::VK_TLSGD: |
Joerg Sonnenberger | d02c8b6 | 2011-03-17 00:35:10 +0000 | [diff] [blame] | 354 | case MCSymbolRefExpr::VK_TLSLD: |
Rafael Espindola | bf8209d | 2010-11-24 18:51:21 +0000 | [diff] [blame] | 355 | case MCSymbolRefExpr::VK_TLSLDM: |
| 356 | case MCSymbolRefExpr::VK_TPOFF: |
| 357 | case MCSymbolRefExpr::VK_DTPOFF: |
Rafael Espindola | bf8209d | 2010-11-24 18:51:21 +0000 | [diff] [blame] | 358 | case MCSymbolRefExpr::VK_ARM_TLSGD: |
Joerg Sonnenberger | d02c8b6 | 2011-03-17 00:35:10 +0000 | [diff] [blame] | 359 | case MCSymbolRefExpr::VK_ARM_TPOFF: |
| 360 | case MCSymbolRefExpr::VK_ARM_GOTTPOFF: |
Bruno Cardoso Lopes | 3507d24 | 2011-10-25 18:13:20 +0000 | [diff] [blame] | 361 | case MCSymbolRefExpr::VK_Mips_TLSGD: |
| 362 | case MCSymbolRefExpr::VK_Mips_GOTTPREL: |
| 363 | case MCSymbolRefExpr::VK_Mips_TPREL_HI: |
| 364 | case MCSymbolRefExpr::VK_Mips_TPREL_LO: |
Bill Schmidt | 3a42989 | 2013-02-26 16:41:03 +0000 | [diff] [blame] | 365 | case MCSymbolRefExpr::VK_PPC_TPREL16_HA: |
| 366 | case MCSymbolRefExpr::VK_PPC_TPREL16_LO: |
| 367 | case MCSymbolRefExpr::VK_PPC_DTPREL16_HA: |
| 368 | case MCSymbolRefExpr::VK_PPC_DTPREL16_LO: |
| 369 | case MCSymbolRefExpr::VK_PPC_GOT_TPREL16_HA: |
| 370 | case MCSymbolRefExpr::VK_PPC_GOT_TPREL16_LO: |
| 371 | case MCSymbolRefExpr::VK_PPC_TLS: |
| 372 | case MCSymbolRefExpr::VK_PPC_GOT_TLSGD16_HA: |
| 373 | case MCSymbolRefExpr::VK_PPC_GOT_TLSGD16_LO: |
| 374 | case MCSymbolRefExpr::VK_PPC_TLSGD: |
| 375 | case MCSymbolRefExpr::VK_PPC_GOT_TLSLD16_HA: |
| 376 | case MCSymbolRefExpr::VK_PPC_GOT_TLSLD16_LO: |
| 377 | case MCSymbolRefExpr::VK_PPC_TLSLD: |
Rafael Espindola | bf8209d | 2010-11-24 18:51:21 +0000 | [diff] [blame] | 378 | break; |
| 379 | } |
Rafael Espindola | 9755127 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 380 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(symRef.getSymbol()); |
Jan Sjödin | 2ddfd95 | 2011-02-28 21:45:04 +0000 | [diff] [blame] | 381 | MCELF::SetType(SD, ELF::STT_TLS); |
Rafael Espindola | 9755127 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 382 | break; |
| 383 | } |
| 384 | |
| 385 | case MCExpr::Unary: |
| 386 | fixSymbolsInTLSFixups(cast<MCUnaryExpr>(expr)->getSubExpr()); |
| 387 | break; |
| 388 | } |
| 389 | } |
| 390 | |
Benjamin Kramer | 93ded73 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 391 | void MCELFStreamer::EmitInstToFragment(const MCInst &Inst) { |
Rafael Espindola | dedb045 | 2010-12-02 05:44:06 +0000 | [diff] [blame] | 392 | this->MCObjectStreamer::EmitInstToFragment(Inst); |
Eli Bendersky | 251040b | 2013-01-08 00:22:56 +0000 | [diff] [blame] | 393 | MCRelaxableFragment &F = *cast<MCRelaxableFragment>(getCurrentFragment()); |
Benjamin Kramer | 93ded73 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 394 | |
Rafael Espindola | dedb045 | 2010-12-02 05:44:06 +0000 | [diff] [blame] | 395 | for (unsigned i = 0, e = F.getFixups().size(); i != e; ++i) |
| 396 | fixSymbolsInTLSFixups(F.getFixups()[i].getValue()); |
Benjamin Kramer | 93ded73 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | void MCELFStreamer::EmitInstToData(const MCInst &Inst) { |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 400 | MCAssembler &Assembler = getAssembler(); |
Benjamin Kramer | 93ded73 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 401 | SmallVector<MCFixup, 4> Fixups; |
| 402 | SmallString<256> Code; |
| 403 | raw_svector_ostream VecOS(Code); |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 404 | Assembler.getEmitter().EncodeInstruction(Inst, VecOS, Fixups); |
Benjamin Kramer | 93ded73 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 405 | VecOS.flush(); |
| 406 | |
Rafael Espindola | 9755127 | 2010-11-24 02:19:40 +0000 | [diff] [blame] | 407 | for (unsigned i = 0, e = Fixups.size(); i != e; ++i) |
| 408 | fixSymbolsInTLSFixups(Fixups[i].getValue()); |
| 409 | |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 410 | // There are several possibilities here: |
| 411 | // |
| 412 | // If bundling is disabled, append the encoded instruction to the current data |
| 413 | // fragment (or create a new such fragment if the current fragment is not a |
| 414 | // data fragment). |
| 415 | // |
| 416 | // If bundling is enabled: |
Eli Bendersky | 9ccb769 | 2013-01-15 23:22:09 +0000 | [diff] [blame] | 417 | // - If we're not in a bundle-locked group, emit the instruction into a |
| 418 | // fragment of its own. If there are no fixups registered for the |
| 419 | // instruction, emit a MCCompactEncodedInstFragment. Otherwise, emit a |
| 420 | // MCDataFragment. |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 421 | // - If we're in a bundle-locked group, append the instruction to the current |
| 422 | // data fragment because we want all the instructions in a group to get into |
| 423 | // the same fragment. Be careful not to do that for the first instruction in |
| 424 | // the group, though. |
| 425 | MCDataFragment *DF; |
| 426 | |
| 427 | if (Assembler.isBundlingEnabled()) { |
| 428 | MCSectionData *SD = getCurrentSectionData(); |
| 429 | if (SD->isBundleLocked() && !SD->isBundleGroupBeforeFirstInst()) |
Derek Schuff | 67144e3 | 2013-02-15 22:50:52 +0000 | [diff] [blame] | 430 | // If we are bundle-locked, we re-use the current fragment. |
| 431 | // The bundle-locking directive ensures this is a new data fragment. |
| 432 | DF = cast<MCDataFragment>(getCurrentFragment()); |
Eli Bendersky | 9ccb769 | 2013-01-15 23:22:09 +0000 | [diff] [blame] | 433 | else if (!SD->isBundleLocked() && Fixups.size() == 0) { |
| 434 | // Optimize memory usage by emitting the instruction to a |
| 435 | // MCCompactEncodedInstFragment when not in a bundle-locked group and |
| 436 | // there are no fixups registered. |
| 437 | MCCompactEncodedInstFragment *CEIF = new MCCompactEncodedInstFragment(SD); |
| 438 | CEIF->getContents().append(Code.begin(), Code.end()); |
| 439 | return; |
Derek Schuff | 67144e3 | 2013-02-15 22:50:52 +0000 | [diff] [blame] | 440 | } else { |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 441 | DF = new MCDataFragment(SD); |
Eli Bendersky | 6c1d497 | 2013-01-07 21:51:08 +0000 | [diff] [blame] | 442 | if (SD->getBundleLockState() == MCSectionData::BundleLockedAlignToEnd) { |
| 443 | // If this is a new fragment created for a bundle-locked group, and the |
| 444 | // group was marked as "align_to_end", set a flag in the fragment. |
| 445 | DF->setAlignToBundleEnd(true); |
| 446 | } |
| 447 | } |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 448 | |
| 449 | // We're now emitting an instruction in a bundle group, so this flag has |
| 450 | // to be turned off. |
| 451 | SD->setBundleGroupBeforeFirstInst(false); |
| 452 | } else { |
| 453 | DF = getOrCreateDataFragment(); |
| 454 | } |
| 455 | |
Benjamin Kramer | 93ded73 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 456 | // Add the fixups and data. |
| 457 | for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { |
| 458 | Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size()); |
Eli Bendersky | 64d9a32 | 2012-12-07 19:13:57 +0000 | [diff] [blame] | 459 | DF->getFixups().push_back(Fixups[i]); |
Benjamin Kramer | 93ded73 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 460 | } |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 461 | DF->setHasInstructions(true); |
Benjamin Kramer | 93ded73 | 2010-08-27 10:40:51 +0000 | [diff] [blame] | 462 | DF->getContents().append(Code.begin(), Code.end()); |
| 463 | } |
| 464 | |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 465 | void MCELFStreamer::EmitBundleAlignMode(unsigned AlignPow2) { |
| 466 | assert(AlignPow2 <= 30 && "Invalid bundle alignment"); |
| 467 | MCAssembler &Assembler = getAssembler(); |
| 468 | if (Assembler.getBundleAlignSize() == 0 && AlignPow2 > 0) |
| 469 | Assembler.setBundleAlignSize(1 << AlignPow2); |
| 470 | else |
| 471 | report_fatal_error(".bundle_align_mode should be only set once per file"); |
| 472 | } |
| 473 | |
Eli Bendersky | 6c1d497 | 2013-01-07 21:51:08 +0000 | [diff] [blame] | 474 | void MCELFStreamer::EmitBundleLock(bool AlignToEnd) { |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 475 | MCSectionData *SD = getCurrentSectionData(); |
| 476 | |
| 477 | // Sanity checks |
| 478 | // |
| 479 | if (!getAssembler().isBundlingEnabled()) |
| 480 | report_fatal_error(".bundle_lock forbidden when bundling is disabled"); |
| 481 | else if (SD->isBundleLocked()) |
| 482 | report_fatal_error("Nesting of .bundle_lock is forbidden"); |
| 483 | |
Eli Bendersky | 6c1d497 | 2013-01-07 21:51:08 +0000 | [diff] [blame] | 484 | SD->setBundleLockState(AlignToEnd ? MCSectionData::BundleLockedAlignToEnd : |
| 485 | MCSectionData::BundleLocked); |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 486 | SD->setBundleGroupBeforeFirstInst(true); |
| 487 | } |
| 488 | |
| 489 | void MCELFStreamer::EmitBundleUnlock() { |
| 490 | MCSectionData *SD = getCurrentSectionData(); |
| 491 | |
| 492 | // Sanity checks |
| 493 | if (!getAssembler().isBundlingEnabled()) |
| 494 | report_fatal_error(".bundle_unlock forbidden when bundling is disabled"); |
| 495 | else if (!SD->isBundleLocked()) |
| 496 | report_fatal_error(".bundle_unlock without matching lock"); |
| 497 | else if (SD->isBundleGroupBeforeFirstInst()) |
| 498 | report_fatal_error("Empty bundle-locked group is forbidden"); |
| 499 | |
Eli Bendersky | 6c1d497 | 2013-01-07 21:51:08 +0000 | [diff] [blame] | 500 | SD->setBundleLockState(MCSectionData::NotBundleLocked); |
Eli Bendersky | 4766ef4 | 2012-12-20 19:05:53 +0000 | [diff] [blame] | 501 | } |
| 502 | |
Rafael Espindola | 99b4237 | 2012-01-07 03:13:18 +0000 | [diff] [blame] | 503 | void MCELFStreamer::FinishImpl() { |
Rafael Espindola | c25dad8 | 2011-05-10 03:14:15 +0000 | [diff] [blame] | 504 | EmitFrames(true); |
Rafael Espindola | c70a1d9 | 2010-11-01 17:07:14 +0000 | [diff] [blame] | 505 | |
Rafael Espindola | 9e3922e | 2010-09-29 14:52:01 +0000 | [diff] [blame] | 506 | for (std::vector<LocalCommon>::const_iterator i = LocalCommons.begin(), |
| 507 | e = LocalCommons.end(); |
| 508 | i != e; ++i) { |
| 509 | MCSymbolData *SD = i->SD; |
| 510 | uint64_t Size = i->Size; |
| 511 | unsigned ByteAlignment = i->ByteAlignment; |
| 512 | const MCSymbol &Symbol = SD->getSymbol(); |
| 513 | const MCSection &Section = Symbol.getSection(); |
| 514 | |
| 515 | MCSectionData &SectData = getAssembler().getOrCreateSectionData(Section); |
| 516 | new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &SectData); |
| 517 | |
| 518 | MCFragment *F = new MCFillFragment(0, 0, Size, &SectData); |
| 519 | SD->setFragment(F); |
| 520 | |
| 521 | // Update the maximum alignment of the section if necessary. |
| 522 | if (ByteAlignment > SectData.getAlignment()) |
| 523 | SectData.setAlignment(ByteAlignment); |
| 524 | } |
| 525 | |
Rafael Espindola | 99b4237 | 2012-01-07 03:13:18 +0000 | [diff] [blame] | 526 | this->MCObjectStreamer::FinishImpl(); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 527 | } |
Tim Northover | 6eb3e87 | 2012-12-07 16:50:23 +0000 | [diff] [blame] | 528 | void MCELFStreamer::EmitTCEntry(const MCSymbol &S) { |
Adhemerval Zanella | f35c62b | 2012-10-15 15:43:14 +0000 | [diff] [blame] | 529 | // Creates a R_PPC64_TOC relocation |
Eric Christopher | 1ced208 | 2013-01-09 03:52:05 +0000 | [diff] [blame] | 530 | MCObjectStreamer::EmitSymbolValue(&S, 8); |
Adhemerval Zanella | f35c62b | 2012-10-15 15:43:14 +0000 | [diff] [blame] | 531 | } |
| 532 | |
Evan Cheng | 78c10ee | 2011-07-25 23:24:55 +0000 | [diff] [blame] | 533 | MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB, |
Rafael Espindola | 96aa78c | 2011-01-23 17:55:27 +0000 | [diff] [blame] | 534 | raw_ostream &OS, MCCodeEmitter *CE, |
| 535 | bool RelaxAll, bool NoExecStack) { |
Evan Cheng | 78c10ee | 2011-07-25 23:24:55 +0000 | [diff] [blame] | 536 | MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 537 | if (RelaxAll) |
| 538 | S->getAssembler().setRelaxAll(true); |
Rafael Espindola | 96aa78c | 2011-01-23 17:55:27 +0000 | [diff] [blame] | 539 | if (NoExecStack) |
| 540 | S->getAssembler().setNoExecStack(true); |
Matt Fleming | 3565a06 | 2010-08-16 18:57:57 +0000 | [diff] [blame] | 541 | return S; |
| 542 | } |
Logan Chien | 6450165 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 543 | |
Tim Northover | 6eb3e87 | 2012-12-07 16:50:23 +0000 | [diff] [blame] | 544 | void MCELFStreamer::EmitThumbFunc(MCSymbol *Func) { |
| 545 | llvm_unreachable("Generic ELF doesn't support this directive"); |
| 546 | } |
| 547 | |
Jack Carter | 77afbdc | 2013-02-19 21:57:35 +0000 | [diff] [blame] | 548 | MCSymbolData &MCELFStreamer::getOrCreateSymbolData(MCSymbol *Symbol) { |
| 549 | return getAssembler().getOrCreateSymbolData(*Symbol); |
| 550 | } |
| 551 | |
Logan Chien | 6450165 | 2012-12-07 15:50:40 +0000 | [diff] [blame] | 552 | void MCELFStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { |
| 553 | llvm_unreachable("ELF doesn't support this directive"); |
| 554 | } |
| 555 | |
| 556 | void MCELFStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) { |
| 557 | llvm_unreachable("ELF doesn't support this directive"); |
| 558 | } |
| 559 | |
| 560 | void MCELFStreamer::EmitCOFFSymbolStorageClass(int StorageClass) { |
| 561 | llvm_unreachable("ELF doesn't support this directive"); |
| 562 | } |
| 563 | |
| 564 | void MCELFStreamer::EmitCOFFSymbolType(int Type) { |
| 565 | llvm_unreachable("ELF doesn't support this directive"); |
| 566 | } |
| 567 | |
| 568 | void MCELFStreamer::EndCOFFSymbolDef() { |
| 569 | llvm_unreachable("ELF doesn't support this directive"); |
| 570 | } |
| 571 | |
| 572 | void MCELFStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, |
| 573 | uint64_t Size, unsigned ByteAlignment) { |
| 574 | llvm_unreachable("ELF doesn't support this directive"); |
| 575 | } |
| 576 | |
| 577 | void MCELFStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, |
| 578 | uint64_t Size, unsigned ByteAlignment) { |
| 579 | llvm_unreachable("ELF doesn't support this directive"); |
| 580 | } |