//===- lib/MC/ELFObjectWriter.cpp - ELF File Writer -------------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This file implements ELF object file writer information.////===----------------------------------------------------------------------===//#include"ELFObjectWriter.h"#include"llvm/ADT/STLExtras.h"#include"llvm/ADT/StringMap.h"#include"llvm/ADT/Twine.h"#include"llvm/MC/MCAsmBackend.h"#include"llvm/MC/MCAsmLayout.h"#include"llvm/MC/MCContext.h"#include"llvm/MC/MCExpr.h"#include"llvm/MC/MCSectionELF.h"#include"llvm/MC/MCValue.h"#include"llvm/Support/Debug.h"#include"llvm/Support/ErrorHandling.h"#include"llvm/Support/ELF.h"#include"llvm/Support/CommandLine.h"#include"llvm/ADT/StringSwitch.h"#include"../Target/Mips/MCTargetDesc/MipsFixupKinds.h"#include<vector>usingnamespacellvm;#undef DEBUG_TYPE#define DEBUG_TYPE "reloc-info"boolELFObjectWriter::isFixupKindPCRel(constMCAssembler&Asm,unsignedKind){constMCFixupKindInfo&FKI=Asm.getBackend().getFixupKindInfo((MCFixupKind)Kind);returnFKI.Flags&MCFixupKindInfo::FKF_IsPCRel;}boolELFObjectWriter::RelocNeedsGOT(MCSymbolRefExpr::VariantKindVariant){switch(Variant){default:returnfalse;caseMCSymbolRefExpr::VK_GOT:caseMCSymbolRefExpr::VK_PLT:caseMCSymbolRefExpr::VK_GOTPCREL:caseMCSymbolRefExpr::VK_GOTOFF:caseMCSymbolRefExpr::VK_TPOFF:caseMCSymbolRefExpr::VK_TLSGD:caseMCSymbolRefExpr::VK_GOTTPOFF:caseMCSymbolRefExpr::VK_INDNTPOFF:caseMCSymbolRefExpr::VK_NTPOFF:caseMCSymbolRefExpr::VK_GOTNTPOFF:caseMCSymbolRefExpr::VK_TLSLDM:caseMCSymbolRefExpr::VK_DTPOFF:caseMCSymbolRefExpr::VK_TLSLD:returntrue;}}ELFObjectWriter::~ELFObjectWriter(){}// Emit the ELF header.voidELFObjectWriter::WriteHeader(uint64_tSectionDataSize,unsignedNumberOfSections){// ELF Header// ----------//// Note// ----// emitWord method behaves differently for ELF32 and ELF64, writing// 4 bytes in the former and 8 in the latter.Write8