LLVM 19.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
11#include "llvm/MC/MCExpr.h"
12#include "llvm/MC/MCValue.h"
14
15using namespace llvm;
16using namespace dwarf;
17
19 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
20 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
21
22 // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
23 // is an indirect pc-relative reference.
24 if ((Encoding & DW_EH_PE_indirect) && (Encoding & DW_EH_PE_pcrel)) {
25 const MCSymbol *Sym = TM.getSymbol(GV);
26 const MCExpr *Res =
28 const MCExpr *Four = MCConstantExpr::create(4, getContext());
29 return MCBinaryExpr::createAdd(Res, Four, getContext());
30 }
31
33 GV, Encoding, TM, MMI, Streamer);
34}
35
37 const GlobalValue *GV, const TargetMachine &TM,
38 MachineModuleInfo *MMI) const {
39 return TM.getSymbol(GV);
40}
41
43 const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV,
44 int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const {
45 // On Darwin/X86-64, we need to use foo@GOTPCREL+4 to access the got entry
46 // from a data section. In case there's an additional offset, then use
47 // foo@GOTPCREL+4+<offset>.
48 unsigned FinalOff = Offset+MV.getConstant()+4;
49 const MCExpr *Res =
51 const MCExpr *Off = MCConstantExpr::create(FinalOff, getContext());
52 return MCBinaryExpr::createAdd(Res, Off, getContext());
53}
54
56 const MCSymbol *Sym) const {
58}
59
61 const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV,
62 int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const {
63 int64_t FinalOffset = Offset + MV.getConstant();
64 const MCExpr *Res =
66 const MCExpr *Off = MCConstantExpr::create(FinalOffset, getContext());
67 return MCBinaryExpr::createAdd(Res, Off, getContext());
68}
This file contains constants used for implementing Dwarf debug support.
Symbol * Sym
Definition: ELF_riscv.cpp:479
const char LLVMTargetMachineRef TM
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:528
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
MCContext & getContext() const
Streaming machine code generation interface.
Definition: MCStreamer.h:212
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:389
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
This represents an "assembler immediate".
Definition: MCValue.h:36
int64_t getConstant() const
Definition: MCValue.h:43
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:78
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:534
@ DW_EH_PE_indirect
Definition: Dwarf.h:539
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:456