LLVM  9.0.0svn
AArch64TargetObjectFile.cpp
Go to the documentation of this file.
1 //===-- AArch64TargetObjectFile.cpp - AArch64 Object Info -----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #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/MC/MCValue.h"
17 using namespace llvm;
18 using namespace dwarf;
19 
20 void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
21  const TargetMachine &TM) {
23  InitializeELF(TM.Options.UseInitArray);
24  // AARCH64 ELF ABI does not define static relocation type for TLS offset
25  // within a module. Do not generate AT_location for TLS variables.
26  SupportDebugThreadLocalLocation = false;
27 }
28 
32 }
33 
35  const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
36  MachineModuleInfo *MMI, MCStreamer &Streamer) const {
37  // On Darwin, we can reference dwarf symbols with foo@GOT-., which
38  // is an indirect pc-relative reference. The default implementation
39  // won't reference using the GOT, so we need this target-specific
40  // version.
41  if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
42  const MCSymbol *Sym = TM.getSymbol(GV);
43  const MCExpr *Res =
46  Streamer.EmitLabel(PCSym);
47  const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
48  return MCBinaryExpr::createSub(Res, PC, getContext());
49  }
50 
52  GV, Encoding, TM, MMI, Streamer);
53 }
54 
56  const GlobalValue *GV, const TargetMachine &TM,
57  MachineModuleInfo *MMI) const {
58  return TM.getSymbol(GV);
59 }
60 
62  const MCSymbol *Sym, const MCValue &MV, int64_t Offset,
63  MachineModuleInfo *MMI, MCStreamer &Streamer) const {
64  assert((Offset+MV.getConstant() == 0) &&
65  "Arch64 does not support GOT PC rel with extra offset");
66  // On ARM64 Darwin, we can reference symbols with foo@GOT-., which
67  // is an indirect pc-relative reference.
68  const MCExpr *Res =
71  Streamer.EmitLabel(PCSym);
72  const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
73  return MCBinaryExpr::createSub(Res, PC, getContext());
74 }
75 
77  SmallVectorImpl<char> &OutName, const GlobalValue *GV,
78  const TargetMachine &TM) const {
79  // AArch64 does not use section-relative relocations so any global symbol must
80  // be accessed via at least a linker-private symbol.
81  getMangler().getNameWithPrefix(OutName, GV, /* CannotUsePrivateLabel */ true);
82 }
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:321
This class represents lattice values for constants.
Definition: AllocatorList.h:23
This represents an "assembler immediate".
Definition: MCValue.h:39
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
int64_t getConstant() const
Definition: MCValue.h:46
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
const MCExpr * getIndirectSymViaGOTPCRel(const MCSymbol *Sym, const MCValue &MV, int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Get MachO PC relative GOT entry relocation.
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
The mach-o version of this method defaults to returning a stub reference.
Context object for machine code objects.
Definition: MCContext.h:62
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:544
Streaming machine code generation interface.
Definition: MCStreamer.h:188
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:220
MCSymbol * getSymbol(const GlobalValue *GV) const
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
The mach-o version of this method defaults to returning a stub reference.
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
This file contains constants used for implementing Dwarf debug support.
TargetOptions Options
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:351
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable&#39;s name.
Definition: Mangler.cpp:111
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
This class contains meta information specific to a module.