1 //===- MCAsmInfoDarwin.cpp - Darwin asm properties ------------------------===//
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 defines target asm properties related what form asm statements
11 // should take in general on Darwin-based targets
13 //===----------------------------------------------------------------------===//
15 #include "llvm/MC/MCAsmInfoDarwin.h"
16 #include "llvm/BinaryFormat/MachO.h"
17 #include "llvm/MC/MCDirectives.h"
18 #include "llvm/MC/MCSectionMachO.h"
22 bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(
23 const MCSection &Section) const {
24 const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);
26 // Sections holding 1 byte strings are atomized based on the data they
28 // Sections holding 2 byte strings require symbols in order to be atomized.
29 // There is no dedicated section for 4 byte strings.
30 if (SMO.getType() == MachO::S_CSTRING_LITERALS)
33 if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
36 if (SMO.getSegmentName() == "__DATA" &&
37 SMO.getSectionName() == "__objc_classrefs")
40 switch (SMO.getType()) {
44 // These sections are atomized at the element boundaries without using
46 case MachO::S_4BYTE_LITERALS:
47 case MachO::S_8BYTE_LITERALS:
48 case MachO::S_16BYTE_LITERALS:
49 case MachO::S_LITERAL_POINTERS:
50 case MachO::S_NON_LAZY_SYMBOL_POINTERS:
51 case MachO::S_LAZY_SYMBOL_POINTERS:
52 case MachO::S_THREAD_LOCAL_VARIABLE_POINTERS:
53 case MachO::S_MOD_INIT_FUNC_POINTERS:
54 case MachO::S_MOD_TERM_FUNC_POINTERS:
55 case MachO::S_INTERPOSING:
60 MCAsmInfoDarwin::MCAsmInfoDarwin() {
61 // Common settings for all Darwin targets.
63 LinkerPrivateGlobalPrefix = "l";
64 HasSingleParameterDotFile = false;
65 HasSubsectionsViaSymbols = true;
67 AlignmentIsInBytes = false;
68 COMMDirectiveAlignmentIsInBytes = false;
69 LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
70 InlineAsmStart = " InlineAsm Start";
71 InlineAsmEnd = " InlineAsm End";
74 HasWeakDefDirective = true;
75 HasWeakDefCanBeHiddenDirective = true;
76 WeakRefDirective = "\t.weak_reference ";
77 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
78 HasMachoZeroFillDirective = true; // Uses .zerofill
79 HasMachoTBSSDirective = true; // Uses .tbss
81 // FIXME: Change this once MC is the system assembler.
82 HasAggressiveSymbolFolding = false;
84 HiddenVisibilityAttr = MCSA_PrivateExtern;
85 HiddenDeclarationVisibilityAttr = MCSA_Invalid;
87 // Doesn't support protected visibility.
88 ProtectedVisibilityAttr = MCSA_Invalid;
90 HasDotTypeDotSizeDirective = false;
91 HasNoDeadStrip = true;
94 DwarfUsesRelocationsAcrossSections = false;
96 UseIntegratedAssembler = true;
97 SetDirectiveSuppressesReloc = true;