LLVM  4.0.0
ARMTargetObjectFile.cpp
Go to the documentation of this file.
1 //===-- llvm/Target/ARMTargetObjectFile.cpp - ARM Object Info Impl --------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "ARMTargetObjectFile.h"
11 #include "ARMTargetMachine.h"
12 #include "llvm/ADT/StringExtras.h"
13 #include "llvm/IR/Mangler.h"
14 #include "llvm/MC/MCAsmInfo.h"
15 #include "llvm/MC/MCContext.h"
16 #include "llvm/MC/MCExpr.h"
17 #include "llvm/MC/MCSectionELF.h"
18 #include "llvm/Support/Dwarf.h"
19 #include "llvm/Support/ELF.h"
21 using namespace llvm;
22 using namespace dwarf;
23 
24 //===----------------------------------------------------------------------===//
25 // ELF Target
26 //===----------------------------------------------------------------------===//
27 
29  const TargetMachine &TM) {
30  const ARMTargetMachine &ARM_TM = static_cast<const ARMTargetMachine &>(TM);
31  bool isAAPCS_ABI = ARM_TM.TargetABI == ARMTargetMachine::ARMABI::ARM_ABI_AAPCS;
32  genExecuteOnly = ARM_TM.getSubtargetImpl()->genExecuteOnly();
33 
35  InitializeELF(isAAPCS_ABI);
36 
37  if (isAAPCS_ABI) {
38  LSDASection = nullptr;
39  }
40 
41  AttributesSection =
42  getContext().getELFSection(".ARM.attributes", ELF::SHT_ARM_ATTRIBUTES, 0);
43 
44  // Make code section unreadable when in execute-only mode
45  if (genExecuteOnly) {
46  unsigned Type = ELF::SHT_PROGBITS;
48  // Since we cannot modify flags for an existing section, we create a new
49  // section with the right flags, and use 0 as the unique ID for
50  // execute-only text
51  TextSection = Ctx.getELFSection(".text", Type, Flags, 0, "", 0U);
52  }
53 }
54 
56  const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
57  MachineModuleInfo *MMI, MCStreamer &Streamer) const {
60  GV, Encoding, TM, MMI, Streamer);
61 
62  assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
63 
64  return MCSymbolRefExpr::create(TM.getSymbol(GV),
65  MCSymbolRefExpr::VK_ARM_TARGET2, getContext());
66 }
67 
71  getContext());
72 }
73 
74 MCSection *
76  SectionKind SK, const TargetMachine &TM) const {
77  // Set execute-only access for the explicit section
78  if (genExecuteOnly && SK.isText())
80 
82 }
83 
84 MCSection *
86  SectionKind SK, const TargetMachine &TM) const {
87  // Place the global in the execute-only text section
88  if (genExecuteOnly && SK.isText())
90 
92 }
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
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...
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:298
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
MCSymbol * getSymbol(const GlobalValue *GV) const
setjmp/longjmp based exceptions
enum llvm::ARMBaseTargetMachine::ARMABI TargetABI
struct fuzzer::@269 Flags
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Context object for machine code objects.
Definition: MCContext.h:51
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
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...
Streaming machine code generation interface.
Definition: MCStreamer.h:161
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
const ARMSubtarget * getSubtargetImpl() const
bool isText() const
Definition: SectionKind.h:119
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...
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:23
ExceptionHandling getExceptionHandlingType() const
Definition: MCAsmInfo.h:538
bool genExecuteOnly() const
Definition: ARMSubtarget.h:500
ARM target machine.
const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const override
Describe a TLS variable address within debug info.
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
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...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:341
Primary interface to the complete machine description for the target machine.
This class contains meta information specific to a module.
static SectionKind getExecuteOnly()
Definition: SectionKind.h:181
This file describes how to lower LLVM code to machine code.