LLVM 24.0.0git
PPCTargetObjectFile.cpp
Go to the documentation of this file.
1//===-- PPCTargetObjectFile.cpp - PPC 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/MCContext.h"
13#include "llvm/MC/MCExpr.h"
14
15using namespace llvm;
16
17void PPC64LinuxTargetObjectFile::initialize(MCContext &Ctx,
18 const TargetMachine &TM,
19 const Module &M) {
21}
22
23MCSection *PPC64LinuxTargetObjectFile::SelectSectionForGlobal(
24 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
25 // Here override ReadOnlySection to DataRelROSection for PPC64 SVR4 ABI
26 // when we have a constant that contains global relocations. This is
27 // necessary because of this ABI's handling of pointers to functions in
28 // a shared library. The address of a function is actually the address
29 // of a function descriptor, which resides in the .opd section. Generated
30 // code uses the descriptor directly rather than going via the GOT as some
31 // other ABIs do, which means that initialized function pointers must
32 // reference the descriptor. The linker must convert copy relocs of
33 // pointers to functions in shared libraries into dynamic relocations,
34 // because of an ordering problem with initialization of copy relocs and
35 // PLT entries. The dynamic relocation will be initialized by the dynamic
36 // linker, so we must use DataRelROSection instead of ReadOnlySection.
37 // For more information, see the description of ELIMINATE_COPY_RELOCS in
38 // GNU ld.
39 if (Kind.isReadOnly()) {
40 const auto *GVar = dyn_cast<GlobalVariable>(GO);
41
42 if (GVar && GVar->isConstant() &&
43 GVar->getInitializer()->needsDynamicRelocation())
45 }
46
48}
49
50const MCExpr *PPC64LinuxTargetObjectFile::
51getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
52 const MCExpr *Expr =
54 return MCBinaryExpr::createAdd(Expr,
56 getContext());
57}
58
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:342
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition MCExpr.cpp:212
Context object for machine code objects.
Definition MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
MCContext & getContext() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:580
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:213
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition SectionKind.h:22
static SectionKind getReadOnlyWithRel()
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
void initialize(MCContext &Ctx, const TargetMachine &TM, const Module &M) override
This method must be called before any actual lowering is done.
Primary interface to the complete machine description for the target machine.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643