Path: blob/main/contrib/llvm-project/llvm/lib/MC/MCAsmInfoDarwin.cpp
35233 views
//===- MCAsmInfoDarwin.cpp - Darwin asm properties ------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file defines target asm properties related what form asm statements9// should take in general on Darwin-based targets10//11//===----------------------------------------------------------------------===//1213#include "llvm/MC/MCAsmInfoDarwin.h"14#include "llvm/BinaryFormat/MachO.h"15#include "llvm/MC/MCDirectives.h"16#include "llvm/MC/MCSectionMachO.h"1718using namespace llvm;1920bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(21const MCSection &Section) {22const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);2324// Sections holding 1 byte strings are atomized based on the data they25// contain.26// Sections holding 2 byte strings require symbols in order to be atomized.27// There is no dedicated section for 4 byte strings.28if (SMO.getType() == MachO::S_CSTRING_LITERALS)29return false;3031if (SMO.getSegmentName() == "__DATA" && SMO.getName() == "__cfstring")32return false;3334if (SMO.getSegmentName() == "__DATA" && SMO.getName() == "__objc_classrefs")35return false;3637switch (SMO.getType()) {38default:39return true;4041// These sections are atomized at the element boundaries without using42// symbols.43case MachO::S_4BYTE_LITERALS:44case MachO::S_8BYTE_LITERALS:45case MachO::S_16BYTE_LITERALS:46case MachO::S_LITERAL_POINTERS:47case MachO::S_NON_LAZY_SYMBOL_POINTERS:48case MachO::S_LAZY_SYMBOL_POINTERS:49case MachO::S_THREAD_LOCAL_VARIABLE_POINTERS:50case MachO::S_MOD_INIT_FUNC_POINTERS:51case MachO::S_MOD_TERM_FUNC_POINTERS:52case MachO::S_INTERPOSING:53return false;54}55}5657MCAsmInfoDarwin::MCAsmInfoDarwin() {58// Common settings for all Darwin targets.59// Syntax:60LinkerPrivateGlobalPrefix = "l";61HasSingleParameterDotFile = false;62HasSubsectionsViaSymbols = true;6364AlignmentIsInBytes = false;65COMMDirectiveAlignmentIsInBytes = false;66LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;67InlineAsmStart = " InlineAsm Start";68InlineAsmEnd = " InlineAsm End";6970// Directives:71HasWeakDefDirective = true;72HasWeakDefCanBeHiddenDirective = true;73WeakRefDirective = "\t.weak_reference ";74ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.75HasMachoZeroFillDirective = true; // Uses .zerofill76HasMachoTBSSDirective = true; // Uses .tbss7778// FIXME: Change this once MC is the system assembler.79HasAggressiveSymbolFolding = false;8081HiddenVisibilityAttr = MCSA_PrivateExtern;82HiddenDeclarationVisibilityAttr = MCSA_Invalid;8384// Doesn't support protected visibility.85ProtectedVisibilityAttr = MCSA_Invalid;8687HasDotTypeDotSizeDirective = false;88HasNoDeadStrip = true;89HasAltEntry = true;9091DwarfUsesRelocationsAcrossSections = false;92SetDirectiveSuppressesReloc = true;93}949596