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 "llvm/MC/MCContext.h"
00013 #include "llvm/MC/MCSectionELF.h"
00014 #include "llvm/Support/ELF.h"
00015 #include "llvm/Target/TargetMachine.h"
00016 using namespace llvm;
00017 
00018 
00019 void XCoreTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM){
00020   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
00021 
00022   DataSection =
00023     Ctx.getELFSection(".dp.data", ELF::SHT_PROGBITS, 
00024                       ELF::SHF_ALLOC | ELF::SHF_WRITE |
00025                       ELF::XCORE_SHF_DP_SECTION,
00026                       SectionKind::getDataRel());
00027   BSSSection =
00028     Ctx.getELFSection(".dp.bss", ELF::SHT_NOBITS,
00029                       ELF::SHF_ALLOC | ELF::SHF_WRITE |
00030                       ELF::XCORE_SHF_DP_SECTION,
00031                       SectionKind::getBSS());
00032   
00033   MergeableConst4Section = 
00034     Ctx.getELFSection(".cp.rodata.cst4", ELF::SHT_PROGBITS,
00035                       ELF::SHF_ALLOC | ELF::SHF_MERGE |
00036                       ELF::XCORE_SHF_CP_SECTION,
00037                       SectionKind::getMergeableConst4());
00038   MergeableConst8Section = 
00039     Ctx.getELFSection(".cp.rodata.cst8", ELF::SHT_PROGBITS,
00040                       ELF::SHF_ALLOC | ELF::SHF_MERGE |
00041                       ELF::XCORE_SHF_CP_SECTION,
00042                       SectionKind::getMergeableConst8());
00043   MergeableConst16Section = 
00044     Ctx.getELFSection(".cp.rodata.cst16", ELF::SHT_PROGBITS,
00045                       ELF::SHF_ALLOC | ELF::SHF_MERGE |
00046                       ELF::XCORE_SHF_CP_SECTION,
00047                       SectionKind::getMergeableConst16());
00048   
00049   // TLS globals are lowered in the backend to arrays indexed by the current
00050   // thread id. After lowering they require no special handling by the linker
00051   // and can be placed in the standard data / bss sections.
00052   TLSDataSection = DataSection;
00053   TLSBSSSection = BSSSection;
00054 
00055   ReadOnlySection = 
00056     Ctx.getELFSection(".cp.rodata", ELF::SHT_PROGBITS,
00057                       ELF::SHF_ALLOC |
00058                       ELF::XCORE_SHF_CP_SECTION,
00059                       SectionKind::getReadOnlyWithRel());
00060 }