//===- lib/MC/MachObjectWriter.cpp - Mach-O File Writer -------------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===//#include"llvm/ADT/StringMap.h"#include"llvm/ADT/Twine.h"#include"llvm/MC/MCAssembler.h"#include"llvm/MC/MCAsmLayout.h"#include"llvm/MC/MCExpr.h"#include"llvm/MC/MCObjectWriter.h"#include"llvm/MC/MCSectionMachO.h"#include"llvm/MC/MCSymbol.h"#include"llvm/MC/MCMachOSymbolFlags.h"#include"llvm/MC/MCValue.h"#include"llvm/Object/MachOFormat.h"#include"llvm/Support/ErrorHandling.h"#include"llvm/Target/TargetAsmBackend.h"// FIXME: Gross.#include"../Target/X86/X86FixupKinds.h"#include<vector>usingnamespacellvm;usingnamespacellvm::object;// FIXME: this has been copied from (or to) X86AsmBackend.cppstaticunsignedgetFixupKindLog2Size(unsignedKind){switch(Kind){// FIXME: Until ARM has it's own relocation stuff spun off, it comes// through here and we don't want it to puke all over. Any reasonable// values will only come when ARM relocation support gets added, at which// point this will be X86 only again and the llvm_unreachable can be// re-enabled.default:return0;// llvm_unreachable("invalid fixup kind!");caseFK_PCRel_1:caseFK_Data_1:return0;caseFK_PCRel_2:caseFK_Data_2:return1;caseFK_PCRel_4:caseX86::reloc_riprel_4byte:caseX86::reloc_riprel_4byte_movq_load:caseX86::reloc_signed_4byte:caseFK_Data_4:return2;caseFK_Data_8:return3;}}staticboolisFixupKindPCRel(unsignedKind){switch(Kind){default:returnfalse;caseFK_PCRel_1:caseFK_PCRel_2:caseFK_PCRel_4:caseX86::reloc_riprel_4byte:caseX86::reloc_riprel_4byte_movq_load:returntrue;}}staticboolisFixupKindRIPRel(unsignedKind){returnKind==X86::reloc_riprel_4byte||Kind==X86::reloc_riprel_4byte_movq_load;}staticbooldoesSymbolRequireExternRelocation(MCSymbolData*SD){// Undefined symbols are always extern.if(SD->Symbol->isUndefined())returntrue;// References to weak definitions require external relocation entries; the// definition may not always be the one in the same object file.<