1 //===-- MCAsmInfoDarwin.cpp - Darwin asm properties -------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file defines target asm properties related what form asm statements 11 // should take in general on Darwin-based targets 12 // 13 //===----------------------------------------------------------------------===// 14 15 #include "llvm/MC/MCAsmInfoDarwin.h" 16 #include "llvm/MC/MCContext.h" 17 #include "llvm/MC/MCExpr.h" 18 #include "llvm/MC/MCSectionMachO.h" 19 using namespace llvm; 20 isSectionAtomizableBySymbols(const MCSection & Section) const21bool MCAsmInfoDarwin::isSectionAtomizableBySymbols( 22 const MCSection &Section) const { 23 const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section); 24 25 // Sections holding 1 byte strings are atomized based on the data they 26 // contain. 27 // Sections holding 2 byte strings require symbols in order to be atomized. 28 // There is no dedicated section for 4 byte strings. 29 if (SMO.getType() == MachO::S_CSTRING_LITERALS) 30 return false; 31 32 if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring") 33 return false; 34 35 if (SMO.getSegmentName() == "__DATA" && 36 SMO.getSectionName() == "__objc_classrefs") 37 return false; 38 39 switch (SMO.getType()) { 40 default: 41 return true; 42 43 // These sections are atomized at the element boundaries without using 44 // symbols. 45 case MachO::S_4BYTE_LITERALS: 46 case MachO::S_8BYTE_LITERALS: 47 case MachO::S_16BYTE_LITERALS: 48 case MachO::S_LITERAL_POINTERS: 49 case MachO::S_NON_LAZY_SYMBOL_POINTERS: 50 case MachO::S_LAZY_SYMBOL_POINTERS: 51 case MachO::S_MOD_INIT_FUNC_POINTERS: 52 case MachO::S_MOD_TERM_FUNC_POINTERS: 53 case MachO::S_INTERPOSING: 54 return false; 55 } 56 } 57 MCAsmInfoDarwin()58MCAsmInfoDarwin::MCAsmInfoDarwin() { 59 // Common settings for all Darwin targets. 60 // Syntax: 61 LinkerPrivateGlobalPrefix = "l"; 62 HasSingleParameterDotFile = false; 63 HasSubsectionsViaSymbols = true; 64 65 AlignmentIsInBytes = false; 66 COMMDirectiveAlignmentIsInBytes = false; 67 LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment; 68 InlineAsmStart = " InlineAsm Start"; 69 InlineAsmEnd = " InlineAsm End"; 70 71 // Directives: 72 HasWeakDefDirective = true; 73 HasWeakDefCanBeHiddenDirective = true; 74 WeakRefDirective = "\t.weak_reference "; 75 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. 76 HasMachoZeroFillDirective = true; // Uses .zerofill 77 HasMachoTBSSDirective = true; // Uses .tbss 78 HasStaticCtorDtorReferenceInStaticMode = true; 79 80 // FIXME: Change this once MC is the system assembler. 81 HasAggressiveSymbolFolding = false; 82 83 HiddenVisibilityAttr = MCSA_PrivateExtern; 84 HiddenDeclarationVisibilityAttr = MCSA_Invalid; 85 86 // Doesn't support protected visibility. 87 ProtectedVisibilityAttr = MCSA_Invalid; 88 89 HasDotTypeDotSizeDirective = false; 90 HasNoDeadStrip = true; 91 92 DwarfUsesRelocationsAcrossSections = false; 93 94 UseIntegratedAssembler = true; 95 SetDirectiveSuppressesReloc = true; 96 } 97