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