LLVM 22.0.0git
X86TargetObjectFile.cpp
Go to the documentation of this file.
1//===-- X86TargetObjectFile.cpp - X86 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
12#include "llvm/MC/MCExpr.h"
13#include "llvm/MC/MCValue.h"
15
16using namespace llvm;
17using namespace dwarf;
18
20 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
21 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
22
23 // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
24 // is an indirect pc-relative reference.
25 if ((Encoding & DW_EH_PE_indirect) && (Encoding & DW_EH_PE_pcrel)) {
26 const MCSymbol *Sym = TM.getSymbol(GV);
27 const MCExpr *Res =
29 const MCExpr *Four = MCConstantExpr::create(4, getContext());
30 return MCBinaryExpr::createAdd(Res, Four, getContext());
31 }
32
34 GV, Encoding, TM, MMI, Streamer);
35}
36
38 const GlobalValue *GV, const TargetMachine &TM,
39 MachineModuleInfo *MMI) const {
40 return TM.getSymbol(GV);
41}
42
44 const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV,
45 int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const {
46 // On Darwin/X86-64, we need to use foo@GOTPCREL+4 to access the got entry
47 // from a data section. In case there's an additional offset, then use
48 // foo@GOTPCREL+4+<offset>.
49 unsigned FinalOff = Offset+MV.getConstant()+4;
50 const MCExpr *Res =
52 const MCExpr *Off = MCConstantExpr::create(FinalOff, getContext());
53 return MCBinaryExpr::createAdd(Res, Off, getContext());
54}
55
58}
59
61 const MCSymbol *Sym) const {
63}
64
66 const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV,
67 int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const {
68 int64_t FinalOffset = Offset + MV.getConstant();
69 const MCExpr *Res =
71 const MCExpr *Off = MCConstantExpr::create(FinalOffset, getContext());
72 return MCBinaryExpr::createAdd(Res, Off, getContext());
73}
This file contains constants used for implementing Dwarf debug support.
Symbol * Sym
Definition: ELF_riscv.cpp:479
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:343
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:212
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
MCContext & getContext() const
Streaming machine code generation interface.
Definition: MCStreamer.h:220
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:214
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
int64_t getConstant() const
Definition: MCValue.h:44
This class contains meta information specific to a module.
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.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:83
MCSymbol * getSymbol(const GlobalValue *GV) const
const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const override
Describe a TLS variable address within debug info.
const MCExpr * getIndirectSymViaGOTPCRel(const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV, int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Get the target specific 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.
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
const MCExpr * getIndirectSymViaGOTPCRel(const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV, int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Get MachO PC relative GOT entry relocation.
@ DW_EH_PE_pcrel
Definition: Dwarf.h:865
@ DW_EH_PE_indirect
Definition: Dwarf.h:870
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477