2016-01-04 13:22:34 +01:00
|
|
|
//===-- MCObjectFileInfo.cpp - Object File Information --------------------===//
|
2011-07-20 07:58:47 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/MC/MCObjectFileInfo.h"
|
2013-12-13 22:33:40 +01:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2014-01-07 12:48:04 +01:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2017-06-07 05:48:56 +02:00
|
|
|
#include "llvm/BinaryFormat/COFF.h"
|
|
|
|
#include "llvm/BinaryFormat/ELF.h"
|
2014-05-13 19:58:13 +02:00
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
2011-07-20 07:58:47 +02:00
|
|
|
#include "llvm/MC/MCContext.h"
|
|
|
|
#include "llvm/MC/MCSection.h"
|
|
|
|
#include "llvm/MC/MCSectionCOFF.h"
|
|
|
|
#include "llvm/MC/MCSectionELF.h"
|
|
|
|
#include "llvm/MC/MCSectionMachO.h"
|
2017-02-22 02:23:18 +01:00
|
|
|
#include "llvm/MC/MCSectionWasm.h"
|
2015-10-07 01:24:35 +02:00
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-06-21 00:37:01 +02:00
|
|
|
static bool useCompactUnwind(const Triple &T) {
|
|
|
|
// Only on darwin.
|
|
|
|
if (!T.isOSDarwin())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// aarch64 always has it.
|
2014-07-23 14:32:47 +02:00
|
|
|
if (T.getArch() == Triple::aarch64)
|
2014-06-21 00:37:01 +02:00
|
|
|
return true;
|
|
|
|
|
2015-10-28 23:56:36 +01:00
|
|
|
// armv7k always has it.
|
2016-01-27 20:32:29 +01:00
|
|
|
if (T.isWatchABI())
|
2015-10-28 23:56:36 +01:00
|
|
|
return true;
|
|
|
|
|
2014-06-21 00:37:01 +02:00
|
|
|
// Use it on newer version of OS X.
|
|
|
|
if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6))
|
|
|
|
return true;
|
|
|
|
|
2014-06-21 00:40:55 +02:00
|
|
|
// And the iOS simulator.
|
|
|
|
if (T.isiOS() &&
|
|
|
|
(T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86))
|
|
|
|
return true;
|
|
|
|
|
2014-06-21 00:37:01 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-08 21:09:22 +02:00
|
|
|
void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
|
2011-07-20 07:58:47 +02:00
|
|
|
// MachO
|
|
|
|
SupportsWeakOmittedEHFrame = false;
|
|
|
|
|
2015-11-06 16:30:45 +01:00
|
|
|
EHFrameSection = Ctx->getMachOSection(
|
|
|
|
"__TEXT", "__eh_frame",
|
|
|
|
MachO::S_COALESCED | MachO::S_ATTR_NO_TOC |
|
|
|
|
MachO::S_ATTR_STRIP_STATIC_SYMS | MachO::S_ATTR_LIVE_SUPPORT,
|
|
|
|
SectionKind::getReadOnly());
|
|
|
|
|
2014-07-23 14:32:47 +02:00
|
|
|
if (T.isOSDarwin() && T.getArch() == Triple::aarch64)
|
2014-03-29 11:18:08 +01:00
|
|
|
SupportsCompactUnwindWithoutEHFrame = true;
|
|
|
|
|
2016-01-27 20:32:29 +01:00
|
|
|
if (T.isWatchABI())
|
2015-10-28 23:56:36 +01:00
|
|
|
OmitDwarfIfHaveCompactUnwind = true;
|
|
|
|
|
2011-07-20 21:50:42 +02:00
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel
|
|
|
|
| dwarf::DW_EH_PE_sdata4;
|
2014-05-12 15:47:05 +02:00
|
|
|
LSDAEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
|
2011-07-20 21:50:42 +02:00
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4;
|
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
// .comm doesn't support alignment before Leopard.
|
|
|
|
if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5))
|
|
|
|
CommDirectiveSupportsAlignment = false;
|
|
|
|
|
|
|
|
TextSection // .text
|
|
|
|
= Ctx->getMachOSection("__TEXT", "__text",
|
2014-03-07 08:36:05 +01:00
|
|
|
MachO::S_ATTR_PURE_INSTRUCTIONS,
|
2011-07-20 07:58:47 +02:00
|
|
|
SectionKind::getText());
|
|
|
|
DataSection // .data
|
2015-11-18 07:02:15 +01:00
|
|
|
= Ctx->getMachOSection("__DATA", "__data", 0, SectionKind::getData());
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2013-09-21 04:34:45 +02:00
|
|
|
// BSSSection might not be expected initialized on msvc.
|
2014-04-13 06:57:38 +02:00
|
|
|
BSSSection = nullptr;
|
2013-09-21 04:34:45 +02:00
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
TLSDataSection // .tdata
|
2015-11-18 07:02:15 +01:00
|
|
|
= Ctx->getMachOSection("__DATA", "__thread_data",
|
|
|
|
MachO::S_THREAD_LOCAL_REGULAR,
|
|
|
|
SectionKind::getData());
|
2011-07-20 07:58:47 +02:00
|
|
|
TLSBSSSection // .tbss
|
|
|
|
= Ctx->getMachOSection("__DATA", "__thread_bss",
|
2014-03-07 08:36:05 +01:00
|
|
|
MachO::S_THREAD_LOCAL_ZEROFILL,
|
2011-07-20 07:58:47 +02:00
|
|
|
SectionKind::getThreadBSS());
|
|
|
|
|
|
|
|
// TODO: Verify datarel below.
|
|
|
|
TLSTLVSection // .tlv
|
2015-11-18 07:02:15 +01:00
|
|
|
= Ctx->getMachOSection("__DATA", "__thread_vars",
|
|
|
|
MachO::S_THREAD_LOCAL_VARIABLES,
|
|
|
|
SectionKind::getData());
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2015-11-18 07:02:15 +01:00
|
|
|
TLSThreadInitSection = Ctx->getMachOSection(
|
|
|
|
"__DATA", "__thread_init", MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
|
|
|
|
SectionKind::getData());
|
2011-07-20 07:58:47 +02:00
|
|
|
|
|
|
|
CStringSection // .cstring
|
|
|
|
= Ctx->getMachOSection("__TEXT", "__cstring",
|
2014-03-07 08:36:05 +01:00
|
|
|
MachO::S_CSTRING_LITERALS,
|
2011-07-20 07:58:47 +02:00
|
|
|
SectionKind::getMergeable1ByteCString());
|
|
|
|
UStringSection
|
|
|
|
= Ctx->getMachOSection("__TEXT","__ustring", 0,
|
|
|
|
SectionKind::getMergeable2ByteCString());
|
|
|
|
FourByteConstantSection // .literal4
|
|
|
|
= Ctx->getMachOSection("__TEXT", "__literal4",
|
2014-03-07 08:36:05 +01:00
|
|
|
MachO::S_4BYTE_LITERALS,
|
2011-07-20 07:58:47 +02:00
|
|
|
SectionKind::getMergeableConst4());
|
|
|
|
EightByteConstantSection // .literal8
|
|
|
|
= Ctx->getMachOSection("__TEXT", "__literal8",
|
2014-03-07 08:36:05 +01:00
|
|
|
MachO::S_8BYTE_LITERALS,
|
2011-07-20 07:58:47 +02:00
|
|
|
SectionKind::getMergeableConst8());
|
|
|
|
|
2014-02-14 00:16:11 +01:00
|
|
|
SixteenByteConstantSection // .literal16
|
|
|
|
= Ctx->getMachOSection("__TEXT", "__literal16",
|
2014-03-07 08:36:05 +01:00
|
|
|
MachO::S_16BYTE_LITERALS,
|
2014-02-14 00:16:11 +01:00
|
|
|
SectionKind::getMergeableConst16());
|
2011-07-20 07:58:47 +02:00
|
|
|
|
|
|
|
ReadOnlySection // .const
|
|
|
|
= Ctx->getMachOSection("__TEXT", "__const", 0,
|
|
|
|
SectionKind::getReadOnly());
|
|
|
|
|
2015-10-15 07:28:38 +02:00
|
|
|
// If the target is not powerpc, map the coal sections to the non-coal
|
|
|
|
// sections.
|
|
|
|
//
|
|
|
|
// "__TEXT/__textcoal_nt" => section "__TEXT/__text"
|
|
|
|
// "__TEXT/__const_coal" => section "__TEXT/__const"
|
|
|
|
// "__DATA/__datacoal_nt" => section "__DATA/__data"
|
|
|
|
Triple::ArchType ArchTy = T.getArch();
|
|
|
|
|
|
|
|
if (ArchTy == Triple::ppc || ArchTy == Triple::ppc64) {
|
|
|
|
TextCoalSection
|
|
|
|
= Ctx->getMachOSection("__TEXT", "__textcoal_nt",
|
|
|
|
MachO::S_COALESCED |
|
|
|
|
MachO::S_ATTR_PURE_INSTRUCTIONS,
|
|
|
|
SectionKind::getText());
|
|
|
|
ConstTextCoalSection
|
|
|
|
= Ctx->getMachOSection("__TEXT", "__const_coal",
|
|
|
|
MachO::S_COALESCED,
|
|
|
|
SectionKind::getReadOnly());
|
2015-11-18 07:02:15 +01:00
|
|
|
DataCoalSection = Ctx->getMachOSection(
|
|
|
|
"__DATA", "__datacoal_nt", MachO::S_COALESCED, SectionKind::getData());
|
2015-10-15 07:28:38 +02:00
|
|
|
} else {
|
|
|
|
TextCoalSection = TextSection;
|
|
|
|
ConstTextCoalSection = ReadOnlySection;
|
|
|
|
DataCoalSection = DataSection;
|
|
|
|
}
|
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
ConstDataSection // .const_data
|
|
|
|
= Ctx->getMachOSection("__DATA", "__const", 0,
|
|
|
|
SectionKind::getReadOnlyWithRel());
|
|
|
|
DataCommonSection
|
|
|
|
= Ctx->getMachOSection("__DATA","__common",
|
2014-03-07 08:36:05 +01:00
|
|
|
MachO::S_ZEROFILL,
|
2011-07-20 07:58:47 +02:00
|
|
|
SectionKind::getBSS());
|
|
|
|
DataBSSSection
|
2014-03-07 08:36:05 +01:00
|
|
|
= Ctx->getMachOSection("__DATA","__bss", MachO::S_ZEROFILL,
|
2011-07-20 07:58:47 +02:00
|
|
|
SectionKind::getBSS());
|
|
|
|
|
|
|
|
|
|
|
|
LazySymbolPointerSection
|
|
|
|
= Ctx->getMachOSection("__DATA", "__la_symbol_ptr",
|
2014-03-07 08:36:05 +01:00
|
|
|
MachO::S_LAZY_SYMBOL_POINTERS,
|
2011-07-20 07:58:47 +02:00
|
|
|
SectionKind::getMetadata());
|
|
|
|
NonLazySymbolPointerSection
|
|
|
|
= Ctx->getMachOSection("__DATA", "__nl_symbol_ptr",
|
2014-03-07 08:36:05 +01:00
|
|
|
MachO::S_NON_LAZY_SYMBOL_POINTERS,
|
2011-07-20 07:58:47 +02:00
|
|
|
SectionKind::getMetadata());
|
2016-04-25 23:12:04 +02:00
|
|
|
|
|
|
|
ThreadLocalPointerSection
|
|
|
|
= Ctx->getMachOSection("__DATA", "__thread_ptr",
|
|
|
|
MachO::S_THREAD_LOCAL_VARIABLE_POINTERS,
|
|
|
|
SectionKind::getMetadata());
|
2011-07-20 07:58:47 +02:00
|
|
|
|
|
|
|
// Exception Handling.
|
|
|
|
LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0,
|
|
|
|
SectionKind::getReadOnlyWithRel());
|
|
|
|
|
2014-04-13 06:57:38 +02:00
|
|
|
COFFDebugSymbolsSection = nullptr;
|
2016-01-29 19:16:43 +01:00
|
|
|
COFFDebugTypesSection = nullptr;
|
2014-01-30 02:39:17 +01:00
|
|
|
|
2014-06-21 00:37:01 +02:00
|
|
|
if (useCompactUnwind(T)) {
|
2011-07-20 07:58:47 +02:00
|
|
|
CompactUnwindSection =
|
2014-06-21 00:37:01 +02:00
|
|
|
Ctx->getMachOSection("__LD", "__compact_unwind", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getReadOnly());
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2013-04-10 23:42:06 +02:00
|
|
|
if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)
|
2015-10-28 23:56:36 +01:00
|
|
|
CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_X86_64_MODE_DWARF
|
2014-07-23 14:32:47 +02:00
|
|
|
else if (T.getArch() == Triple::aarch64)
|
2015-10-28 23:56:36 +01:00
|
|
|
CompactUnwindDwarfEHFrameOnly = 0x03000000; // UNWIND_ARM64_MODE_DWARF
|
|
|
|
else if (T.getArch() == Triple::arm || T.getArch() == Triple::thumb)
|
|
|
|
CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_ARM_MODE_DWARF
|
2013-04-10 23:42:06 +02:00
|
|
|
}
|
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
// Debug Information.
|
2011-11-07 10:24:32 +01:00
|
|
|
DwarfAccelNamesSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__apple_names", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "names_begin");
|
2011-11-07 10:24:32 +01:00
|
|
|
DwarfAccelObjCSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__apple_objc", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "objc_begin");
|
2011-11-07 10:24:32 +01:00
|
|
|
// 16 character section limit...
|
|
|
|
DwarfAccelNamespaceSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__apple_namespac", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "namespac_begin");
|
2011-11-07 10:24:32 +01:00
|
|
|
DwarfAccelTypesSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__apple_types", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "types_begin");
|
2012-05-11 03:41:30 +02:00
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfAbbrevSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_abbrev", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_abbrev");
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfInfoSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_info", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_info");
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfLineSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_line", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_line");
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfFrameSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_frame", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata());
|
2013-02-12 19:00:14 +01:00
|
|
|
DwarfPubNamesSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_pubnames", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata());
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfPubTypesSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_pubtypes", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata());
|
2013-09-09 22:03:14 +02:00
|
|
|
DwarfGnuPubNamesSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata());
|
2013-09-09 22:03:14 +02:00
|
|
|
DwarfGnuPubTypesSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata());
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfStrSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_str", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "info_string");
|
2017-06-06 03:22:34 +02:00
|
|
|
DwarfStrOffSection =
|
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_str_offs", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata(), "section_str_off");
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfLocSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_loc", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_debug_loc");
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfARangesSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_aranges", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata());
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfRangesSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "debug_range");
|
2016-01-07 15:28:20 +01:00
|
|
|
DwarfMacinfoSection =
|
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_macinfo", MachO::S_ATTR_DEBUG,
|
2016-02-01 15:09:41 +01:00
|
|
|
SectionKind::getMetadata(), "debug_macinfo");
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfDebugInlineSection =
|
2015-03-10 22:16:18 +01:00
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata());
|
2015-12-02 07:21:34 +01:00
|
|
|
DwarfCUIndexSection =
|
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_cu_index", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata());
|
2015-12-05 04:05:45 +01:00
|
|
|
DwarfTUIndexSection =
|
|
|
|
Ctx->getMachOSection("__DWARF", "__debug_tu_index", MachO::S_ATTR_DEBUG,
|
|
|
|
SectionKind::getMetadata());
|
2015-03-10 22:16:18 +01:00
|
|
|
StackMapSection = Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps",
|
|
|
|
0, SectionKind::getMetadata());
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2015-06-15 20:44:08 +02:00
|
|
|
FaultMapSection = Ctx->getMachOSection("__LLVM_FAULTMAPS", "__llvm_faultmaps",
|
|
|
|
0, SectionKind::getMetadata());
|
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
TLSExtraDataSection = TLSTLVSection;
|
|
|
|
}
|
|
|
|
|
2016-06-08 21:09:22 +02:00
|
|
|
void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T) {
|
2014-05-01 01:23:14 +02:00
|
|
|
switch (T.getArch()) {
|
|
|
|
case Triple::mips:
|
|
|
|
case Triple::mipsel:
|
2013-04-03 05:13:19 +02:00
|
|
|
FDECFIEncoding = dwarf::DW_EH_PE_sdata4;
|
2014-05-01 01:23:14 +02:00
|
|
|
break;
|
|
|
|
case Triple::mips64:
|
|
|
|
case Triple::mips64el:
|
2013-04-03 05:13:19 +02:00
|
|
|
FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
|
2014-11-27 18:13:56 +01:00
|
|
|
break;
|
|
|
|
case Triple::x86_64:
|
|
|
|
FDECFIEncoding = dwarf::DW_EH_PE_pcrel |
|
|
|
|
((CMModel == CodeModel::Large) ? dwarf::DW_EH_PE_sdata8
|
|
|
|
: dwarf::DW_EH_PE_sdata4);
|
2014-05-01 01:23:14 +02:00
|
|
|
break;
|
2017-05-03 19:30:56 +02:00
|
|
|
case Triple::bpfel:
|
|
|
|
case Triple::bpfeb:
|
|
|
|
FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
|
|
|
|
break;
|
2014-05-01 01:23:14 +02:00
|
|
|
default:
|
2013-03-15 06:51:57 +01:00
|
|
|
FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
2014-05-01 01:23:14 +02:00
|
|
|
break;
|
|
|
|
}
|
2013-03-15 06:51:57 +01:00
|
|
|
|
2014-05-01 01:23:14 +02:00
|
|
|
switch (T.getArch()) {
|
2014-05-07 09:49:34 +02:00
|
|
|
case Triple::arm:
|
|
|
|
case Triple::armeb:
|
|
|
|
case Triple::thumb:
|
|
|
|
case Triple::thumbeb:
|
2014-05-13 19:58:13 +02:00
|
|
|
if (Ctx->getAsmInfo()->getExceptionHandlingType() == ExceptionHandling::ARM)
|
|
|
|
break;
|
|
|
|
// Fallthrough if not using EHABI
|
2016-08-17 22:30:52 +02:00
|
|
|
LLVM_FALLTHROUGH;
|
2014-07-24 21:25:16 +02:00
|
|
|
case Triple::ppc:
|
2014-05-01 01:23:14 +02:00
|
|
|
case Triple::x86:
|
2016-05-18 13:58:50 +02:00
|
|
|
PersonalityEncoding = PositionIndependent
|
|
|
|
? dwarf::DW_EH_PE_indirect |
|
|
|
|
dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4
|
|
|
|
: dwarf::DW_EH_PE_absptr;
|
|
|
|
LSDAEncoding = PositionIndependent
|
|
|
|
? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
|
|
|
|
: dwarf::DW_EH_PE_absptr;
|
|
|
|
TTypeEncoding = PositionIndependent
|
|
|
|
? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4
|
|
|
|
: dwarf::DW_EH_PE_absptr;
|
2014-05-01 01:23:14 +02:00
|
|
|
break;
|
|
|
|
case Triple::x86_64:
|
2016-05-18 13:58:50 +02:00
|
|
|
if (PositionIndependent) {
|
2011-07-20 21:50:42 +02:00
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
|
|
|
|
? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_pcrel |
|
|
|
|
(CMModel == CodeModel::Small
|
|
|
|
? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
|
|
|
|
? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
|
|
|
|
} else {
|
|
|
|
PersonalityEncoding =
|
|
|
|
(CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
|
|
|
|
? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
|
|
|
|
LSDAEncoding = (CMModel == CodeModel::Small)
|
|
|
|
? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
|
|
|
|
TTypeEncoding = (CMModel == CodeModel::Small)
|
|
|
|
? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
|
|
|
|
}
|
2016-04-25 23:28:52 +02:00
|
|
|
break;
|
2016-04-25 23:05:19 +02:00
|
|
|
case Triple::hexagon:
|
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
FDECFIEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_absptr;
|
2016-05-18 13:58:50 +02:00
|
|
|
if (PositionIndependent) {
|
2016-04-25 23:05:19 +02:00
|
|
|
PersonalityEncoding |= dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel;
|
|
|
|
LSDAEncoding |= dwarf::DW_EH_PE_pcrel;
|
|
|
|
FDECFIEncoding |= dwarf::DW_EH_PE_pcrel;
|
|
|
|
TTypeEncoding |= dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel;
|
|
|
|
}
|
2014-05-01 01:23:14 +02:00
|
|
|
break;
|
|
|
|
case Triple::aarch64:
|
|
|
|
case Triple::aarch64_be:
|
2013-01-31 13:12:40 +01:00
|
|
|
// The small model guarantees static code/data size < 4GB, but not where it
|
|
|
|
// will be in memory. Most of these could end up >2GB away so even a signed
|
|
|
|
// pc-relative 32-bit address is insufficient, theoretically.
|
2016-05-18 13:58:50 +02:00
|
|
|
if (PositionIndependent) {
|
2013-01-31 13:12:40 +01:00
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata8;
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata8;
|
|
|
|
} else {
|
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
}
|
2014-05-01 01:23:14 +02:00
|
|
|
break;
|
2016-03-01 22:21:42 +01:00
|
|
|
case Triple::lanai:
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
break;
|
2014-05-30 18:48:56 +02:00
|
|
|
case Triple::mips:
|
|
|
|
case Triple::mipsel:
|
2014-11-05 23:42:31 +01:00
|
|
|
case Triple::mips64:
|
|
|
|
case Triple::mips64el:
|
2015-06-02 22:32:50 +02:00
|
|
|
// MIPS uses indirect pointer to refer personality functions and types, so
|
|
|
|
// that the eh_frame section can be read-only. DW.ref.personality will be
|
|
|
|
// generated for relocation.
|
2014-05-30 18:48:56 +02:00
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_indirect;
|
2015-06-02 22:32:50 +02:00
|
|
|
// FIXME: The N64 ABI probably ought to use DW_EH_PE_sdata8 but we can't
|
|
|
|
// identify N64 from just a triple.
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4;
|
|
|
|
// We don't support PC-relative LSDA references in GAS so we use the default
|
|
|
|
// DW_EH_PE_absptr for those.
|
2016-08-04 17:36:03 +02:00
|
|
|
|
|
|
|
// FreeBSD must be explicit about the data size and using pcrel since it's
|
|
|
|
// assembler/linker won't do the automatic conversion that the Linux tools
|
|
|
|
// do.
|
|
|
|
if (T.isOSFreeBSD()) {
|
|
|
|
PersonalityEncoding |= dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
|
|
|
}
|
2014-05-30 18:48:56 +02:00
|
|
|
break;
|
2014-05-01 01:23:14 +02:00
|
|
|
case Triple::ppc64:
|
|
|
|
case Triple::ppc64le:
|
2013-01-09 18:08:15 +01:00
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_udata8;
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_udata8;
|
2014-05-01 01:23:14 +02:00
|
|
|
break;
|
2015-04-29 22:30:57 +02:00
|
|
|
case Triple::sparcel:
|
2014-05-01 01:23:14 +02:00
|
|
|
case Triple::sparc:
|
2016-05-18 13:58:50 +02:00
|
|
|
if (PositionIndependent) {
|
2014-01-28 03:52:26 +01:00
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4;
|
|
|
|
} else {
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
}
|
2014-05-01 01:36:24 +02:00
|
|
|
break;
|
2014-05-01 01:23:14 +02:00
|
|
|
case Triple::sparcv9:
|
2014-01-28 03:52:26 +01:00
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
2016-05-18 13:58:50 +02:00
|
|
|
if (PositionIndependent) {
|
2014-01-28 03:52:26 +01:00
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4;
|
|
|
|
} else {
|
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
}
|
2014-05-01 01:36:24 +02:00
|
|
|
break;
|
2014-05-01 01:23:14 +02:00
|
|
|
case Triple::systemz:
|
2013-05-06 18:11:12 +02:00
|
|
|
// All currently-defined code models guarantee that 4-byte PC-relative
|
|
|
|
// values will be in range.
|
2016-05-18 13:58:50 +02:00
|
|
|
if (PositionIndependent) {
|
2013-05-06 19:28:30 +02:00
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4;
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
|
|
|
dwarf::DW_EH_PE_sdata4;
|
|
|
|
} else {
|
|
|
|
PersonalityEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
LSDAEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
TTypeEncoding = dwarf::DW_EH_PE_absptr;
|
|
|
|
}
|
2014-05-01 01:36:24 +02:00
|
|
|
break;
|
2014-05-01 01:23:14 +02:00
|
|
|
default:
|
|
|
|
break;
|
2011-07-20 21:50:42 +02:00
|
|
|
}
|
|
|
|
|
2015-11-06 16:30:45 +01:00
|
|
|
unsigned EHSectionType = T.getArch() == Triple::x86_64
|
|
|
|
? ELF::SHT_X86_64_UNWIND
|
|
|
|
: ELF::SHT_PROGBITS;
|
2015-11-06 14:35:35 +01:00
|
|
|
|
2012-02-17 18:31:15 +01:00
|
|
|
// Solaris requires different flags for .eh_frame to seemingly every other
|
|
|
|
// platform.
|
2015-11-06 16:30:45 +01:00
|
|
|
unsigned EHSectionFlags = ELF::SHF_ALLOC;
|
2015-11-06 14:35:35 +01:00
|
|
|
if (T.isOSSolaris() && T.getArch() != Triple::x86_64)
|
|
|
|
EHSectionFlags |= ELF::SHF_WRITE;
|
2012-02-17 18:31:15 +01:00
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
// ELF
|
2015-01-29 18:33:21 +01:00
|
|
|
BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
|
|
|
|
ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2015-01-29 18:33:21 +01:00
|
|
|
TextSection = Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
|
|
|
|
ELF::SHF_EXECINSTR | ELF::SHF_ALLOC);
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2015-01-29 18:33:21 +01:00
|
|
|
DataSection = Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
|
|
|
|
ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
2011-07-20 07:58:47 +02:00
|
|
|
|
|
|
|
ReadOnlySection =
|
2015-01-29 18:33:21 +01:00
|
|
|
Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
|
2011-07-20 07:58:47 +02:00
|
|
|
|
|
|
|
TLSDataSection =
|
2015-01-29 18:33:21 +01:00
|
|
|
Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
|
|
|
|
ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
|
|
|
|
|
|
|
|
TLSBSSSection = Ctx->getELFSection(
|
|
|
|
".tbss", ELF::SHT_NOBITS, ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
|
|
|
|
|
|
|
|
DataRelROSection = Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
|
|
|
|
ELF::SHF_ALLOC | ELF::SHF_WRITE);
|
2011-07-20 07:58:47 +02:00
|
|
|
|
|
|
|
MergeableConst4Section =
|
2015-01-29 18:33:21 +01:00
|
|
|
Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
|
|
|
|
ELF::SHF_ALLOC | ELF::SHF_MERGE, 4, "");
|
2011-07-20 07:58:47 +02:00
|
|
|
|
|
|
|
MergeableConst8Section =
|
2015-01-29 18:33:21 +01:00
|
|
|
Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
|
|
|
|
ELF::SHF_ALLOC | ELF::SHF_MERGE, 8, "");
|
2011-07-20 07:58:47 +02:00
|
|
|
|
|
|
|
MergeableConst16Section =
|
2015-01-29 18:33:21 +01:00
|
|
|
Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
|
|
|
|
ELF::SHF_ALLOC | ELF::SHF_MERGE, 16, "");
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2016-02-22 23:23:11 +01:00
|
|
|
MergeableConst32Section =
|
|
|
|
Ctx->getELFSection(".rodata.cst32", ELF::SHT_PROGBITS,
|
|
|
|
ELF::SHF_ALLOC | ELF::SHF_MERGE, 32, "");
|
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
// 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.
|
2015-01-29 18:33:21 +01:00
|
|
|
LSDASection = Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
|
|
|
|
ELF::SHF_ALLOC);
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2014-04-13 06:57:38 +02:00
|
|
|
COFFDebugSymbolsSection = nullptr;
|
2016-01-29 19:16:43 +01:00
|
|
|
COFFDebugTypesSection = nullptr;
|
2014-01-30 02:39:17 +01:00
|
|
|
|
2017-03-10 09:22:20 +01:00
|
|
|
unsigned DebugSecType = ELF::SHT_PROGBITS;
|
|
|
|
|
|
|
|
// MIPS .debug_* sections should have SHT_MIPS_DWARF section type
|
|
|
|
// to distinguish among sections contain DWARF and ECOFF debug formats.
|
|
|
|
// Sections with ECOFF debug format are obsoleted and marked by SHT_PROGBITS.
|
|
|
|
if (T.getArch() == Triple::mips || T.getArch() == Triple::mipsel ||
|
|
|
|
T.getArch() == Triple::mips64 || T.getArch() == Triple::mips64el)
|
|
|
|
DebugSecType = ELF::SHT_MIPS_DWARF;
|
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
// Debug Info Sections.
|
2017-02-02 22:26:06 +01:00
|
|
|
DwarfAbbrevSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_abbrev", DebugSecType, 0);
|
|
|
|
DwarfInfoSection = Ctx->getELFSection(".debug_info", DebugSecType, 0);
|
|
|
|
DwarfLineSection = Ctx->getELFSection(".debug_line", DebugSecType, 0);
|
|
|
|
DwarfFrameSection = Ctx->getELFSection(".debug_frame", DebugSecType, 0);
|
2013-02-12 19:00:14 +01:00
|
|
|
DwarfPubNamesSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_pubnames", DebugSecType, 0);
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfPubTypesSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_pubtypes", DebugSecType, 0);
|
2013-09-09 22:03:14 +02:00
|
|
|
DwarfGnuPubNamesSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_gnu_pubnames", DebugSecType, 0);
|
2013-09-09 22:03:14 +02:00
|
|
|
DwarfGnuPubTypesSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_gnu_pubtypes", DebugSecType, 0);
|
2015-03-11 05:20:31 +01:00
|
|
|
DwarfStrSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_str", DebugSecType,
|
2015-03-11 05:20:31 +01:00
|
|
|
ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
|
2017-03-10 09:22:20 +01:00
|
|
|
DwarfLocSection = Ctx->getELFSection(".debug_loc", DebugSecType, 0);
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfARangesSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_aranges", DebugSecType, 0);
|
2011-07-20 07:58:47 +02:00
|
|
|
DwarfRangesSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_ranges", DebugSecType, 0);
|
2017-02-02 22:26:06 +01:00
|
|
|
DwarfMacinfoSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_macinfo", DebugSecType, 0);
|
2012-11-28 03:49:34 +01:00
|
|
|
|
|
|
|
// DWARF5 Experimental Debug Info
|
|
|
|
|
|
|
|
// Accelerator Tables
|
2012-10-08 23:41:30 +02:00
|
|
|
DwarfAccelNamesSection =
|
2017-02-02 22:26:06 +01:00
|
|
|
Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0);
|
2012-10-08 23:41:30 +02:00
|
|
|
DwarfAccelObjCSection =
|
2017-02-02 22:26:06 +01:00
|
|
|
Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0);
|
|
|
|
DwarfAccelNamespaceSection =
|
|
|
|
Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0);
|
2012-10-08 23:41:30 +02:00
|
|
|
DwarfAccelTypesSection =
|
2017-02-02 22:26:06 +01:00
|
|
|
Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0);
|
2012-11-28 03:49:38 +01:00
|
|
|
|
2017-06-06 03:22:34 +02:00
|
|
|
// String Offset and Address Sections
|
|
|
|
DwarfStrOffSection =
|
|
|
|
Ctx->getELFSection(".debug_str_offsets", DebugSecType, 0);
|
|
|
|
DwarfAddrSection = Ctx->getELFSection(".debug_addr", DebugSecType, 0);
|
|
|
|
|
2012-11-28 03:49:38 +01:00
|
|
|
// Fission Sections
|
2015-03-11 05:20:31 +01:00
|
|
|
DwarfInfoDWOSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_info.dwo", DebugSecType, 0);
|
2015-03-11 05:20:31 +01:00
|
|
|
DwarfTypesDWOSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_types.dwo", DebugSecType, 0);
|
2015-03-11 05:20:31 +01:00
|
|
|
DwarfAbbrevDWOSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_abbrev.dwo", DebugSecType, 0);
|
2015-03-11 05:20:31 +01:00
|
|
|
DwarfStrDWOSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_str.dwo", DebugSecType,
|
2015-03-11 05:20:31 +01:00
|
|
|
ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
|
2012-11-30 07:47:06 +01:00
|
|
|
DwarfLineDWOSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_line.dwo", DebugSecType, 0);
|
2012-11-30 07:47:06 +01:00
|
|
|
DwarfLocDWOSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_loc.dwo", DebugSecType, 0);
|
2013-01-04 18:59:22 +01:00
|
|
|
DwarfStrOffDWOSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_str_offsets.dwo", DebugSecType, 0);
|
2014-08-01 20:47:09 +02:00
|
|
|
|
2015-12-02 07:21:34 +01:00
|
|
|
// DWP Sections
|
|
|
|
DwarfCUIndexSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_cu_index", DebugSecType, 0);
|
2015-12-05 04:05:45 +01:00
|
|
|
DwarfTUIndexSection =
|
2017-03-10 09:22:20 +01:00
|
|
|
Ctx->getELFSection(".debug_tu_index", DebugSecType, 0);
|
2015-12-02 07:21:34 +01:00
|
|
|
|
2014-08-01 20:47:09 +02:00
|
|
|
StackMapSection =
|
2015-01-29 18:33:21 +01:00
|
|
|
Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
|
2015-06-15 20:44:08 +02:00
|
|
|
|
|
|
|
FaultMapSection =
|
|
|
|
Ctx->getELFSection(".llvm_faultmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
|
2015-11-06 16:30:45 +01:00
|
|
|
|
|
|
|
EHFrameSection =
|
|
|
|
Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
|
2011-07-20 07:58:47 +02:00
|
|
|
}
|
|
|
|
|
2016-06-08 21:09:22 +02:00
|
|
|
void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
|
2015-11-06 16:30:45 +01:00
|
|
|
EHFrameSection = Ctx->getCOFFSection(
|
|
|
|
".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
|
2015-11-18 07:02:15 +01:00
|
|
|
SectionKind::getData());
|
2015-11-06 16:30:45 +01:00
|
|
|
|
2016-06-27 16:42:20 +02:00
|
|
|
// Set the `IMAGE_SCN_MEM_16BIT` flag when compiling for thumb mode. This is
|
|
|
|
// used to indicate to the linker that the text segment contains thumb instructions
|
|
|
|
// and to set the ISA selection bit for calls accordingly.
|
|
|
|
const bool IsThumb = T.getArch() == Triple::thumb;
|
2014-06-08 05:57:49 +02:00
|
|
|
|
2014-09-21 11:18:07 +02:00
|
|
|
CommDirectiveSupportsAlignment = true;
|
2014-04-09 00:33:40 +02:00
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
// COFF
|
2015-03-10 22:16:18 +01:00
|
|
|
BSSSection = Ctx->getCOFFSection(
|
|
|
|
".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
|
|
|
|
SectionKind::getBSS());
|
|
|
|
TextSection = Ctx->getCOFFSection(
|
|
|
|
".text",
|
2016-06-27 16:42:20 +02:00
|
|
|
(IsThumb ? COFF::IMAGE_SCN_MEM_16BIT : (COFF::SectionCharacteristics)0) |
|
2015-03-10 22:16:18 +01:00
|
|
|
COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getText());
|
|
|
|
DataSection = Ctx->getCOFFSection(
|
|
|
|
".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
|
|
|
|
COFF::IMAGE_SCN_MEM_WRITE,
|
2015-11-18 07:02:15 +01:00
|
|
|
SectionKind::getData());
|
2015-03-10 22:16:18 +01:00
|
|
|
ReadOnlySection = Ctx->getCOFFSection(
|
|
|
|
".rdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getReadOnly());
|
2014-06-08 02:34:23 +02:00
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
// FIXME: We're emitting LSDA info into a readonly section on COFF, 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.
|
2014-06-25 14:41:52 +02:00
|
|
|
if (T.getArch() == Triple::x86_64) {
|
|
|
|
// On Windows 64 with SEH, the LSDA is emitted into the .xdata section
|
2015-10-07 01:24:35 +02:00
|
|
|
LSDASection = nullptr;
|
2014-06-25 14:41:52 +02:00
|
|
|
} else {
|
|
|
|
LSDASection = Ctx->getCOFFSection(".gcc_except_table",
|
|
|
|
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getReadOnly());
|
|
|
|
}
|
2011-07-20 07:58:47 +02:00
|
|
|
|
|
|
|
// Debug info.
|
2014-01-28 04:48:44 +01:00
|
|
|
COFFDebugSymbolsSection =
|
2016-01-29 19:16:43 +01:00
|
|
|
Ctx->getCOFFSection(".debug$S", (COFF::IMAGE_SCN_MEM_DISCARDABLE |
|
|
|
|
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ),
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
COFFDebugTypesSection =
|
|
|
|
Ctx->getCOFFSection(".debug$T", (COFF::IMAGE_SCN_MEM_DISCARDABLE |
|
|
|
|
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ),
|
2015-03-10 22:16:18 +01:00
|
|
|
SectionKind::getMetadata());
|
|
|
|
|
|
|
|
DwarfAbbrevSection = Ctx->getCOFFSection(
|
|
|
|
".debug_abbrev",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_abbrev");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfInfoSection = Ctx->getCOFFSection(
|
|
|
|
".debug_info",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_info");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfLineSection = Ctx->getCOFFSection(
|
|
|
|
".debug_line",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_line");
|
|
|
|
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfFrameSection = Ctx->getCOFFSection(
|
|
|
|
".debug_frame",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
DwarfPubNamesSection = Ctx->getCOFFSection(
|
|
|
|
".debug_pubnames",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
DwarfPubTypesSection = Ctx->getCOFFSection(
|
|
|
|
".debug_pubtypes",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
DwarfGnuPubNamesSection = Ctx->getCOFFSection(
|
|
|
|
".debug_gnu_pubnames",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
DwarfGnuPubTypesSection = Ctx->getCOFFSection(
|
|
|
|
".debug_gnu_pubtypes",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
DwarfStrSection = Ctx->getCOFFSection(
|
|
|
|
".debug_str",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "info_string");
|
2017-06-06 03:22:34 +02:00
|
|
|
DwarfStrOffSection = Ctx->getCOFFSection(
|
|
|
|
".debug_str_offsets",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata(), "section_str_off");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfLocSection = Ctx->getCOFFSection(
|
|
|
|
".debug_loc",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_debug_loc");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfARangesSection = Ctx->getCOFFSection(
|
|
|
|
".debug_aranges",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
DwarfRangesSection = Ctx->getCOFFSection(
|
|
|
|
".debug_ranges",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "debug_range");
|
2016-01-07 15:28:20 +01:00
|
|
|
DwarfMacinfoSection = Ctx->getCOFFSection(
|
|
|
|
".debug_macinfo",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2016-02-01 15:09:41 +01:00
|
|
|
SectionKind::getMetadata(), "debug_macinfo");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfInfoDWOSection = Ctx->getCOFFSection(
|
|
|
|
".debug_info.dwo",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_info_dwo");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfTypesDWOSection = Ctx->getCOFFSection(
|
|
|
|
".debug_types.dwo",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-11 00:06:32 +01:00
|
|
|
SectionKind::getMetadata(), "section_types_dwo");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfAbbrevDWOSection = Ctx->getCOFFSection(
|
|
|
|
".debug_abbrev.dwo",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "section_abbrev_dwo");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfStrDWOSection = Ctx->getCOFFSection(
|
|
|
|
".debug_str.dwo",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "skel_string");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfLineDWOSection = Ctx->getCOFFSection(
|
|
|
|
".debug_line.dwo",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
DwarfLocDWOSection = Ctx->getCOFFSection(
|
|
|
|
".debug_loc.dwo",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "skel_loc");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfStrOffDWOSection = Ctx->getCOFFSection(
|
|
|
|
".debug_str_offsets.dwo",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2017-06-06 03:22:34 +02:00
|
|
|
SectionKind::getMetadata(), "section_str_off_dwo");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfAddrSection = Ctx->getCOFFSection(
|
|
|
|
".debug_addr",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "addr_sec");
|
2015-12-02 07:21:34 +01:00
|
|
|
DwarfCUIndexSection = Ctx->getCOFFSection(
|
|
|
|
".debug_cu_index",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata());
|
2015-12-05 04:05:45 +01:00
|
|
|
DwarfTUIndexSection = Ctx->getCOFFSection(
|
|
|
|
".debug_tu_index",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
|
|
|
SectionKind::getMetadata());
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfAccelNamesSection = Ctx->getCOFFSection(
|
|
|
|
".apple_names",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "names_begin");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfAccelNamespaceSection = Ctx->getCOFFSection(
|
|
|
|
".apple_namespaces",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "namespac_begin");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfAccelTypesSection = Ctx->getCOFFSection(
|
|
|
|
".apple_types",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "types_begin");
|
2015-03-10 22:16:18 +01:00
|
|
|
DwarfAccelObjCSection = Ctx->getCOFFSection(
|
|
|
|
".apple_objc",
|
|
|
|
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-03-10 23:00:25 +01:00
|
|
|
SectionKind::getMetadata(), "objc_begin");
|
2015-03-10 22:16:18 +01:00
|
|
|
|
|
|
|
DrectveSection = Ctx->getCOFFSection(
|
|
|
|
".drectve", COFF::IMAGE_SCN_LNK_INFO | COFF::IMAGE_SCN_LNK_REMOVE,
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
|
|
|
|
PDataSection = Ctx->getCOFFSection(
|
|
|
|
".pdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
|
2015-11-18 07:02:15 +01:00
|
|
|
SectionKind::getData());
|
2015-03-10 22:16:18 +01:00
|
|
|
|
|
|
|
XDataSection = Ctx->getCOFFSection(
|
|
|
|
".xdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
|
2015-11-18 07:02:15 +01:00
|
|
|
SectionKind::getData());
|
2015-03-10 22:16:18 +01:00
|
|
|
|
2015-05-30 06:56:02 +02:00
|
|
|
SXDataSection = Ctx->getCOFFSection(".sxdata", COFF::IMAGE_SCN_LNK_INFO,
|
|
|
|
SectionKind::getMetadata());
|
|
|
|
|
2015-03-10 22:16:18 +01:00
|
|
|
TLSDataSection = Ctx->getCOFFSection(
|
|
|
|
".tls$", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
|
|
|
|
COFF::IMAGE_SCN_MEM_WRITE,
|
2015-11-18 07:02:15 +01:00
|
|
|
SectionKind::getData());
|
2015-09-22 13:15:07 +02:00
|
|
|
|
2015-06-25 02:28:42 +02:00
|
|
|
StackMapSection = Ctx->getCOFFSection(".llvm_stackmaps",
|
|
|
|
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
|
|
|
COFF::IMAGE_SCN_MEM_READ,
|
2015-09-22 13:15:07 +02:00
|
|
|
SectionKind::getReadOnly());
|
2011-07-20 07:58:47 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 02:23:18 +01:00
|
|
|
void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
|
|
|
|
// TODO: Set the section types and flags.
|
2017-02-25 00:18:00 +01:00
|
|
|
TextSection = Ctx->getWasmSection(".text", 0, 0);
|
|
|
|
DataSection = Ctx->getWasmSection(".data", 0, 0);
|
2017-02-22 02:23:18 +01:00
|
|
|
|
|
|
|
// TODO: Set the section types and flags.
|
|
|
|
DwarfLineSection = Ctx->getWasmSection(".debug_line", 0, 0);
|
|
|
|
DwarfStrSection = Ctx->getWasmSection(".debug_str", 0, 0);
|
|
|
|
DwarfLocSection = Ctx->getWasmSection(".debug_loc", 0, 0);
|
|
|
|
DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", 0, 0, "section_abbrev");
|
|
|
|
DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", 0, 0);
|
|
|
|
DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", 0, 0, "debug_range");
|
|
|
|
DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", 0, 0, "debug_macinfo");
|
|
|
|
DwarfAddrSection = Ctx->getWasmSection(".debug_addr", 0, 0);
|
|
|
|
DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", 0, 0);
|
|
|
|
DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", 0, 0);
|
|
|
|
DwarfInfoSection = Ctx->getWasmSection(".debug_info", 0, 0, "section_info");
|
|
|
|
DwarfFrameSection = Ctx->getWasmSection(".debug_frame", 0, 0);
|
|
|
|
DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", 0, 0);
|
|
|
|
DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", 0, 0);
|
|
|
|
|
|
|
|
// TODO: Define more sections.
|
|
|
|
}
|
|
|
|
|
2016-05-18 13:58:50 +02:00
|
|
|
void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,
|
2011-07-20 21:50:42 +02:00
|
|
|
CodeModel::Model cm,
|
2011-07-20 07:58:47 +02:00
|
|
|
MCContext &ctx) {
|
2016-05-18 13:58:50 +02:00
|
|
|
PositionIndependent = PIC;
|
2011-07-20 21:50:42 +02:00
|
|
|
CMModel = cm;
|
2011-07-20 07:58:47 +02:00
|
|
|
Ctx = &ctx;
|
|
|
|
|
|
|
|
// Common.
|
|
|
|
CommDirectiveSupportsAlignment = true;
|
|
|
|
SupportsWeakOmittedEHFrame = true;
|
2014-03-29 10:03:13 +01:00
|
|
|
SupportsCompactUnwindWithoutEHFrame = false;
|
2015-10-28 23:56:36 +01:00
|
|
|
OmitDwarfIfHaveCompactUnwind = false;
|
2011-07-20 21:50:42 +02:00
|
|
|
|
2014-05-12 15:47:05 +02:00
|
|
|
PersonalityEncoding = LSDAEncoding = FDECFIEncoding = TTypeEncoding =
|
|
|
|
dwarf::DW_EH_PE_absptr;
|
2011-07-20 21:50:42 +02:00
|
|
|
|
2013-04-10 23:42:06 +02:00
|
|
|
CompactUnwindDwarfEHFrameOnly = 0;
|
|
|
|
|
2014-04-13 06:57:38 +02:00
|
|
|
EHFrameSection = nullptr; // Created on demand.
|
|
|
|
CompactUnwindSection = nullptr; // Used only by selected targets.
|
|
|
|
DwarfAccelNamesSection = nullptr; // Used only by selected targets.
|
|
|
|
DwarfAccelObjCSection = nullptr; // Used only by selected targets.
|
|
|
|
DwarfAccelNamespaceSection = nullptr; // Used only by selected targets.
|
|
|
|
DwarfAccelTypesSection = nullptr; // Used only by selected targets.
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2015-06-16 14:18:07 +02:00
|
|
|
TT = TheTriple;
|
2014-06-23 00:25:01 +02:00
|
|
|
|
2015-12-22 02:39:04 +01:00
|
|
|
switch (TT.getObjectFormat()) {
|
|
|
|
case Triple::MachO:
|
2015-08-14 17:48:41 +02:00
|
|
|
Env = IsMachO;
|
2015-06-05 01:35:03 +02:00
|
|
|
initMachOMCObjectFileInfo(TT);
|
2015-12-22 02:39:04 +01:00
|
|
|
break;
|
|
|
|
case Triple::COFF:
|
|
|
|
if (!TT.isOSWindows())
|
|
|
|
report_fatal_error(
|
|
|
|
"Cannot initialize MC for non-Windows COFF object files.");
|
|
|
|
|
2015-08-14 17:48:41 +02:00
|
|
|
Env = IsCOFF;
|
2015-06-05 01:35:03 +02:00
|
|
|
initCOFFMCObjectFileInfo(TT);
|
2015-12-22 02:39:04 +01:00
|
|
|
break;
|
|
|
|
case Triple::ELF:
|
2015-08-14 17:48:41 +02:00
|
|
|
Env = IsELF;
|
2015-06-05 01:35:03 +02:00
|
|
|
initELFMCObjectFileInfo(TT);
|
2015-12-22 02:39:04 +01:00
|
|
|
break;
|
2017-01-17 21:34:09 +01:00
|
|
|
case Triple::Wasm:
|
2017-02-22 02:23:18 +01:00
|
|
|
Env = IsWasm;
|
|
|
|
initWasmMCObjectFileInfo(TT);
|
2017-01-17 21:34:09 +01:00
|
|
|
break;
|
2015-12-22 02:39:04 +01:00
|
|
|
case Triple::UnknownObjectFormat:
|
|
|
|
report_fatal_error("Cannot initialize MC for unknown object file format.");
|
|
|
|
break;
|
2011-07-20 07:58:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-21 21:20:38 +02:00
|
|
|
MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
|
2013-12-13 22:33:40 +01:00
|
|
|
return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
|
2015-01-29 18:33:21 +01:00
|
|
|
0, utostr(Hash));
|
2013-12-13 22:33:40 +01:00
|
|
|
}
|