Home | History | Annotate | Download | only in AArch64
      1 //===-- AArch64TargetObjectFile.cpp - AArch64 Object Info -----------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #include "AArch64TargetObjectFile.h"
     11 #include "AArch64TargetMachine.h"
     12 #include "llvm/IR/Mangler.h"
     13 #include "llvm/MC/MCContext.h"
     14 #include "llvm/MC/MCExpr.h"
     15 #include "llvm/MC/MCStreamer.h"
     16 #include "llvm/Support/Dwarf.h"
     17 using namespace llvm;
     18 using namespace dwarf;
     19 
     20 void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
     21                                              const TargetMachine &TM) {
     22   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
     23   InitializeELF(TM.Options.UseInitArray);
     24 }
     25 
     26 const MCExpr *AArch64_MachoTargetObjectFile::getTTypeGlobalReference(
     27     const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
     28     const TargetMachine &TM, MachineModuleInfo *MMI,
     29     MCStreamer &Streamer) const {
     30   // On Darwin, we can reference dwarf symbols with foo@GOT-., which
     31   // is an indirect pc-relative reference. The default implementation
     32   // won't reference using the GOT, so we need this target-specific
     33   // version.
     34   if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
     35     const MCSymbol *Sym = TM.getSymbol(GV, Mang);
     36     const MCExpr *Res =
     37         MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOT, getContext());
     38     MCSymbol *PCSym = getContext().CreateTempSymbol();
     39     Streamer.EmitLabel(PCSym);
     40     const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, getContext());
     41     return MCBinaryExpr::CreateSub(Res, PC, getContext());
     42   }
     43 
     44   return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
     45       GV, Encoding, Mang, TM, MMI, Streamer);
     46 }
     47 
     48 MCSymbol *AArch64_MachoTargetObjectFile::getCFIPersonalitySymbol(
     49     const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
     50     MachineModuleInfo *MMI) const {
     51   return TM.getSymbol(GV, Mang);
     52 }
     53