//===- lib/MC/MCAssembler.cpp - Assembler Backend Implementation ----------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===//#define DEBUG_TYPE "assembler"#include"llvm/MC/MCAssembler.h"#include"llvm/MC/MCExpr.h"#include"llvm/MC/MCSectionMachO.h"#include"llvm/MC/MCSymbol.h"#include"llvm/MC/MCValue.h"#include"llvm/ADT/DenseMap.h"#include"llvm/ADT/SmallString.h"#include"llvm/ADT/Statistic.h"#include"llvm/ADT/StringExtras.h"#include"llvm/ADT/StringMap.h"#include"llvm/ADT/Twine.h"#include"llvm/Support/ErrorHandling.h"#include"llvm/Support/MachO.h"#include"llvm/Support/raw_ostream.h"#include"llvm/Support/Debug.h"#include<vector>usingnamespacellvm;classMachObjectWriter;STATISTIC(EmittedFragments,"Number of emitted assembler fragments");// FIXME FIXME FIXME: There are number of places in this file where we convert// what is a 64-bit assembler value used for computation into a value in the// object file, which may truncate it. We should detect that truncation where// invalid and report errors back.staticvoidWriteFileData(raw_ostream&OS,constMCSectionData&SD,MachObjectWriter&MOW);/// isVirtualSection - Check if this is a section which does not actually exist/// in the object file.staticboolisVirtualSection(constMCSection&Section){// FIXME: Lame.constMCSectionMachO&SMO=static_cast<constMCSectionMachO&>(Section);unsignedType=SMO.getTypeAndAttributes()&MCSectionMachO::SECTION_TYPE;return(Type==MCSectionMachO::S_ZEROFILL);}classMachObjectWriter{// See <mach-o/loader.h>.enum{Header_Magic32=0xFEEDFACE,Header_Magic64=0xFEEDFACF};staticconstunsignedHeader32Size=28;staticconstunsignedHeader64Size=32;staticconstunsignedSegmentLoadCommand32Size=56;staticconstunsignedSection32Size=68;staticconstunsignedSymtabLoadCommandSize=24;staticconstunsignedDysymtabLoadCommandSize=80;staticconstunsignedNlist32Size=12;staticconstunsignedRelocationInfoSize=8;enumHeaderFileType{HFT_Object=0x1};enumHeaderFlags{HF_SubsectionsViaSymbols=0x2000