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