move elf section uniquing to MCContext. Along the way
[oota-llvm.git] / lib / Target / XCore / XCoreTargetObjectFile.cpp
1 //===-- XCoreTargetObjectFile.cpp - XCore object files --------------------===//
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 "XCoreTargetObjectFile.h"
11 #include "XCoreSubtarget.h"
12 #include "llvm/MC/MCContext.h"
13 #include "llvm/MC/MCSectionELF.h"
14 #include "llvm/Target/TargetMachine.h"
15 using namespace llvm;
16
17
18 void XCoreTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){
19   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
20
21   DataSection =
22     Ctx.getELFSection(".dp.data", MCSectionELF::SHT_PROGBITS, 
23                       MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
24                       MCSectionELF::XCORE_SHF_DP_SECTION,
25                       SectionKind::getDataRel(), false);
26   BSSSection =
27     Ctx.getELFSection(".dp.bss", MCSectionELF::SHT_NOBITS,
28                       MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
29                       MCSectionELF::XCORE_SHF_DP_SECTION,
30                       SectionKind::getBSS(), false);
31   
32   MergeableConst4Section = 
33     Ctx.getELFSection(".cp.rodata.cst4", MCSectionELF::SHT_PROGBITS,
34                       MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
35                       MCSectionELF::XCORE_SHF_CP_SECTION,
36                       SectionKind::getMergeableConst4(), false);
37   MergeableConst8Section = 
38     Ctx.getELFSection(".cp.rodata.cst8", MCSectionELF::SHT_PROGBITS,
39                       MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
40                       MCSectionELF::XCORE_SHF_CP_SECTION,
41                       SectionKind::getMergeableConst8(), false);
42   MergeableConst16Section = 
43     Ctx.getELFSection(".cp.rodata.cst16", MCSectionELF::SHT_PROGBITS,
44                       MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
45                       MCSectionELF::XCORE_SHF_CP_SECTION,
46                       SectionKind::getMergeableConst16(), false);
47   
48   // TLS globals are lowered in the backend to arrays indexed by the current
49   // thread id. After lowering they require no special handling by the linker
50   // and can be placed in the standard data / bss sections.
51   TLSDataSection = DataSection;
52   TLSBSSSection = BSSSection;
53
54   ReadOnlySection = 
55     Ctx.getELFSection(".cp.rodata", MCSectionELF::SHT_PROGBITS,
56                       MCSectionELF::SHF_ALLOC |
57                       MCSectionELF::XCORE_SHF_CP_SECTION,
58                       SectionKind::getReadOnlyWithRel(), false);
59
60   // Dynamic linking is not supported. Data with relocations is placed in the
61   // same section as data without relocations.
62   DataRelSection = DataRelLocalSection = DataSection;
63   DataRelROSection = DataRelROLocalSection = ReadOnlySection;
64 }