use XCore-specific section with xcore specific cp/dp flags to restore
[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 "MCSectionXCore.h"
13 #include "llvm/Target/TargetMachine.h"
14 using namespace llvm;
15
16
17 void XCoreTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){
18   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
19
20   DataSection =
21     MCSectionXCore::Create(".dp.data", MCSectionELF::SHT_PROGBITS, 
22                            MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
23                            MCSectionXCore::SHF_DP_SECTION,
24                            SectionKind::getDataRel(), false, getContext());
25   BSSSection =
26     MCSectionXCore::Create(".dp.bss", MCSectionELF::SHT_NOBITS,
27                            MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
28                            MCSectionXCore::SHF_DP_SECTION,
29                            SectionKind::getBSS(), false, getContext());
30   
31   // For now, disable lowering of mergable sections, just drop everything into
32   // ReadOnly.
33   MergeableConst4Section = 0;
34   MergeableConst8Section = 0;
35   MergeableConst16Section = 0;
36   
37   // TLS globals are lowered in the backend to arrays indexed by the current
38   // thread id. After lowering they require no special handling by the linker
39   // and can be placed in the standard data / bss sections.
40   TLSDataSection = DataSection;
41   TLSBSSSection = BSSSection;
42   
43   if (TM.getSubtarget<XCoreSubtarget>().isXS1A())
44     ReadOnlySection =   // FIXME: Why is this a writable section for XS1A?
45       MCSectionXCore::Create(".dp.rodata", MCSectionELF::SHT_PROGBITS,
46                              MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
47                              MCSectionXCore::SHF_DP_SECTION,
48                              SectionKind::getDataRel(), false, getContext());
49   else
50     ReadOnlySection = 
51       MCSectionXCore::Create(".cp.rodata", MCSectionELF::SHT_PROGBITS,
52                              MCSectionELF::SHF_ALLOC |
53                              MCSectionXCore::SHF_CP_SECTION,
54                              SectionKind::getReadOnly(), false, getContext());
55 }