LLVM API Documentation

XCoreTargetObjectFile.cpp

Go to the documentation of this file.
00001 //===-- XCoreTargetObjectFile.cpp - XCore object files --------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #include "XCoreTargetObjectFile.h"
00011 #include "XCoreSubtarget.h"
00012 #include "MCSectionXCore.h"
00013 #include "llvm/Target/TargetMachine.h"
00014 using namespace llvm;
00015 
00016 
00017 void XCoreTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){
00018   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
00019 
00020   DataSection =
00021     MCSectionXCore::Create(".dp.data", MCSectionELF::SHT_PROGBITS, 
00022                            MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
00023                            MCSectionXCore::SHF_DP_SECTION,
00024                            SectionKind::getDataRel(), false, getContext());
00025   BSSSection =
00026     MCSectionXCore::Create(".dp.bss", MCSectionELF::SHT_NOBITS,
00027                            MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
00028                            MCSectionXCore::SHF_DP_SECTION,
00029                            SectionKind::getBSS(), false, getContext());
00030   
00031   MergeableConst4Section = 
00032     MCSectionXCore::Create(".cp.rodata.cst4", MCSectionELF::SHT_PROGBITS,
00033                            MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
00034                            MCSectionXCore::SHF_CP_SECTION,
00035                            SectionKind::getMergeableConst4(), false,
00036                            getContext());
00037   MergeableConst8Section = 
00038     MCSectionXCore::Create(".cp.rodata.cst8", MCSectionELF::SHT_PROGBITS,
00039                            MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
00040                            MCSectionXCore::SHF_CP_SECTION,
00041                            SectionKind::getMergeableConst8(), false,
00042                            getContext());
00043   MergeableConst16Section = 
00044     MCSectionXCore::Create(".cp.rodata.cst16", MCSectionELF::SHT_PROGBITS,
00045                            MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE |
00046                            MCSectionXCore::SHF_CP_SECTION,
00047                            SectionKind::getMergeableConst16(), false,
00048                            getContext());
00049   
00050   // TLS globals are lowered in the backend to arrays indexed by the current
00051   // thread id. After lowering they require no special handling by the linker
00052   // and can be placed in the standard data / bss sections.
00053   TLSDataSection = DataSection;
00054   TLSBSSSection = BSSSection;
00055   
00056   if (TM.getSubtarget<XCoreSubtarget>().isXS1A())
00057     ReadOnlySection =   // FIXME: Why is this a writable section for XS1A?
00058       MCSectionXCore::Create(".dp.rodata", MCSectionELF::SHT_PROGBITS,
00059                              MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE |
00060                              MCSectionXCore::SHF_DP_SECTION,
00061                              SectionKind::getDataRel(), false, getContext());
00062   else
00063     ReadOnlySection = 
00064       MCSectionXCore::Create(".cp.rodata", MCSectionELF::SHT_PROGBITS,
00065                              MCSectionELF::SHF_ALLOC |
00066                              MCSectionXCore::SHF_CP_SECTION,
00067                              SectionKind::getReadOnlyWithRel(), false,
00068                              getContext());
00069 
00070   // Dynamic linking is not supported. Data with relocations is placed in the
00071   // same section as data without relocations.
00072   DataRelSection = DataRelLocalSection = DataSection;
00073   DataRelROSection = DataRelROLocalSection = ReadOnlySection;
00074 }