1 //===- lib/MC/ARMELFStreamer.cpp - ELF Object Output for ARM --------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file assembles .s files and emits ARM ELF .o object files. Different
11 // from generic ELF streamer in emitting mapping symbols ($a, $t and $d) to
12 // delimit regions of data and code.
14 //===----------------------------------------------------------------------===//
16 #include "ARMRegisterInfo.h"
17 #include "ARMUnwindOpAsm.h"
18 #include "llvm/ADT/StringExtras.h"
19 #include "llvm/ADT/Twine.h"
20 #include "llvm/MC/MCAsmBackend.h"
21 #include "llvm/MC/MCAsmInfo.h"
22 #include "llvm/MC/MCAssembler.h"
23 #include "llvm/MC/MCCodeEmitter.h"
24 #include "llvm/MC/MCContext.h"
25 #include "llvm/MC/MCELFStreamer.h"
26 #include "llvm/MC/MCExpr.h"
27 #include "llvm/MC/MCInst.h"
28 #include "llvm/MC/MCInstPrinter.h"
29 #include "llvm/MC/MCObjectFileInfo.h"
30 #include "llvm/MC/MCObjectStreamer.h"
31 #include "llvm/MC/MCRegisterInfo.h"
32 #include "llvm/MC/MCSection.h"
33 #include "llvm/MC/MCSectionELF.h"
34 #include "llvm/MC/MCStreamer.h"
35 #include "llvm/MC/MCSymbolELF.h"
36 #include "llvm/MC/MCValue.h"
37 #include "llvm/Support/ARMBuildAttributes.h"
38 #include "llvm/Support/ARMEHABI.h"
39 #include "llvm/Support/TargetParser.h"
40 #include "llvm/Support/Debug.h"
41 #include "llvm/Support/ELF.h"
42 #include "llvm/Support/FormattedStream.h"
43 #include "llvm/Support/LEB128.h"
44 #include "llvm/Support/raw_ostream.h"
49 static std::string GetAEABIUnwindPersonalityName(unsigned Index) {
50 assert(Index < ARM::EHABI::NUM_PERSONALITY_INDEX &&
51 "Invalid personality index");
52 return (Twine("__aeabi_unwind_cpp_pr") + Twine(Index)).str();
59 class ARMTargetAsmStreamer : public ARMTargetStreamer {
60 formatted_raw_ostream &OS;
61 MCInstPrinter &InstPrinter;
64 void emitFnStart() override;
65 void emitFnEnd() override;
66 void emitCantUnwind() override;
67 void emitPersonality(const MCSymbol *Personality) override;
68 void emitPersonalityIndex(unsigned Index) override;
69 void emitHandlerData() override;
70 void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0) override;
71 void emitMovSP(unsigned Reg, int64_t Offset = 0) override;
72 void emitPad(int64_t Offset) override;
73 void emitRegSave(const SmallVectorImpl<unsigned> &RegList,
74 bool isVector) override;
75 void emitUnwindRaw(int64_t Offset,
76 const SmallVectorImpl<uint8_t> &Opcodes) override;
78 void switchVendor(StringRef Vendor) override;
79 void emitAttribute(unsigned Attribute, unsigned Value) override;
80 void emitTextAttribute(unsigned Attribute, StringRef String) override;
81 void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
82 StringRef StringValue) override;
83 void emitArch(unsigned Arch) override;
84 void emitArchExtension(unsigned ArchExt) override;
85 void emitObjectArch(unsigned Arch) override;
86 void emitFPU(unsigned FPU) override;
87 void emitInst(uint32_t Inst, char Suffix = '\0') override;
88 void finishAttributeSection() override;
90 void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
91 void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) override;
94 ARMTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS,
95 MCInstPrinter &InstPrinter, bool VerboseAsm);
98 ARMTargetAsmStreamer::ARMTargetAsmStreamer(MCStreamer &S,
99 formatted_raw_ostream &OS,
100 MCInstPrinter &InstPrinter,
102 : ARMTargetStreamer(S), OS(OS), InstPrinter(InstPrinter),
103 IsVerboseAsm(VerboseAsm) {}
104 void ARMTargetAsmStreamer::emitFnStart() { OS << "\t.fnstart\n"; }
105 void ARMTargetAsmStreamer::emitFnEnd() { OS << "\t.fnend\n"; }
106 void ARMTargetAsmStreamer::emitCantUnwind() { OS << "\t.cantunwind\n"; }
107 void ARMTargetAsmStreamer::emitPersonality(const MCSymbol *Personality) {
108 OS << "\t.personality " << Personality->getName() << '\n';
110 void ARMTargetAsmStreamer::emitPersonalityIndex(unsigned Index) {
111 OS << "\t.personalityindex " << Index << '\n';
113 void ARMTargetAsmStreamer::emitHandlerData() { OS << "\t.handlerdata\n"; }
114 void ARMTargetAsmStreamer::emitSetFP(unsigned FpReg, unsigned SpReg,
117 InstPrinter.printRegName(OS, FpReg);
119 InstPrinter.printRegName(OS, SpReg);
121 OS << ", #" << Offset;
124 void ARMTargetAsmStreamer::emitMovSP(unsigned Reg, int64_t Offset) {
125 assert((Reg != ARM::SP && Reg != ARM::PC) &&
126 "the operand of .movsp cannot be either sp or pc");
129 InstPrinter.printRegName(OS, Reg);
131 OS << ", #" << Offset;
134 void ARMTargetAsmStreamer::emitPad(int64_t Offset) {
135 OS << "\t.pad\t#" << Offset << '\n';
137 void ARMTargetAsmStreamer::emitRegSave(const SmallVectorImpl<unsigned> &RegList,
139 assert(RegList.size() && "RegList should not be empty");
145 InstPrinter.printRegName(OS, RegList[0]);
147 for (unsigned i = 1, e = RegList.size(); i != e; ++i) {
149 InstPrinter.printRegName(OS, RegList[i]);
154 void ARMTargetAsmStreamer::switchVendor(StringRef Vendor) {
156 void ARMTargetAsmStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
157 OS << "\t.eabi_attribute\t" << Attribute << ", " << Twine(Value);
159 StringRef Name = ARMBuildAttrs::AttrTypeAsString(Attribute);
161 OS << "\t@ " << Name;
165 void ARMTargetAsmStreamer::emitTextAttribute(unsigned Attribute,
168 case ARMBuildAttrs::CPU_name:
169 OS << "\t.cpu\t" << String.lower();
172 OS << "\t.eabi_attribute\t" << Attribute << ", \"" << String << "\"";
174 StringRef Name = ARMBuildAttrs::AttrTypeAsString(Attribute);
176 OS << "\t@ " << Name;
182 void ARMTargetAsmStreamer::emitIntTextAttribute(unsigned Attribute,
184 StringRef StringValue) {
186 default: llvm_unreachable("unsupported multi-value attribute in asm mode");
187 case ARMBuildAttrs::compatibility:
188 OS << "\t.eabi_attribute\t" << Attribute << ", " << IntValue;
189 if (!StringValue.empty())
190 OS << ", \"" << StringValue << "\"";
192 OS << "\t@ " << ARMBuildAttrs::AttrTypeAsString(Attribute);
197 void ARMTargetAsmStreamer::emitArch(unsigned Arch) {
198 OS << "\t.arch\t" << ARM::getArchName(Arch) << "\n";
200 void ARMTargetAsmStreamer::emitArchExtension(unsigned ArchExt) {
201 OS << "\t.arch_extension\t" << ARM::getArchExtName(ArchExt) << "\n";
203 void ARMTargetAsmStreamer::emitObjectArch(unsigned Arch) {
204 OS << "\t.object_arch\t" << ARM::getArchName(Arch) << '\n';
206 void ARMTargetAsmStreamer::emitFPU(unsigned FPU) {
207 OS << "\t.fpu\t" << ARM::getFPUName(FPU) << "\n";
209 void ARMTargetAsmStreamer::finishAttributeSection() {
212 ARMTargetAsmStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
213 OS << "\t.tlsdescseq\t" << S->getSymbol().getName();
216 void ARMTargetAsmStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
217 const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo();
219 OS << "\t.thumb_set\t";
220 Symbol->print(OS, MAI);
222 Value->print(OS, MAI);
226 void ARMTargetAsmStreamer::emitInst(uint32_t Inst, char Suffix) {
230 OS << "\t0x" << Twine::utohexstr(Inst) << "\n";
233 void ARMTargetAsmStreamer::emitUnwindRaw(int64_t Offset,
234 const SmallVectorImpl<uint8_t> &Opcodes) {
235 OS << "\t.unwind_raw " << Offset;
236 for (SmallVectorImpl<uint8_t>::const_iterator OCI = Opcodes.begin(),
239 OS << ", 0x" << Twine::utohexstr(*OCI);
243 class ARMTargetELFStreamer : public ARMTargetStreamer {
245 // This structure holds all attributes, accounting for
246 // their string/numeric value, so we can later emit them
247 // in declaration order, keeping all in the same vector
248 struct AttributeItem {
253 NumericAndTextAttributes
257 std::string StringValue;
259 static bool LessTag(const AttributeItem &LHS, const AttributeItem &RHS) {
260 // The conformance tag must be emitted first when serialised
261 // into an object file. Specifically, the addenda to the ARM ABI
262 // states that (2.3.7.4):
264 // "To simplify recognition by consumers in the common case of
265 // claiming conformity for the whole file, this tag should be
266 // emitted first in a file-scope sub-subsection of the first
267 // public subsection of the attributes section."
269 // So it is special-cased in this comparison predicate when the
270 // attributes are sorted in finishAttributeSection().
271 return (RHS.Tag != ARMBuildAttrs::conformance) &&
272 ((LHS.Tag == ARMBuildAttrs::conformance) || (LHS.Tag < RHS.Tag));
276 StringRef CurrentVendor;
279 unsigned EmittedArch;
280 SmallVector<AttributeItem, 64> Contents;
282 MCSection *AttributeSection;
284 AttributeItem *getAttributeItem(unsigned Attribute) {
285 for (size_t i = 0; i < Contents.size(); ++i)
286 if (Contents[i].Tag == Attribute)
291 void setAttributeItem(unsigned Attribute, unsigned Value,
292 bool OverwriteExisting) {
293 // Look for existing attribute item
294 if (AttributeItem *Item = getAttributeItem(Attribute)) {
295 if (!OverwriteExisting)
297 Item->Type = AttributeItem::NumericAttribute;
298 Item->IntValue = Value;
302 // Create new attribute item
303 AttributeItem Item = {
304 AttributeItem::NumericAttribute,
309 Contents.push_back(Item);
312 void setAttributeItem(unsigned Attribute, StringRef Value,
313 bool OverwriteExisting) {
314 // Look for existing attribute item
315 if (AttributeItem *Item = getAttributeItem(Attribute)) {
316 if (!OverwriteExisting)
318 Item->Type = AttributeItem::TextAttribute;
319 Item->StringValue = Value;
323 // Create new attribute item
324 AttributeItem Item = {
325 AttributeItem::TextAttribute,
330 Contents.push_back(Item);
333 void setAttributeItems(unsigned Attribute, unsigned IntValue,
334 StringRef StringValue, bool OverwriteExisting) {
335 // Look for existing attribute item
336 if (AttributeItem *Item = getAttributeItem(Attribute)) {
337 if (!OverwriteExisting)
339 Item->Type = AttributeItem::NumericAndTextAttributes;
340 Item->IntValue = IntValue;
341 Item->StringValue = StringValue;
345 // Create new attribute item
346 AttributeItem Item = {
347 AttributeItem::NumericAndTextAttributes,
352 Contents.push_back(Item);
355 void emitArchDefaultAttributes();
356 void emitFPUDefaultAttributes();
358 ARMELFStreamer &getStreamer();
360 void emitFnStart() override;
361 void emitFnEnd() override;
362 void emitCantUnwind() override;
363 void emitPersonality(const MCSymbol *Personality) override;
364 void emitPersonalityIndex(unsigned Index) override;
365 void emitHandlerData() override;
366 void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0) override;
367 void emitMovSP(unsigned Reg, int64_t Offset = 0) override;
368 void emitPad(int64_t Offset) override;
369 void emitRegSave(const SmallVectorImpl<unsigned> &RegList,
370 bool isVector) override;
371 void emitUnwindRaw(int64_t Offset,
372 const SmallVectorImpl<uint8_t> &Opcodes) override;
374 void switchVendor(StringRef Vendor) override;
375 void emitAttribute(unsigned Attribute, unsigned Value) override;
376 void emitTextAttribute(unsigned Attribute, StringRef String) override;
377 void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
378 StringRef StringValue) override;
379 void emitArch(unsigned Arch) override;
380 void emitObjectArch(unsigned Arch) override;
381 void emitFPU(unsigned FPU) override;
382 void emitInst(uint32_t Inst, char Suffix = '\0') override;
383 void finishAttributeSection() override;
384 void emitLabel(MCSymbol *Symbol) override;
386 void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
387 void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) override;
389 size_t calculateContentSize() const;
391 // Reset state between object emissions
392 void reset() override;
395 ARMTargetELFStreamer(MCStreamer &S)
396 : ARMTargetStreamer(S), CurrentVendor("aeabi"), FPU(ARM::FK_INVALID),
397 Arch(ARM::AK_INVALID), EmittedArch(ARM::AK_INVALID),
398 AttributeSection(nullptr) {}
401 /// Extend the generic ELFStreamer class so that it can emit mapping symbols at
402 /// the appropriate points in the object files. These symbols are defined in the
403 /// ARM ELF ABI: infocenter.arm.com/help/topic/com.arm.../IHI0044D_aaelf.pdf.
405 /// In brief: $a, $t or $d should be emitted at the start of each contiguous
406 /// region of ARM code, Thumb code or data in a section. In practice, this
407 /// emission does not rely on explicit assembler directives but on inherent
408 /// properties of the directives doing the emission (e.g. ".byte" is data, "add
409 /// r0, r0, r0" an instruction).
411 /// As a result this system is orthogonal to the DataRegion infrastructure used
412 /// by MachO. Beware!
413 class ARMELFStreamer : public MCELFStreamer {
415 friend class ARMTargetELFStreamer;
417 ARMELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS,
418 MCCodeEmitter *Emitter, bool IsThumb)
419 : MCELFStreamer(Context, TAB, OS, Emitter), IsThumb(IsThumb),
420 MappingSymbolCounter(0), LastEMS(EMS_None) {
426 void FinishImpl() override;
428 // ARM exception handling directives
431 void emitCantUnwind();
432 void emitPersonality(const MCSymbol *Per);
433 void emitPersonalityIndex(unsigned index);
434 void emitHandlerData();
435 void emitSetFP(unsigned NewFpReg, unsigned NewSpReg, int64_t Offset = 0);
436 void emitMovSP(unsigned Reg, int64_t Offset = 0);
437 void emitPad(int64_t Offset);
438 void emitRegSave(const SmallVectorImpl<unsigned> &RegList, bool isVector);
439 void emitUnwindRaw(int64_t Offset, const SmallVectorImpl<uint8_t> &Opcodes);
441 void ChangeSection(MCSection *Section, const MCExpr *Subsection) override {
442 // We have to keep track of the mapping symbol state of any sections we
443 // use. Each one should start off as EMS_None, which is provided as the
444 // default constructor by DenseMap::lookup.
445 LastMappingSymbols[getPreviousSection().first] = LastEMS;
446 LastEMS = LastMappingSymbols.lookup(Section);
448 MCELFStreamer::ChangeSection(Section, Subsection);
451 /// This function is the one used to emit instruction data into the ELF
452 /// streamer. We override it to add the appropriate mapping symbol if
454 void EmitInstruction(const MCInst& Inst,
455 const MCSubtargetInfo &STI) override {
457 EmitThumbMappingSymbol();
459 EmitARMMappingSymbol();
461 MCELFStreamer::EmitInstruction(Inst, STI);
464 void emitInst(uint32_t Inst, char Suffix) {
467 const bool LittleEndian = getContext().getAsmInfo()->isLittleEndian();
474 EmitARMMappingSymbol();
475 for (unsigned II = 0, IE = Size; II != IE; II++) {
476 const unsigned I = LittleEndian ? (Size - II - 1) : II;
477 Buffer[Size - II - 1] = uint8_t(Inst >> I * CHAR_BIT);
483 Size = (Suffix == 'n' ? 2 : 4);
486 EmitThumbMappingSymbol();
487 for (unsigned II = 0, IE = Size; II != IE; II = II + 2) {
488 const unsigned I0 = LittleEndian ? II + 0 : (Size - II - 1);
489 const unsigned I1 = LittleEndian ? II + 1 : (Size - II - 2);
490 Buffer[Size - II - 2] = uint8_t(Inst >> I0 * CHAR_BIT);
491 Buffer[Size - II - 1] = uint8_t(Inst >> I1 * CHAR_BIT);
496 llvm_unreachable("Invalid Suffix");
499 MCELFStreamer::EmitBytes(StringRef(Buffer, Size));
502 /// This is one of the functions used to emit data into an ELF section, so the
503 /// ARM streamer overrides it to add the appropriate mapping symbol ($d) if
505 void EmitBytes(StringRef Data) override {
506 EmitDataMappingSymbol();
507 MCELFStreamer::EmitBytes(Data);
510 /// This is one of the functions used to emit data into an ELF section, so the
511 /// ARM streamer overrides it to add the appropriate mapping symbol ($d) if
513 void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override {
514 if (const MCSymbolRefExpr *SRE = dyn_cast_or_null<MCSymbolRefExpr>(Value))
515 if (SRE->getKind() == MCSymbolRefExpr::VK_ARM_SBREL && !(Size == 4)) {
516 getContext().reportError(Loc, "relocated expression must be 32-bit");
520 EmitDataMappingSymbol();
521 MCELFStreamer::EmitValueImpl(Value, Size, Loc);
524 void EmitAssemblerFlag(MCAssemblerFlag Flag) override {
525 MCELFStreamer::EmitAssemblerFlag(Flag);
528 case MCAF_SyntaxUnified:
529 return; // no-op here.
532 return; // Change to Thumb mode
535 return; // Change to ARM mode
538 case MCAF_SubsectionsViaSymbols:
544 enum ElfMappingSymbol {
551 void EmitDataMappingSymbol() {
552 if (LastEMS == EMS_Data) return;
553 EmitMappingSymbol("$d");
557 void EmitThumbMappingSymbol() {
558 if (LastEMS == EMS_Thumb) return;
559 EmitMappingSymbol("$t");
563 void EmitARMMappingSymbol() {
564 if (LastEMS == EMS_ARM) return;
565 EmitMappingSymbol("$a");
569 void EmitMappingSymbol(StringRef Name) {
570 auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
571 Name + "." + Twine(MappingSymbolCounter++)));
574 Symbol->setType(ELF::STT_NOTYPE);
575 Symbol->setBinding(ELF::STB_LOCAL);
576 Symbol->setExternal(false);
579 void EmitThumbFunc(MCSymbol *Func) override {
580 getAssembler().setIsThumbFunc(Func);
581 EmitSymbolAttribute(Func, MCSA_ELF_TypeFunction);
584 // Helper functions for ARM exception handling directives
587 // Reset state between object emissions
588 void reset() override;
590 void EmitPersonalityFixup(StringRef Name);
591 void FlushPendingOffset();
592 void FlushUnwindOpcodes(bool NoHandlerData);
594 void SwitchToEHSection(const char *Prefix, unsigned Type, unsigned Flags,
595 SectionKind Kind, const MCSymbol &Fn);
596 void SwitchToExTabSection(const MCSymbol &FnStart);
597 void SwitchToExIdxSection(const MCSymbol &FnStart);
599 void EmitFixup(const MCExpr *Expr, MCFixupKind Kind);
602 int64_t MappingSymbolCounter;
604 DenseMap<const MCSection *, ElfMappingSymbol> LastMappingSymbols;
605 ElfMappingSymbol LastEMS;
607 // ARM Exception Handling Frame Information
610 const MCSymbol *Personality;
611 unsigned PersonalityIndex;
612 unsigned FPReg; // Frame pointer register
613 int64_t FPOffset; // Offset: (final frame pointer) - (initial $sp)
614 int64_t SPOffset; // Offset: (final $sp) - (initial $sp)
615 int64_t PendingOffset; // Offset: (final $sp) - (emitted $sp)
618 SmallVector<uint8_t, 64> Opcodes;
619 UnwindOpcodeAssembler UnwindOpAsm;
621 } // end anonymous namespace
623 ARMELFStreamer &ARMTargetELFStreamer::getStreamer() {
624 return static_cast<ARMELFStreamer &>(Streamer);
627 void ARMTargetELFStreamer::emitFnStart() { getStreamer().emitFnStart(); }
628 void ARMTargetELFStreamer::emitFnEnd() { getStreamer().emitFnEnd(); }
629 void ARMTargetELFStreamer::emitCantUnwind() { getStreamer().emitCantUnwind(); }
630 void ARMTargetELFStreamer::emitPersonality(const MCSymbol *Personality) {
631 getStreamer().emitPersonality(Personality);
633 void ARMTargetELFStreamer::emitPersonalityIndex(unsigned Index) {
634 getStreamer().emitPersonalityIndex(Index);
636 void ARMTargetELFStreamer::emitHandlerData() {
637 getStreamer().emitHandlerData();
639 void ARMTargetELFStreamer::emitSetFP(unsigned FpReg, unsigned SpReg,
641 getStreamer().emitSetFP(FpReg, SpReg, Offset);
643 void ARMTargetELFStreamer::emitMovSP(unsigned Reg, int64_t Offset) {
644 getStreamer().emitMovSP(Reg, Offset);
646 void ARMTargetELFStreamer::emitPad(int64_t Offset) {
647 getStreamer().emitPad(Offset);
649 void ARMTargetELFStreamer::emitRegSave(const SmallVectorImpl<unsigned> &RegList,
651 getStreamer().emitRegSave(RegList, isVector);
653 void ARMTargetELFStreamer::emitUnwindRaw(int64_t Offset,
654 const SmallVectorImpl<uint8_t> &Opcodes) {
655 getStreamer().emitUnwindRaw(Offset, Opcodes);
657 void ARMTargetELFStreamer::switchVendor(StringRef Vendor) {
658 assert(!Vendor.empty() && "Vendor cannot be empty.");
660 if (CurrentVendor == Vendor)
663 if (!CurrentVendor.empty())
664 finishAttributeSection();
666 assert(Contents.empty() &&
667 ".ARM.attributes should be flushed before changing vendor");
668 CurrentVendor = Vendor;
671 void ARMTargetELFStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
672 setAttributeItem(Attribute, Value, /* OverwriteExisting= */ true);
674 void ARMTargetELFStreamer::emitTextAttribute(unsigned Attribute,
676 setAttributeItem(Attribute, Value, /* OverwriteExisting= */ true);
678 void ARMTargetELFStreamer::emitIntTextAttribute(unsigned Attribute,
680 StringRef StringValue) {
681 setAttributeItems(Attribute, IntValue, StringValue,
682 /* OverwriteExisting= */ true);
684 void ARMTargetELFStreamer::emitArch(unsigned Value) {
687 void ARMTargetELFStreamer::emitObjectArch(unsigned Value) {
690 void ARMTargetELFStreamer::emitArchDefaultAttributes() {
691 using namespace ARMBuildAttrs;
693 setAttributeItem(CPU_name,
694 ARM::getCPUAttr(Arch),
697 if (EmittedArch == ARM::AK_INVALID)
698 setAttributeItem(CPU_arch,
699 ARM::getArchAttr(Arch),
702 setAttributeItem(CPU_arch,
703 ARM::getArchAttr(EmittedArch),
712 setAttributeItem(ARM_ISA_use, Allowed, false);
717 case ARM::AK_ARMV5TE:
719 setAttributeItem(ARM_ISA_use, Allowed, false);
720 setAttributeItem(THUMB_ISA_use, Allowed, false);
723 case ARM::AK_ARMV6T2:
724 setAttributeItem(ARM_ISA_use, Allowed, false);
725 setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
729 case ARM::AK_ARMV6KZ:
730 setAttributeItem(ARM_ISA_use, Allowed, false);
731 setAttributeItem(THUMB_ISA_use, Allowed, false);
732 setAttributeItem(Virtualization_use, AllowTZ, false);
736 setAttributeItem(THUMB_ISA_use, Allowed, false);
740 setAttributeItem(CPU_arch_profile, ApplicationProfile, false);
741 setAttributeItem(ARM_ISA_use, Allowed, false);
742 setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
746 setAttributeItem(CPU_arch_profile, RealTimeProfile, false);
747 setAttributeItem(ARM_ISA_use, Allowed, false);
748 setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
752 setAttributeItem(CPU_arch_profile, MicroControllerProfile, false);
753 setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
757 case ARM::AK_ARMV8_1A:
758 case ARM::AK_ARMV8_2A:
759 setAttributeItem(CPU_arch_profile, ApplicationProfile, false);
760 setAttributeItem(ARM_ISA_use, Allowed, false);
761 setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
762 setAttributeItem(MPextension_use, Allowed, false);
763 setAttributeItem(Virtualization_use, AllowTZVirtualization, false);
767 setAttributeItem(ARM_ISA_use, Allowed, false);
768 setAttributeItem(THUMB_ISA_use, Allowed, false);
769 setAttributeItem(WMMX_arch, AllowWMMXv1, false);
772 case ARM::AK_IWMMXT2:
773 setAttributeItem(ARM_ISA_use, Allowed, false);
774 setAttributeItem(THUMB_ISA_use, Allowed, false);
775 setAttributeItem(WMMX_arch, AllowWMMXv2, false);
779 report_fatal_error("Unknown Arch: " + Twine(Arch));
783 void ARMTargetELFStreamer::emitFPU(unsigned Value) {
786 void ARMTargetELFStreamer::emitFPUDefaultAttributes() {
790 setAttributeItem(ARMBuildAttrs::FP_arch,
791 ARMBuildAttrs::AllowFPv2,
792 /* OverwriteExisting= */ false);
796 setAttributeItem(ARMBuildAttrs::FP_arch,
797 ARMBuildAttrs::AllowFPv3A,
798 /* OverwriteExisting= */ false);
801 case ARM::FK_VFPV3_FP16:
802 setAttributeItem(ARMBuildAttrs::FP_arch,
803 ARMBuildAttrs::AllowFPv3A,
804 /* OverwriteExisting= */ false);
805 setAttributeItem(ARMBuildAttrs::FP_HP_extension,
806 ARMBuildAttrs::AllowHPFP,
807 /* OverwriteExisting= */ false);
810 case ARM::FK_VFPV3_D16:
811 setAttributeItem(ARMBuildAttrs::FP_arch,
812 ARMBuildAttrs::AllowFPv3B,
813 /* OverwriteExisting= */ false);
816 case ARM::FK_VFPV3_D16_FP16:
817 setAttributeItem(ARMBuildAttrs::FP_arch,
818 ARMBuildAttrs::AllowFPv3B,
819 /* OverwriteExisting= */ false);
820 setAttributeItem(ARMBuildAttrs::FP_HP_extension,
821 ARMBuildAttrs::AllowHPFP,
822 /* OverwriteExisting= */ false);
825 case ARM::FK_VFPV3XD:
826 setAttributeItem(ARMBuildAttrs::FP_arch,
827 ARMBuildAttrs::AllowFPv3B,
828 /* OverwriteExisting= */ false);
830 case ARM::FK_VFPV3XD_FP16:
831 setAttributeItem(ARMBuildAttrs::FP_arch,
832 ARMBuildAttrs::AllowFPv3B,
833 /* OverwriteExisting= */ false);
834 setAttributeItem(ARMBuildAttrs::FP_HP_extension,
835 ARMBuildAttrs::AllowHPFP,
836 /* OverwriteExisting= */ false);
840 setAttributeItem(ARMBuildAttrs::FP_arch,
841 ARMBuildAttrs::AllowFPv4A,
842 /* OverwriteExisting= */ false);
845 // ABI_HardFP_use is handled in ARMAsmPrinter, so _SP_D16 is treated the same
847 case ARM::FK_FPV4_SP_D16:
848 case ARM::FK_VFPV4_D16:
849 setAttributeItem(ARMBuildAttrs::FP_arch,
850 ARMBuildAttrs::AllowFPv4B,
851 /* OverwriteExisting= */ false);
854 case ARM::FK_FP_ARMV8:
855 setAttributeItem(ARMBuildAttrs::FP_arch,
856 ARMBuildAttrs::AllowFPARMv8A,
857 /* OverwriteExisting= */ false);
860 // FPV5_D16 is identical to FP_ARMV8 except for the number of D registers, so
861 // uses the FP_ARMV8_D16 build attribute.
862 case ARM::FK_FPV5_SP_D16:
863 case ARM::FK_FPV5_D16:
864 setAttributeItem(ARMBuildAttrs::FP_arch,
865 ARMBuildAttrs::AllowFPARMv8B,
866 /* OverwriteExisting= */ false);
870 setAttributeItem(ARMBuildAttrs::FP_arch,
871 ARMBuildAttrs::AllowFPv3A,
872 /* OverwriteExisting= */ false);
873 setAttributeItem(ARMBuildAttrs::Advanced_SIMD_arch,
874 ARMBuildAttrs::AllowNeon,
875 /* OverwriteExisting= */ false);
878 case ARM::FK_NEON_FP16:
879 setAttributeItem(ARMBuildAttrs::FP_arch,
880 ARMBuildAttrs::AllowFPv3A,
881 /* OverwriteExisting= */ false);
882 setAttributeItem(ARMBuildAttrs::Advanced_SIMD_arch,
883 ARMBuildAttrs::AllowNeon,
884 /* OverwriteExisting= */ false);
885 setAttributeItem(ARMBuildAttrs::FP_HP_extension,
886 ARMBuildAttrs::AllowHPFP,
887 /* OverwriteExisting= */ false);
890 case ARM::FK_NEON_VFPV4:
891 setAttributeItem(ARMBuildAttrs::FP_arch,
892 ARMBuildAttrs::AllowFPv4A,
893 /* OverwriteExisting= */ false);
894 setAttributeItem(ARMBuildAttrs::Advanced_SIMD_arch,
895 ARMBuildAttrs::AllowNeon2,
896 /* OverwriteExisting= */ false);
899 case ARM::FK_NEON_FP_ARMV8:
900 case ARM::FK_CRYPTO_NEON_FP_ARMV8:
901 setAttributeItem(ARMBuildAttrs::FP_arch,
902 ARMBuildAttrs::AllowFPARMv8A,
903 /* OverwriteExisting= */ false);
904 // 'Advanced_SIMD_arch' must be emitted not here, but within
905 // ARMAsmPrinter::emitAttributes(), depending on hasV8Ops() and hasV8_1a()
908 case ARM::FK_SOFTVFP:
913 report_fatal_error("Unknown FPU: " + Twine(FPU));
917 size_t ARMTargetELFStreamer::calculateContentSize() const {
919 for (size_t i = 0; i < Contents.size(); ++i) {
920 AttributeItem item = Contents[i];
922 case AttributeItem::HiddenAttribute:
924 case AttributeItem::NumericAttribute:
925 Result += getULEB128Size(item.Tag);
926 Result += getULEB128Size(item.IntValue);
928 case AttributeItem::TextAttribute:
929 Result += getULEB128Size(item.Tag);
930 Result += item.StringValue.size() + 1; // string + '\0'
932 case AttributeItem::NumericAndTextAttributes:
933 Result += getULEB128Size(item.Tag);
934 Result += getULEB128Size(item.IntValue);
935 Result += item.StringValue.size() + 1; // string + '\0';
941 void ARMTargetELFStreamer::finishAttributeSection() {
943 // [ <section-length> "vendor-name"
944 // [ <file-tag> <size> <attribute>*
945 // | <section-tag> <size> <section-number>* 0 <attribute>*
946 // | <symbol-tag> <size> <symbol-number>* 0 <attribute>*
950 if (FPU != ARM::FK_INVALID)
951 emitFPUDefaultAttributes();
953 if (Arch != ARM::AK_INVALID)
954 emitArchDefaultAttributes();
956 if (Contents.empty())
959 std::sort(Contents.begin(), Contents.end(), AttributeItem::LessTag);
961 ARMELFStreamer &Streamer = getStreamer();
963 // Switch to .ARM.attributes section
964 if (AttributeSection) {
965 Streamer.SwitchSection(AttributeSection);
967 AttributeSection = Streamer.getContext().getELFSection(
968 ".ARM.attributes", ELF::SHT_ARM_ATTRIBUTES, 0);
969 Streamer.SwitchSection(AttributeSection);
972 Streamer.EmitIntValue(0x41, 1);
975 // Vendor size + Vendor name + '\0'
976 const size_t VendorHeaderSize = 4 + CurrentVendor.size() + 1;
979 const size_t TagHeaderSize = 1 + 4;
981 const size_t ContentsSize = calculateContentSize();
983 Streamer.EmitIntValue(VendorHeaderSize + TagHeaderSize + ContentsSize, 4);
984 Streamer.EmitBytes(CurrentVendor);
985 Streamer.EmitIntValue(0, 1); // '\0'
987 Streamer.EmitIntValue(ARMBuildAttrs::File, 1);
988 Streamer.EmitIntValue(TagHeaderSize + ContentsSize, 4);
990 // Size should have been accounted for already, now
991 // emit each field as its type (ULEB or String)
992 for (size_t i = 0; i < Contents.size(); ++i) {
993 AttributeItem item = Contents[i];
994 Streamer.EmitULEB128IntValue(item.Tag);
996 default: llvm_unreachable("Invalid attribute type");
997 case AttributeItem::NumericAttribute:
998 Streamer.EmitULEB128IntValue(item.IntValue);
1000 case AttributeItem::TextAttribute:
1001 Streamer.EmitBytes(item.StringValue);
1002 Streamer.EmitIntValue(0, 1); // '\0'
1004 case AttributeItem::NumericAndTextAttributes:
1005 Streamer.EmitULEB128IntValue(item.IntValue);
1006 Streamer.EmitBytes(item.StringValue);
1007 Streamer.EmitIntValue(0, 1); // '\0'
1013 FPU = ARM::FK_INVALID;
1016 void ARMTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
1017 ARMELFStreamer &Streamer = getStreamer();
1018 if (!Streamer.IsThumb)
1021 Streamer.getAssembler().registerSymbol(*Symbol);
1022 unsigned Type = cast<MCSymbolELF>(Symbol)->getType();
1023 if (Type == ELF::STT_FUNC || Type == ELF::STT_GNU_IFUNC)
1024 Streamer.EmitThumbFunc(Symbol);
1028 ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
1029 getStreamer().EmitFixup(S, FK_Data_4);
1032 void ARMTargetELFStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
1033 if (const MCSymbolRefExpr *SRE = dyn_cast<MCSymbolRefExpr>(Value)) {
1034 const MCSymbol &Sym = SRE->getSymbol();
1035 if (!Sym.isDefined()) {
1036 getStreamer().EmitAssignment(Symbol, Value);
1041 getStreamer().EmitThumbFunc(Symbol);
1042 getStreamer().EmitAssignment(Symbol, Value);
1045 void ARMTargetELFStreamer::emitInst(uint32_t Inst, char Suffix) {
1046 getStreamer().emitInst(Inst, Suffix);
1049 void ARMTargetELFStreamer::reset() { AttributeSection = nullptr; }
1051 void ARMELFStreamer::FinishImpl() {
1052 MCTargetStreamer &TS = *getTargetStreamer();
1053 ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
1054 ATS.finishAttributeSection();
1056 MCELFStreamer::FinishImpl();
1059 void ARMELFStreamer::reset() {
1060 MCTargetStreamer &TS = *getTargetStreamer();
1061 ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
1063 MappingSymbolCounter = 0;
1064 MCELFStreamer::reset();
1065 // MCELFStreamer clear's the assembler's e_flags. However, for
1066 // arm we manually set the ABI version on streamer creation, so
1068 getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
1071 inline void ARMELFStreamer::SwitchToEHSection(const char *Prefix,
1075 const MCSymbol &Fn) {
1076 const MCSectionELF &FnSection =
1077 static_cast<const MCSectionELF &>(Fn.getSection());
1079 // Create the name for new section
1080 StringRef FnSecName(FnSection.getSectionName());
1081 SmallString<128> EHSecName(Prefix);
1082 if (FnSecName != ".text") {
1083 EHSecName += FnSecName;
1086 // Get .ARM.extab or .ARM.exidx section
1087 const MCSymbolELF *Group = FnSection.getGroup();
1089 Flags |= ELF::SHF_GROUP;
1090 MCSectionELF *EHSection =
1091 getContext().getELFSection(EHSecName, Type, Flags, 0, Group,
1092 FnSection.getUniqueID(), nullptr, &FnSection);
1094 assert(EHSection && "Failed to get the required EH section");
1096 // Switch to .ARM.extab or .ARM.exidx section
1097 SwitchSection(EHSection);
1098 EmitCodeAlignment(4);
1101 inline void ARMELFStreamer::SwitchToExTabSection(const MCSymbol &FnStart) {
1102 SwitchToEHSection(".ARM.extab", ELF::SHT_PROGBITS, ELF::SHF_ALLOC,
1103 SectionKind::getData(), FnStart);
1106 inline void ARMELFStreamer::SwitchToExIdxSection(const MCSymbol &FnStart) {
1107 SwitchToEHSection(".ARM.exidx", ELF::SHT_ARM_EXIDX,
1108 ELF::SHF_ALLOC | ELF::SHF_LINK_ORDER,
1109 SectionKind::getData(), FnStart);
1111 void ARMELFStreamer::EmitFixup(const MCExpr *Expr, MCFixupKind Kind) {
1112 MCDataFragment *Frag = getOrCreateDataFragment();
1113 Frag->getFixups().push_back(MCFixup::create(Frag->getContents().size(), Expr,
1117 void ARMELFStreamer::EHReset() {
1120 Personality = nullptr;
1121 PersonalityIndex = ARM::EHABI::NUM_PERSONALITY_INDEX;
1130 UnwindOpAsm.Reset();
1133 void ARMELFStreamer::emitFnStart() {
1134 assert(FnStart == nullptr);
1135 FnStart = getContext().createTempSymbol();
1139 void ARMELFStreamer::emitFnEnd() {
1140 assert(FnStart && ".fnstart must precedes .fnend");
1142 // Emit unwind opcodes if there is no .handlerdata directive
1143 if (!ExTab && !CantUnwind)
1144 FlushUnwindOpcodes(true);
1146 // Emit the exception index table entry
1147 SwitchToExIdxSection(*FnStart);
1149 if (PersonalityIndex < ARM::EHABI::NUM_PERSONALITY_INDEX)
1150 EmitPersonalityFixup(GetAEABIUnwindPersonalityName(PersonalityIndex));
1152 const MCSymbolRefExpr *FnStartRef =
1153 MCSymbolRefExpr::create(FnStart,
1154 MCSymbolRefExpr::VK_ARM_PREL31,
1157 EmitValue(FnStartRef, 4);
1160 EmitIntValue(ARM::EHABI::EXIDX_CANTUNWIND, 4);
1162 // Emit a reference to the unwind opcodes in the ".ARM.extab" section.
1163 const MCSymbolRefExpr *ExTabEntryRef =
1164 MCSymbolRefExpr::create(ExTab,
1165 MCSymbolRefExpr::VK_ARM_PREL31,
1167 EmitValue(ExTabEntryRef, 4);
1169 // For the __aeabi_unwind_cpp_pr0, we have to emit the unwind opcodes in
1170 // the second word of exception index table entry. The size of the unwind
1171 // opcodes should always be 4 bytes.
1172 assert(PersonalityIndex == ARM::EHABI::AEABI_UNWIND_CPP_PR0 &&
1173 "Compact model must use __aeabi_unwind_cpp_pr0 as personality");
1174 assert(Opcodes.size() == 4u &&
1175 "Unwind opcode size for __aeabi_unwind_cpp_pr0 must be equal to 4");
1176 uint64_t Intval = Opcodes[0] |
1180 EmitIntValue(Intval, Opcodes.size());
1183 // Switch to the section containing FnStart
1184 SwitchSection(&FnStart->getSection());
1186 // Clean exception handling frame information
1190 void ARMELFStreamer::emitCantUnwind() { CantUnwind = true; }
1192 // Add the R_ARM_NONE fixup at the same position
1193 void ARMELFStreamer::EmitPersonalityFixup(StringRef Name) {
1194 const MCSymbol *PersonalitySym = getContext().getOrCreateSymbol(Name);
1196 const MCSymbolRefExpr *PersonalityRef = MCSymbolRefExpr::create(
1197 PersonalitySym, MCSymbolRefExpr::VK_ARM_NONE, getContext());
1199 visitUsedExpr(*PersonalityRef);
1200 MCDataFragment *DF = getOrCreateDataFragment();
1201 DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
1203 MCFixup::getKindForSize(4, false)));
1206 void ARMELFStreamer::FlushPendingOffset() {
1207 if (PendingOffset != 0) {
1208 UnwindOpAsm.EmitSPOffset(-PendingOffset);
1213 void ARMELFStreamer::FlushUnwindOpcodes(bool NoHandlerData) {
1214 // Emit the unwind opcode to restore $sp.
1216 const MCRegisterInfo *MRI = getContext().getRegisterInfo();
1217 int64_t LastRegSaveSPOffset = SPOffset - PendingOffset;
1218 UnwindOpAsm.EmitSPOffset(LastRegSaveSPOffset - FPOffset);
1219 UnwindOpAsm.EmitSetSP(MRI->getEncodingValue(FPReg));
1221 FlushPendingOffset();
1224 // Finalize the unwind opcode sequence
1225 UnwindOpAsm.Finalize(PersonalityIndex, Opcodes);
1227 // For compact model 0, we have to emit the unwind opcodes in the .ARM.exidx
1228 // section. Thus, we don't have to create an entry in the .ARM.extab
1230 if (NoHandlerData && PersonalityIndex == ARM::EHABI::AEABI_UNWIND_CPP_PR0)
1233 // Switch to .ARM.extab section.
1234 SwitchToExTabSection(*FnStart);
1236 // Create .ARM.extab label for offset in .ARM.exidx
1238 ExTab = getContext().createTempSymbol();
1243 const MCSymbolRefExpr *PersonalityRef =
1244 MCSymbolRefExpr::create(Personality,
1245 MCSymbolRefExpr::VK_ARM_PREL31,
1248 EmitValue(PersonalityRef, 4);
1251 // Emit unwind opcodes
1252 assert((Opcodes.size() % 4) == 0 &&
1253 "Unwind opcode size for __aeabi_cpp_unwind_pr0 must be multiple of 4");
1254 for (unsigned I = 0; I != Opcodes.size(); I += 4) {
1255 uint64_t Intval = Opcodes[I] |
1256 Opcodes[I + 1] << 8 |
1257 Opcodes[I + 2] << 16 |
1258 Opcodes[I + 3] << 24;
1259 EmitIntValue(Intval, 4);
1262 // According to ARM EHABI section 9.2, if the __aeabi_unwind_cpp_pr1() or
1263 // __aeabi_unwind_cpp_pr2() is used, then the handler data must be emitted
1264 // after the unwind opcodes. The handler data consists of several 32-bit
1265 // words, and should be terminated by zero.
1267 // In case that the .handlerdata directive is not specified by the
1268 // programmer, we should emit zero to terminate the handler data.
1269 if (NoHandlerData && !Personality)
1273 void ARMELFStreamer::emitHandlerData() { FlushUnwindOpcodes(false); }
1275 void ARMELFStreamer::emitPersonality(const MCSymbol *Per) {
1277 UnwindOpAsm.setPersonality(Per);
1280 void ARMELFStreamer::emitPersonalityIndex(unsigned Index) {
1281 assert(Index < ARM::EHABI::NUM_PERSONALITY_INDEX && "invalid index");
1282 PersonalityIndex = Index;
1285 void ARMELFStreamer::emitSetFP(unsigned NewFPReg, unsigned NewSPReg,
1287 assert((NewSPReg == ARM::SP || NewSPReg == FPReg) &&
1288 "the operand of .setfp directive should be either $sp or $fp");
1293 if (NewSPReg == ARM::SP)
1294 FPOffset = SPOffset + Offset;
1299 void ARMELFStreamer::emitMovSP(unsigned Reg, int64_t Offset) {
1300 assert((Reg != ARM::SP && Reg != ARM::PC) &&
1301 "the operand of .movsp cannot be either sp or pc");
1302 assert(FPReg == ARM::SP && "current FP must be SP");
1304 FlushPendingOffset();
1307 FPOffset = SPOffset + Offset;
1309 const MCRegisterInfo *MRI = getContext().getRegisterInfo();
1310 UnwindOpAsm.EmitSetSP(MRI->getEncodingValue(FPReg));
1313 void ARMELFStreamer::emitPad(int64_t Offset) {
1314 // Track the change of the $sp offset
1317 // To squash multiple .pad directives, we should delay the unwind opcode
1318 // until the .save, .vsave, .handlerdata, or .fnend directives.
1319 PendingOffset -= Offset;
1322 void ARMELFStreamer::emitRegSave(const SmallVectorImpl<unsigned> &RegList,
1324 // Collect the registers in the register list
1327 const MCRegisterInfo *MRI = getContext().getRegisterInfo();
1328 for (size_t i = 0; i < RegList.size(); ++i) {
1329 unsigned Reg = MRI->getEncodingValue(RegList[i]);
1330 assert(Reg < (IsVector ? 32U : 16U) && "Register out of range");
1331 unsigned Bit = (1u << Reg);
1332 if ((Mask & Bit) == 0) {
1338 // Track the change the $sp offset: For the .save directive, the
1339 // corresponding push instruction will decrease the $sp by (4 * Count).
1340 // For the .vsave directive, the corresponding vpush instruction will
1341 // decrease $sp by (8 * Count).
1342 SPOffset -= Count * (IsVector ? 8 : 4);
1345 FlushPendingOffset();
1347 UnwindOpAsm.EmitVFPRegSave(Mask);
1349 UnwindOpAsm.EmitRegSave(Mask);
1352 void ARMELFStreamer::emitUnwindRaw(int64_t Offset,
1353 const SmallVectorImpl<uint8_t> &Opcodes) {
1354 FlushPendingOffset();
1355 SPOffset = SPOffset - Offset;
1356 UnwindOpAsm.EmitRaw(Opcodes);
1361 MCTargetStreamer *createARMTargetAsmStreamer(MCStreamer &S,
1362 formatted_raw_ostream &OS,
1363 MCInstPrinter *InstPrint,
1364 bool isVerboseAsm) {
1365 return new ARMTargetAsmStreamer(S, OS, *InstPrint, isVerboseAsm);
1368 MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S) {
1369 return new ARMTargetStreamer(S);
1372 MCTargetStreamer *createARMObjectTargetStreamer(MCStreamer &S,
1373 const MCSubtargetInfo &STI) {
1374 const Triple &TT = STI.getTargetTriple();
1375 if (TT.isOSBinFormatELF())
1376 return new ARMTargetELFStreamer(S);
1377 return new ARMTargetStreamer(S);
1380 MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
1381 raw_pwrite_stream &OS,
1382 MCCodeEmitter *Emitter, bool RelaxAll,
1384 ARMELFStreamer *S = new ARMELFStreamer(Context, TAB, OS, Emitter, IsThumb);
1385 // FIXME: This should eventually end up somewhere else where more
1386 // intelligent flag decisions can be made. For now we are just maintaining
1387 // the status quo for ARM and setting EF_ARM_EABI_VER5 as the default.
1388 S->getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
1391 S->getAssembler().setRelaxAll(true);