blob: 48238bfcf696b25d85fbfac71d415732fe290f56 [file] [log] [blame]
Bill Wendling94811812010-03-09 18:31:07 +00001//===-- 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"
Chandler Carruthed0881b2012-12-03 16:50:05 +000012#include "llvm/ADT/StringExtras.h"
Rafael Espindola894843c2014-01-07 21:19:40 +000013#include "llvm/IR/Mangler.h"
Joerg Sonnenbergercf86ce12014-05-07 07:49:34 +000014#include "llvm/MC/MCAsmInfo.h"
Chris Lattner80c34592010-04-08 21:34:17 +000015#include "llvm/MC/MCContext.h"
Anton Korobeynikove42af362012-11-14 01:47:00 +000016#include "llvm/MC/MCExpr.h"
Bill Wendling94811812010-03-09 18:31:07 +000017#include "llvm/MC/MCSectionELF.h"
Bill Wendling94811812010-03-09 18:31:07 +000018#include "llvm/Support/Dwarf.h"
Rafael Espindolaaea49582011-01-23 04:28:49 +000019#include "llvm/Support/ELF.h"
Rafael Espindoladaeafb42014-02-19 17:23:20 +000020#include "llvm/Target/TargetLowering.h"
Bill Wendling94811812010-03-09 18:31:07 +000021using namespace llvm;
22using namespace dwarf;
23
24//===----------------------------------------------------------------------===//
25// ELF Target
26//===----------------------------------------------------------------------===//
27
28void ARMElfTargetObjectFile::Initialize(MCContext &Ctx,
29 const TargetMachine &TM) {
Rafael Espindolaca3e0ee2012-06-19 00:48:28 +000030 bool isAAPCS_ABI = TM.getSubtarget<ARMSubtarget>().isAAPCS_ABI();
Bill Wendling94811812010-03-09 18:31:07 +000031 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
Rafael Espindolaca3e0ee2012-06-19 00:48:28 +000032 InitializeELF(isAAPCS_ABI);
Bill Wendling94811812010-03-09 18:31:07 +000033
Anton Korobeynikov7722a2d2012-01-25 22:24:19 +000034 if (isAAPCS_ABI) {
Craig Topper062a2ba2014-04-25 05:30:21 +000035 LSDASection = nullptr;
Bill Wendling94811812010-03-09 18:31:07 +000036 }
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000037
Jason W Kim109ff292010-10-11 23:01:44 +000038 AttributesSection =
39 getContext().getELFSection(".ARM.attributes",
Rafael Espindolaaea49582011-01-23 04:28:49 +000040 ELF::SHT_ARM_ATTRIBUTES,
Jason W Kim109ff292010-10-11 23:01:44 +000041 0,
42 SectionKind::getMetadata());
Bill Wendling94811812010-03-09 18:31:07 +000043}
Anton Korobeynikove42af362012-11-14 01:47:00 +000044
Rafael Espindola15b26692014-02-09 14:50:44 +000045const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference(
46 const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
Rafael Espindoladaeafb42014-02-19 17:23:20 +000047 const TargetMachine &TM, MachineModuleInfo *MMI,
48 MCStreamer &Streamer) const {
Joerg Sonnenbergercf86ce12014-05-07 07:49:34 +000049 if (TM.getMCAsmInfo()->getExceptionHandlingType() != ExceptionHandling::ARM)
50 return TargetLoweringObjectFileELF::getTTypeGlobalReference(
51 GV, Encoding, Mang, TM, MMI, Streamer);
52
Anton Korobeynikove42af362012-11-14 01:47:00 +000053 assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
54
Rafael Espindolaa3ad4e62014-02-19 20:30:41 +000055 return MCSymbolRefExpr::Create(TM.getSymbol(GV, Mang),
Rafael Espindoladaeafb42014-02-19 17:23:20 +000056 MCSymbolRefExpr::VK_ARM_TARGET2, getContext());
Anton Korobeynikove42af362012-11-14 01:47:00 +000057}
Kai Nacke382c1402014-02-05 07:23:09 +000058
59const MCExpr *ARMElfTargetObjectFile::
60getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
61 return MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_ARM_TLSLDO,
62 getContext());
63}