Newer
Older
//===-- llvm/CodeGen/TargetLoweringObjectFileImpl.cpp - Object File Info --===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements classes used to handle lowerings specific to common
// object file formats.
//
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionCOFF.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Target/Mangler.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Triple.h"
using namespace llvm;
Anton Korobeynikov
committed
using namespace dwarf;
//===----------------------------------------------------------------------===//
// ELF
//===----------------------------------------------------------------------===//
void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
const TargetMachine &TM) {
TargetLoweringObjectFile::Initialize(Ctx, TM);
BSSSection =
getContext().getELFSection(".bss", ELF::SHT_NOBITS,
TextSection =
getContext().getELFSection(".text", ELF::SHT_PROGBITS,
DataSection =
getContext().getELFSection(".data", ELF::SHT_PROGBITS,
ReadOnlySection =
getContext().getELFSection(".rodata", ELF::SHT_PROGBITS,
TLSDataSection =
getContext().getELFSection(".tdata", ELF::SHT_PROGBITS,
ELF::SHF_ALLOC | ELF::SHF_TLS |
ELF::SHF_WRITE,
TLSBSSSection =
getContext().getELFSection(".tbss", ELF::SHT_NOBITS,
ELF::SHF_ALLOC | ELF::SHF_TLS |
ELF::SHF_WRITE,
DataRelSection =
getContext().getELFSection(".data.rel", ELF::SHT_PROGBITS,
DataRelLocalSection =
getContext().getELFSection(".data.rel.local", ELF::SHT_PROGBITS,
DataRelROSection =
getContext().getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
DataRelROLocalSection =
getContext().getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS,
MergeableConst4Section =
getContext().getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
MergeableConst8Section =
getContext().getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
MergeableConst16Section =
getContext().getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
StaticCtorSection =
getContext().getELFSection(".ctors", ELF::SHT_PROGBITS,
StaticDtorSection =
getContext().getELFSection(".dtors", ELF::SHT_PROGBITS,
// Exception Handling Sections.
// FIXME: We're emitting LSDA info into a readonly section on ELF, even though
// it contains relocatable pointers. In PIC mode, this is probably a big
// runtime hit for C++ apps. Either the contents of the LSDA need to be
// adjusted or this should be a data section.
LSDASection =
getContext().getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
// Debug Info Sections.
DwarfAbbrevSection =
getContext().getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0,
DwarfInfoSection =
getContext().getELFSection(".debug_info", ELF::SHT_PROGBITS, 0,
DwarfLineSection =
getContext().getELFSection(".debug_line", ELF::SHT_PROGBITS, 0,
DwarfFrameSection =
getContext().getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0,
DwarfPubNamesSection =
getContext().getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0,
DwarfPubTypesSection =
getContext().getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0,
DwarfStrSection =
getContext().getELFSection(".debug_str", ELF::SHT_PROGBITS, 0,
DwarfLocSection =
getContext().getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0,
DwarfARangesSection =
getContext().getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0,
DwarfRangesSection =
getContext().getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0,
DwarfMacroInfoSection =
getContext().getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0,
}
const MCSection *TargetLoweringObjectFileELF::getEHFrameSection() const {
return getContext().getELFSection(".eh_frame", ELF::SHT_PROGBITS,
ELF::SHF_ALLOC,
SectionKind::getDataRel());
}
static SectionKind
getELFKindForNamedSection(StringRef Name, SectionKind K) {
if (Name.empty() || Name[0] != '.') return K;
// Some lame default implementation based on some magic section names.
if (Name == ".bss" ||
Name.startswith(".bss.") ||
Name.startswith(".gnu.linkonce.b.") ||
Name.startswith(".llvm.linkonce.b.") ||
Name == ".sbss" ||
Name.startswith(".sbss.") ||
Name.startswith(".gnu.linkonce.sb.") ||
Name.startswith(".llvm.linkonce.sb."))
return SectionKind::getBSS();
if (Name == ".tdata" ||
Name.startswith(".tdata.") ||
Name.startswith(".gnu.linkonce.td.") ||
Name.startswith(".llvm.linkonce.td."))
return SectionKind::getThreadData();
if (Name == ".tbss" ||
Loading
Loading full blame...