LCOV - code coverage report
Current view: top level - lib/Target/ARM - ARMTargetObjectFile.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 27 27 100.0 %
Date: 2017-09-14 15:23:50 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "ARMSubtarget.h"
      12             : #include "ARMTargetMachine.h"
      13             : #include "llvm/BinaryFormat/Dwarf.h"
      14             : #include "llvm/BinaryFormat/ELF.h"
      15             : #include "llvm/MC/MCAsmInfo.h"
      16             : #include "llvm/MC/MCContext.h"
      17             : #include "llvm/MC/MCExpr.h"
      18             : #include "llvm/MC/MCSectionELF.h"
      19             : #include "llvm/MC/MCTargetOptions.h"
      20             : #include "llvm/MC/SectionKind.h"
      21             : #include "llvm/Target/TargetMachine.h"
      22             : #include <cassert>
      23             : 
      24             : using namespace llvm;
      25             : using namespace dwarf;
      26             : 
      27             : //===----------------------------------------------------------------------===//
      28             : //                               ELF Target
      29             : //===----------------------------------------------------------------------===//
      30             : 
      31        1755 : void ARMElfTargetObjectFile::Initialize(MCContext &Ctx,
      32             :                                         const TargetMachine &TM) {
      33        1755 :   const ARMBaseTargetMachine &ARM_TM = static_cast<const ARMBaseTargetMachine &>(TM);
      34        1755 :   bool isAAPCS_ABI = ARM_TM.TargetABI == ARMBaseTargetMachine::ARMABI::ARM_ABI_AAPCS;
      35             :   //  genExecuteOnly = ARM_TM.getSubtargetImpl()->genExecuteOnly();
      36             : 
      37        1755 :   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
      38        1755 :   InitializeELF(isAAPCS_ABI);
      39             : 
      40        1755 :   if (isAAPCS_ABI) {
      41        1744 :     LSDASection = nullptr;
      42             :   }
      43             : 
      44        1755 :   AttributesSection =
      45        7020 :       getContext().getELFSection(".ARM.attributes", ELF::SHT_ARM_ATTRIBUTES, 0);
      46        1755 : }
      47             : 
      48           6 : const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference(
      49             :     const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
      50             :     MachineModuleInfo *MMI, MCStreamer &Streamer) const {
      51           6 :   if (TM.getMCAsmInfo()->getExceptionHandlingType() != ExceptionHandling::ARM)
      52           2 :     return TargetLoweringObjectFileELF::getTTypeGlobalReference(
      53           2 :         GV, Encoding, TM, MMI, Streamer);
      54             : 
      55             :   assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
      56             : 
      57           8 :   return MCSymbolRefExpr::create(TM.getSymbol(GV),
      58           8 :                                  MCSymbolRefExpr::VK_ARM_TARGET2, getContext());
      59             : }
      60             : 
      61           1 : const MCExpr *ARMElfTargetObjectFile::
      62             : getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
      63           2 :   return MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_ARM_TLSLDO,
      64           3 :                                  getContext());
      65             : }
      66             : 
      67             : static bool isExecuteOnlyFunction(const GlobalObject *GO, SectionKind SK,
      68             :                                   const TargetMachine &TM) {
      69        9319 :   if (const Function *F = dyn_cast<Function>(GO))
      70        9397 :     if (TM.getSubtarget<ARMSubtarget>(*F).genExecuteOnly() && SK.isText())
      71             :       return true;
      72             :   return false;
      73             : }
      74             : 
      75          38 : MCSection *ARMElfTargetObjectFile::getExplicitSectionGlobal(
      76             :     const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
      77             :   // Set execute-only access for the explicit section
      78          38 :   if (isExecuteOnlyFunction(GO, SK, TM))
      79             :     SK = SectionKind::getExecuteOnly();
      80             : 
      81          38 :   return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM);
      82             : }
      83             : 
      84        9788 : MCSection *ARMElfTargetObjectFile::SelectSectionForGlobal(
      85             :     const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
      86             :   // Place the global in the execute-only text section
      87        9788 :   if (isExecuteOnlyFunction(GO, SK, TM))
      88             :     SK = SectionKind::getExecuteOnly();
      89             : 
      90        9788 :   return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, SK, TM);
      91             : }

Generated by: LCOV version 1.13