LLVM 17.0.0git
ARMTargetObjectFile.cpp
Go to the documentation of this file.
1//===-- llvm/Target/ARMTargetObjectFile.cpp - ARM Object Info Impl --------===//
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 "ARMSubtarget.h"
11#include "ARMTargetMachine.h"
14#include "llvm/MC/MCAsmInfo.h"
15#include "llvm/MC/MCContext.h"
16#include "llvm/MC/MCExpr.h"
19#include "llvm/MC/SectionKind.h"
21#include <cassert>
22
23using namespace llvm;
24using namespace dwarf;
25
26//===----------------------------------------------------------------------===//
27// ELF Target
28//===----------------------------------------------------------------------===//
29
31 const TargetMachine &TM) {
32 const ARMBaseTargetMachine &ARM_TM = static_cast<const ARMBaseTargetMachine &>(TM);
33 bool isAAPCS_ABI = ARM_TM.TargetABI == ARMBaseTargetMachine::ARMABI::ARM_ABI_AAPCS;
34 bool genExecuteOnly =
35 ARM_TM.getMCSubtargetInfo()->hasFeature(ARM::FeatureExecuteOnly);
36
38 InitializeELF(isAAPCS_ABI);
39
40 if (isAAPCS_ABI) {
41 LSDASection = nullptr;
42 }
43
44 // Make code section unreadable when in execute-only mode
45 if (genExecuteOnly) {
46 unsigned Type = ELF::SHT_PROGBITS;
47 unsigned Flags =
49 // Since we cannot modify flags for an existing section, we create a new
50 // section with the right flags, and use 0 as the unique ID for
51 // execute-only text
53 Ctx.getELFSection(".text", Type, Flags, 0, "", false, 0U, nullptr);
54 }
55}
56
58
60getIndirectSymViaRWPI(const MCSymbol *Sym) const {
62 getContext());
63}
64
66 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
67 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
70 GV, Encoding, TM, MMI, Streamer);
71
72 assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
73
76}
77
79getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
81 getContext());
82}
83
85 const TargetMachine &TM) {
86 if (const Function *F = dyn_cast<Function>(GO))
87 if (TM.getSubtarget<ARMSubtarget>(*F).genExecuteOnly() && SK.isText())
88 return true;
89 return false;
90}
91
93 const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
94 // Set execute-only access for the explicit section
95 if (isExecuteOnlyFunction(GO, SK, TM))
97
99}
100
102 const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
103 // Place the global in the execute-only text section
104 if (isExecuteOnlyFunction(GO, SK, TM))
106
108}
static bool isExecuteOnlyFunction(const GlobalObject *GO, SectionKind SK, const TargetMachine &TM)
This file contains constants used for implementing Dwarf debug support.
#define F(x, y, z)
Definition: MD5.cpp:55
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
enum llvm::ARMBaseTargetMachine::ARMABI TargetABI
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const override
Describe a TLS variable address within debug info.
MCRegister getStaticBase() const override
Returns the register used as static base in RWPI variants.
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
const MCExpr * getIndirectSymViaRWPI(const MCSymbol *Sym) const override
Get the target specific RWPI relocation.
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Return an MCExpr to use for a reference to the specified type info global variable from exception han...
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
ExceptionHandling getExceptionHandlingType() const
Definition: MCAsmInfo.h:781
Context object for machine code objects.
Definition: MCContext.h:76
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:563
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
MCSection * TextSection
Section directive for standard text.
MCSection * LSDASection
If exception handling is supported by the target, this is the section the Language Specific Data Area...
MCContext & getContext() const
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:24
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
Streaming machine code generation interface.
Definition: MCStreamer.h:212
bool hasFeature(unsigned Feature) const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:386
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
This class contains meta information specific to a module.
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
bool isText() const
Definition: SectionKind.h:127
static SectionKind getExecuteOnly()
Definition: SectionKind.h:191
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Return an MCExpr to use for a reference to the specified type info global variable from exception han...
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:78
const MCSubtargetInfo * getMCSubtargetInfo() const
MCSymbol * getSymbol(const GlobalValue *GV) const
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
@ SHF_ALLOC
Definition: ELF.h:1083
@ SHF_ARM_PURECODE
Definition: ELF.h:1178
@ SHF_EXECINSTR
Definition: ELF.h:1086
@ SHT_PROGBITS
Definition: ELF.h:995
@ DW_EH_PE_absptr
Definition: Dwarf.h:515
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18