9415f5127dc3f868f22fc836feee44b26e65108c
[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/MCSectionELF.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 = getELFSection(".dp.data", MCSectionELF::SHT_PROGBITS, 
21                               MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE,
22                               SectionKind::getDataRel());
23   BSSSection = getELFSection(".dp.bss", MCSectionELF::SHT_NOBITS,
24                               MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE,
25                               SectionKind::getBSS());
26   
27   // TLS globals are lowered in the backend to arrays indexed by the current
28   // thread id. After lowering they require no special handling by the linker
29   // and can be placed in the standard data / bss sections.
30   TLSDataSection = DataSection;
31   TLSBSSSection = BSSSection;
32   
33   if (TM.getSubtarget<XCoreSubtarget>().isXS1A())
34     // FIXME: Why is this writable ("datarel")???
35     ReadOnlySection = 
36       getELFSection(".dp.rodata", MCSectionELF::SHT_PROGBITS,
37                     MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE,
38                     SectionKind::getDataRel());
39   else
40     ReadOnlySection = 
41       getELFSection(".cp.rodata", MCSectionELF::SHT_PROGBITS, 
42                     MCSectionELF::SHF_ALLOC, SectionKind::getReadOnly());
43 }