blob: 87ff0d359d1ad1b6d0059f4142c6aec693bc3655 [file] [log] [blame]
Evan Cheng76792992011-07-20 05:58:47 +00001//===-- MObjectFileInfo.cpp - Object File Information ---------------------===//
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 "llvm/MC/MCObjectFileInfo.h"
David Blaikiebc563272013-12-13 21:33:40 +000011#include "llvm/ADT/StringExtras.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000012#include "llvm/ADT/Triple.h"
Evan Cheng76792992011-07-20 05:58:47 +000013#include "llvm/MC/MCContext.h"
14#include "llvm/MC/MCSection.h"
15#include "llvm/MC/MCSectionCOFF.h"
16#include "llvm/MC/MCSectionELF.h"
17#include "llvm/MC/MCSectionMachO.h"
Evan Cheng76792992011-07-20 05:58:47 +000018using namespace llvm;
19
20void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
21 // MachO
22 IsFunctionEHFrameSymbolPrivate = false;
23 SupportsWeakOmittedEHFrame = false;
24
Evan Chengbbf3b0d2011-07-20 19:50:42 +000025 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel
26 | dwarf::DW_EH_PE_sdata4;
27 LSDAEncoding = FDEEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
28 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
29 dwarf::DW_EH_PE_sdata4;
30
Evan Cheng76792992011-07-20 05:58:47 +000031 // .comm doesn't support alignment before Leopard.
32 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5))
33 CommDirectiveSupportsAlignment = false;
34
35 TextSection // .text
36 = Ctx->getMachOSection("__TEXT", "__text",
David Majnemer7b583052014-03-07 07:36:05 +000037 MachO::S_ATTR_PURE_INSTRUCTIONS,
Evan Cheng76792992011-07-20 05:58:47 +000038 SectionKind::getText());
39 DataSection // .data
40 = Ctx->getMachOSection("__DATA", "__data", 0,
41 SectionKind::getDataRel());
42
NAKAMURA Takumi68fa6f92013-09-21 02:34:45 +000043 // BSSSection might not be expected initialized on msvc.
44 BSSSection = 0;
45
Evan Cheng76792992011-07-20 05:58:47 +000046 TLSDataSection // .tdata
47 = Ctx->getMachOSection("__DATA", "__thread_data",
David Majnemer7b583052014-03-07 07:36:05 +000048 MachO::S_THREAD_LOCAL_REGULAR,
Evan Cheng76792992011-07-20 05:58:47 +000049 SectionKind::getDataRel());
50 TLSBSSSection // .tbss
51 = Ctx->getMachOSection("__DATA", "__thread_bss",
David Majnemer7b583052014-03-07 07:36:05 +000052 MachO::S_THREAD_LOCAL_ZEROFILL,
Evan Cheng76792992011-07-20 05:58:47 +000053 SectionKind::getThreadBSS());
54
55 // TODO: Verify datarel below.
56 TLSTLVSection // .tlv
57 = Ctx->getMachOSection("__DATA", "__thread_vars",
David Majnemer7b583052014-03-07 07:36:05 +000058 MachO::S_THREAD_LOCAL_VARIABLES,
Evan Cheng76792992011-07-20 05:58:47 +000059 SectionKind::getDataRel());
60
61 TLSThreadInitSection
62 = Ctx->getMachOSection("__DATA", "__thread_init",
David Majnemer7b583052014-03-07 07:36:05 +000063 MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
Jim Grosbach0dde3492011-11-15 16:46:22 +000064 SectionKind::getDataRel());
Evan Cheng76792992011-07-20 05:58:47 +000065
66 CStringSection // .cstring
67 = Ctx->getMachOSection("__TEXT", "__cstring",
David Majnemer7b583052014-03-07 07:36:05 +000068 MachO::S_CSTRING_LITERALS,
Evan Cheng76792992011-07-20 05:58:47 +000069 SectionKind::getMergeable1ByteCString());
70 UStringSection
71 = Ctx->getMachOSection("__TEXT","__ustring", 0,
72 SectionKind::getMergeable2ByteCString());
73 FourByteConstantSection // .literal4
74 = Ctx->getMachOSection("__TEXT", "__literal4",
David Majnemer7b583052014-03-07 07:36:05 +000075 MachO::S_4BYTE_LITERALS,
Evan Cheng76792992011-07-20 05:58:47 +000076 SectionKind::getMergeableConst4());
77 EightByteConstantSection // .literal8
78 = Ctx->getMachOSection("__TEXT", "__literal8",
David Majnemer7b583052014-03-07 07:36:05 +000079 MachO::S_8BYTE_LITERALS,
Evan Cheng76792992011-07-20 05:58:47 +000080 SectionKind::getMergeableConst8());
81
Rafael Espindola1f3de492014-02-13 23:16:11 +000082 SixteenByteConstantSection // .literal16
83 = Ctx->getMachOSection("__TEXT", "__literal16",
David Majnemer7b583052014-03-07 07:36:05 +000084 MachO::S_16BYTE_LITERALS,
Rafael Espindola1f3de492014-02-13 23:16:11 +000085 SectionKind::getMergeableConst16());
Evan Cheng76792992011-07-20 05:58:47 +000086
87 ReadOnlySection // .const
88 = Ctx->getMachOSection("__TEXT", "__const", 0,
89 SectionKind::getReadOnly());
90
91 TextCoalSection
92 = Ctx->getMachOSection("__TEXT", "__textcoal_nt",
David Majnemer7b583052014-03-07 07:36:05 +000093 MachO::S_COALESCED |
94 MachO::S_ATTR_PURE_INSTRUCTIONS,
Evan Cheng76792992011-07-20 05:58:47 +000095 SectionKind::getText());
96 ConstTextCoalSection
97 = Ctx->getMachOSection("__TEXT", "__const_coal",
David Majnemer7b583052014-03-07 07:36:05 +000098 MachO::S_COALESCED,
Evan Cheng76792992011-07-20 05:58:47 +000099 SectionKind::getReadOnly());
100 ConstDataSection // .const_data
101 = Ctx->getMachOSection("__DATA", "__const", 0,
102 SectionKind::getReadOnlyWithRel());
103 DataCoalSection
104 = Ctx->getMachOSection("__DATA","__datacoal_nt",
David Majnemer7b583052014-03-07 07:36:05 +0000105 MachO::S_COALESCED,
Evan Cheng76792992011-07-20 05:58:47 +0000106 SectionKind::getDataRel());
107 DataCommonSection
108 = Ctx->getMachOSection("__DATA","__common",
David Majnemer7b583052014-03-07 07:36:05 +0000109 MachO::S_ZEROFILL,
Evan Cheng76792992011-07-20 05:58:47 +0000110 SectionKind::getBSS());
111 DataBSSSection
David Majnemer7b583052014-03-07 07:36:05 +0000112 = Ctx->getMachOSection("__DATA","__bss", MachO::S_ZEROFILL,
Evan Cheng76792992011-07-20 05:58:47 +0000113 SectionKind::getBSS());
114
115
116 LazySymbolPointerSection
117 = Ctx->getMachOSection("__DATA", "__la_symbol_ptr",
David Majnemer7b583052014-03-07 07:36:05 +0000118 MachO::S_LAZY_SYMBOL_POINTERS,
Evan Cheng76792992011-07-20 05:58:47 +0000119 SectionKind::getMetadata());
120 NonLazySymbolPointerSection
121 = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr",
David Majnemer7b583052014-03-07 07:36:05 +0000122 MachO::S_NON_LAZY_SYMBOL_POINTERS,
Evan Cheng76792992011-07-20 05:58:47 +0000123 SectionKind::getMetadata());
124
125 if (RelocM == Reloc::Static) {
126 StaticCtorSection
127 = Ctx->getMachOSection("__TEXT", "__constructor", 0,
128 SectionKind::getDataRel());
129 StaticDtorSection
130 = Ctx->getMachOSection("__TEXT", "__destructor", 0,
131 SectionKind::getDataRel());
132 } else {
133 StaticCtorSection
134 = Ctx->getMachOSection("__DATA", "__mod_init_func",
David Majnemer7b583052014-03-07 07:36:05 +0000135 MachO::S_MOD_INIT_FUNC_POINTERS,
Evan Cheng76792992011-07-20 05:58:47 +0000136 SectionKind::getDataRel());
137 StaticDtorSection
138 = Ctx->getMachOSection("__DATA", "__mod_term_func",
David Majnemer7b583052014-03-07 07:36:05 +0000139 MachO::S_MOD_TERM_FUNC_POINTERS,
Evan Cheng76792992011-07-20 05:58:47 +0000140 SectionKind::getDataRel());
141 }
142
143 // Exception Handling.
144 LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0,
145 SectionKind::getReadOnlyWithRel());
146
Timur Iskhodzhanovf166f6c2014-01-30 01:39:17 +0000147 COFFDebugSymbolsSection = 0;
148
Bill Wendling2d1df6b2013-04-10 21:42:06 +0000149 if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6)) {
Evan Cheng76792992011-07-20 05:58:47 +0000150 CompactUnwindSection =
151 Ctx->getMachOSection("__LD", "__compact_unwind",
David Majnemer7b583052014-03-07 07:36:05 +0000152 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000153 SectionKind::getReadOnly());
154
Bill Wendling2d1df6b2013-04-10 21:42:06 +0000155 if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)
156 CompactUnwindDwarfEHFrameOnly = 0x04000000;
157 }
158
Evan Cheng76792992011-07-20 05:58:47 +0000159 // Debug Information.
Eric Christopher4996c702011-11-07 09:24:32 +0000160 DwarfAccelNamesSection =
161 Ctx->getMachOSection("__DWARF", "__apple_names",
David Majnemer7b583052014-03-07 07:36:05 +0000162 MachO::S_ATTR_DEBUG,
Eric Christopher4996c702011-11-07 09:24:32 +0000163 SectionKind::getMetadata());
164 DwarfAccelObjCSection =
165 Ctx->getMachOSection("__DWARF", "__apple_objc",
David Majnemer7b583052014-03-07 07:36:05 +0000166 MachO::S_ATTR_DEBUG,
Eric Christopher4996c702011-11-07 09:24:32 +0000167 SectionKind::getMetadata());
168 // 16 character section limit...
169 DwarfAccelNamespaceSection =
170 Ctx->getMachOSection("__DWARF", "__apple_namespac",
David Majnemer7b583052014-03-07 07:36:05 +0000171 MachO::S_ATTR_DEBUG,
Eric Christopher4996c702011-11-07 09:24:32 +0000172 SectionKind::getMetadata());
173 DwarfAccelTypesSection =
174 Ctx->getMachOSection("__DWARF", "__apple_types",
David Majnemer7b583052014-03-07 07:36:05 +0000175 MachO::S_ATTR_DEBUG,
Eric Christopher4996c702011-11-07 09:24:32 +0000176 SectionKind::getMetadata());
Jim Grosbachdc1e36e2012-05-11 01:41:30 +0000177
Evan Cheng76792992011-07-20 05:58:47 +0000178 DwarfAbbrevSection =
179 Ctx->getMachOSection("__DWARF", "__debug_abbrev",
David Majnemer7b583052014-03-07 07:36:05 +0000180 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000181 SectionKind::getMetadata());
182 DwarfInfoSection =
183 Ctx->getMachOSection("__DWARF", "__debug_info",
David Majnemer7b583052014-03-07 07:36:05 +0000184 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000185 SectionKind::getMetadata());
186 DwarfLineSection =
187 Ctx->getMachOSection("__DWARF", "__debug_line",
David Majnemer7b583052014-03-07 07:36:05 +0000188 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000189 SectionKind::getMetadata());
190 DwarfFrameSection =
191 Ctx->getMachOSection("__DWARF", "__debug_frame",
David Majnemer7b583052014-03-07 07:36:05 +0000192 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000193 SectionKind::getMetadata());
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000194 DwarfPubNamesSection =
195 Ctx->getMachOSection("__DWARF", "__debug_pubnames",
David Majnemer7b583052014-03-07 07:36:05 +0000196 MachO::S_ATTR_DEBUG,
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000197 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000198 DwarfPubTypesSection =
199 Ctx->getMachOSection("__DWARF", "__debug_pubtypes",
David Majnemer7b583052014-03-07 07:36:05 +0000200 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000201 SectionKind::getMetadata());
Eric Christopherb0e76942013-09-09 20:03:14 +0000202 DwarfGnuPubNamesSection =
203 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn",
David Majnemer7b583052014-03-07 07:36:05 +0000204 MachO::S_ATTR_DEBUG,
Eric Christopherb0e76942013-09-09 20:03:14 +0000205 SectionKind::getMetadata());
206 DwarfGnuPubTypesSection =
207 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt",
David Majnemer7b583052014-03-07 07:36:05 +0000208 MachO::S_ATTR_DEBUG,
Eric Christopherb0e76942013-09-09 20:03:14 +0000209 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000210 DwarfStrSection =
211 Ctx->getMachOSection("__DWARF", "__debug_str",
David Majnemer7b583052014-03-07 07:36:05 +0000212 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000213 SectionKind::getMetadata());
214 DwarfLocSection =
215 Ctx->getMachOSection("__DWARF", "__debug_loc",
David Majnemer7b583052014-03-07 07:36:05 +0000216 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000217 SectionKind::getMetadata());
218 DwarfARangesSection =
219 Ctx->getMachOSection("__DWARF", "__debug_aranges",
David Majnemer7b583052014-03-07 07:36:05 +0000220 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000221 SectionKind::getMetadata());
222 DwarfRangesSection =
223 Ctx->getMachOSection("__DWARF", "__debug_ranges",
David Majnemer7b583052014-03-07 07:36:05 +0000224 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000225 SectionKind::getMetadata());
226 DwarfMacroInfoSection =
227 Ctx->getMachOSection("__DWARF", "__debug_macinfo",
David Majnemer7b583052014-03-07 07:36:05 +0000228 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000229 SectionKind::getMetadata());
230 DwarfDebugInlineSection =
231 Ctx->getMachOSection("__DWARF", "__debug_inlined",
David Majnemer7b583052014-03-07 07:36:05 +0000232 MachO::S_ATTR_DEBUG,
Evan Cheng76792992011-07-20 05:58:47 +0000233 SectionKind::getMetadata());
Lang Hames30789772013-11-08 22:14:49 +0000234 StackMapSection =
235 Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps", 0,
236 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000237
238 TLSExtraDataSection = TLSTLVSection;
239}
240
241void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
Rafael Espindolab9b7ae02013-04-03 03:13:19 +0000242 if (T.getArch() == Triple::mips ||
243 T.getArch() == Triple::mipsel)
244 FDECFIEncoding = dwarf::DW_EH_PE_sdata4;
245 else if (T.getArch() == Triple::mips64 ||
246 T.getArch() == Triple::mips64el)
247 FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
248 else
Rafael Espindolaef9d3492013-03-15 05:51:57 +0000249 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
250
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000251 if (T.getArch() == Triple::x86) {
252 PersonalityEncoding = (RelocM == Reloc::PIC_)
Jim Grosbach0dde3492011-11-15 16:46:22 +0000253 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
254 : dwarf::DW_EH_PE_absptr;
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000255 LSDAEncoding = (RelocM == Reloc::PIC_)
256 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
257 : dwarf::DW_EH_PE_absptr;
Rafael Espindolaef9d3492013-03-15 05:51:57 +0000258 FDEEncoding = (RelocM == Reloc::PIC_)
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000259 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
260 : dwarf::DW_EH_PE_absptr;
261 TTypeEncoding = (RelocM == Reloc::PIC_)
Jim Grosbach0dde3492011-11-15 16:46:22 +0000262 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
263 : dwarf::DW_EH_PE_absptr;
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000264 } else if (T.getArch() == Triple::x86_64) {
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000265 if (RelocM == Reloc::PIC_) {
266 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
267 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
268 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
269 LSDAEncoding = dwarf::DW_EH_PE_pcrel |
270 (CMModel == CodeModel::Small
271 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
272 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
273 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
274 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
275 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
276 } else {
277 PersonalityEncoding =
278 (CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
279 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
280 LSDAEncoding = (CMModel == CodeModel::Small)
281 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
282 FDEEncoding = dwarf::DW_EH_PE_udata4;
283 TTypeEncoding = (CMModel == CodeModel::Small)
284 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
285 }
Christian Pirker99974c72014-03-26 14:57:32 +0000286 } else if (T.getArch() == Triple::aarch64 ||
287 T.getArch() == Triple::aarch64_be ) {
Tim Northovere0e3aef2013-01-31 12:12:40 +0000288 // The small model guarantees static code/data size < 4GB, but not where it
289 // will be in memory. Most of these could end up >2GB away so even a signed
290 // pc-relative 32-bit address is insufficient, theoretically.
291 if (RelocM == Reloc::PIC_) {
292 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
293 dwarf::DW_EH_PE_sdata8;
294 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8;
295 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
296 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
297 dwarf::DW_EH_PE_sdata8;
298 } else {
299 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
300 LSDAEncoding = dwarf::DW_EH_PE_absptr;
301 FDEEncoding = dwarf::DW_EH_PE_udata4;
302 TTypeEncoding = dwarf::DW_EH_PE_absptr;
303 }
Bill Schmidt0a9170d2013-07-26 01:35:43 +0000304 } else if (T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le) {
Adhemerval Zanella1ae22482013-01-09 17:08:15 +0000305 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
306 dwarf::DW_EH_PE_udata8;
Adhemerval Zanella1ae22482013-01-09 17:08:15 +0000307 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
308 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
309 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
310 dwarf::DW_EH_PE_udata8;
Jakob Stoklund Olesen83c67732014-01-28 02:52:26 +0000311 } else if (T.getArch() == Triple::sparc) {
312 if (RelocM == Reloc::PIC_) {
313 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
314 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
315 dwarf::DW_EH_PE_sdata4;
316 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
317 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
318 dwarf::DW_EH_PE_sdata4;
319 } else {
320 LSDAEncoding = dwarf::DW_EH_PE_absptr;
321 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
322 FDEEncoding = dwarf::DW_EH_PE_udata4;
323 TTypeEncoding = dwarf::DW_EH_PE_absptr;
324 }
325 } else if (T.getArch() == Triple::sparcv9) {
326 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
327 if (RelocM == Reloc::PIC_) {
328 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
329 dwarf::DW_EH_PE_sdata4;
330 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
331 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
332 dwarf::DW_EH_PE_sdata4;
333 } else {
334 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
335 FDEEncoding = dwarf::DW_EH_PE_udata4;
336 TTypeEncoding = dwarf::DW_EH_PE_absptr;
337 }
Ulrich Weigand0213e7f2013-05-06 16:11:12 +0000338 } else if (T.getArch() == Triple::systemz) {
339 // All currently-defined code models guarantee that 4-byte PC-relative
340 // values will be in range.
Ulrich Weigande7c6dfe2013-05-06 17:28:30 +0000341 if (RelocM == Reloc::PIC_) {
342 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
343 dwarf::DW_EH_PE_sdata4;
344 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
345 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
346 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
347 dwarf::DW_EH_PE_sdata4;
348 } else {
349 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
350 LSDAEncoding = dwarf::DW_EH_PE_absptr;
351 FDEEncoding = dwarf::DW_EH_PE_absptr;
352 TTypeEncoding = dwarf::DW_EH_PE_absptr;
353 }
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000354 }
355
David Chisnall07f8d3e2012-02-17 17:31:15 +0000356 // Solaris requires different flags for .eh_frame to seemingly every other
357 // platform.
David Chisnallbbec8722012-04-10 11:44:33 +0000358 EHSectionType = ELF::SHT_PROGBITS;
David Chisnall07f8d3e2012-02-17 17:31:15 +0000359 EHSectionFlags = ELF::SHF_ALLOC;
David Chisnallbbec8722012-04-10 11:44:33 +0000360 if (T.getOS() == Triple::Solaris) {
361 if (T.getArch() == Triple::x86_64)
362 EHSectionType = ELF::SHT_X86_64_UNWIND;
363 else
364 EHSectionFlags |= ELF::SHF_WRITE;
365 }
David Chisnall07f8d3e2012-02-17 17:31:15 +0000366
367
Evan Cheng76792992011-07-20 05:58:47 +0000368 // ELF
369 BSSSection =
370 Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
Anton Korobeynikov7722a2d2012-01-25 22:24:19 +0000371 ELF::SHF_WRITE | ELF::SHF_ALLOC,
Evan Cheng76792992011-07-20 05:58:47 +0000372 SectionKind::getBSS());
373
374 TextSection =
375 Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
376 ELF::SHF_EXECINSTR |
377 ELF::SHF_ALLOC,
378 SectionKind::getText());
379
380 DataSection =
381 Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
382 ELF::SHF_WRITE |ELF::SHF_ALLOC,
383 SectionKind::getDataRel());
384
385 ReadOnlySection =
386 Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS,
387 ELF::SHF_ALLOC,
388 SectionKind::getReadOnly());
389
390 TLSDataSection =
391 Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
392 ELF::SHF_ALLOC | ELF::SHF_TLS |
393 ELF::SHF_WRITE,
394 SectionKind::getThreadData());
395
396 TLSBSSSection =
397 Ctx->getELFSection(".tbss", ELF::SHT_NOBITS,
398 ELF::SHF_ALLOC | ELF::SHF_TLS |
399 ELF::SHF_WRITE,
400 SectionKind::getThreadBSS());
401
402 DataRelSection =
403 Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS,
404 ELF::SHF_ALLOC |ELF::SHF_WRITE,
405 SectionKind::getDataRel());
406
407 DataRelLocalSection =
408 Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS,
409 ELF::SHF_ALLOC |ELF::SHF_WRITE,
410 SectionKind::getDataRelLocal());
411
412 DataRelROSection =
413 Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
414 ELF::SHF_ALLOC |ELF::SHF_WRITE,
415 SectionKind::getReadOnlyWithRel());
416
417 DataRelROLocalSection =
418 Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS,
419 ELF::SHF_ALLOC |ELF::SHF_WRITE,
420 SectionKind::getReadOnlyWithRelLocal());
421
422 MergeableConst4Section =
423 Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
424 ELF::SHF_ALLOC |ELF::SHF_MERGE,
425 SectionKind::getMergeableConst4());
426
427 MergeableConst8Section =
428 Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
429 ELF::SHF_ALLOC |ELF::SHF_MERGE,
430 SectionKind::getMergeableConst8());
431
432 MergeableConst16Section =
433 Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
434 ELF::SHF_ALLOC |ELF::SHF_MERGE,
435 SectionKind::getMergeableConst16());
436
437 StaticCtorSection =
438 Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS,
439 ELF::SHF_ALLOC |ELF::SHF_WRITE,
440 SectionKind::getDataRel());
441
442 StaticDtorSection =
443 Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS,
444 ELF::SHF_ALLOC |ELF::SHF_WRITE,
445 SectionKind::getDataRel());
446
447 // Exception Handling Sections.
448
449 // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
450 // it contains relocatable pointers. In PIC mode, this is probably a big
451 // runtime hit for C++ apps. Either the contents of the LSDA need to be
452 // adjusted or this should be a data section.
453 LSDASection =
454 Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
455 ELF::SHF_ALLOC,
456 SectionKind::getReadOnly());
457
Timur Iskhodzhanovf166f6c2014-01-30 01:39:17 +0000458 COFFDebugSymbolsSection = 0;
459
Evan Cheng76792992011-07-20 05:58:47 +0000460 // Debug Info Sections.
461 DwarfAbbrevSection =
462 Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0,
463 SectionKind::getMetadata());
464 DwarfInfoSection =
465 Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0,
466 SectionKind::getMetadata());
467 DwarfLineSection =
468 Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0,
469 SectionKind::getMetadata());
470 DwarfFrameSection =
471 Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0,
472 SectionKind::getMetadata());
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000473 DwarfPubNamesSection =
474 Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0,
475 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000476 DwarfPubTypesSection =
477 Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0,
478 SectionKind::getMetadata());
Eric Christopherb0e76942013-09-09 20:03:14 +0000479 DwarfGnuPubNamesSection =
480 Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0,
481 SectionKind::getMetadata());
482 DwarfGnuPubTypesSection =
483 Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0,
484 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000485 DwarfStrSection =
Nick Lewycky1a62d782011-10-26 18:44:32 +0000486 Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS,
487 ELF::SHF_MERGE | ELF::SHF_STRINGS,
488 SectionKind::getMergeable1ByteCString());
Evan Cheng76792992011-07-20 05:58:47 +0000489 DwarfLocSection =
490 Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0,
491 SectionKind::getMetadata());
492 DwarfARangesSection =
493 Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0,
494 SectionKind::getMetadata());
495 DwarfRangesSection =
496 Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0,
497 SectionKind::getMetadata());
498 DwarfMacroInfoSection =
499 Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0,
500 SectionKind::getMetadata());
Eric Christopher27ed8ec2012-11-28 02:49:34 +0000501
502 // DWARF5 Experimental Debug Info
503
504 // Accelerator Tables
Eric Christophera0ad67d2012-10-08 21:41:30 +0000505 DwarfAccelNamesSection =
506 Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0,
507 SectionKind::getMetadata());
508 DwarfAccelObjCSection =
509 Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0,
510 SectionKind::getMetadata());
511 DwarfAccelNamespaceSection =
512 Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0,
513 SectionKind::getMetadata());
514 DwarfAccelTypesSection =
515 Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0,
516 SectionKind::getMetadata());
Eric Christopherc3b434b2012-11-28 02:49:38 +0000517
518 // Fission Sections
519 DwarfInfoDWOSection =
520 Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0,
521 SectionKind::getMetadata());
Eric Christopher3c230092012-11-30 06:47:06 +0000522 DwarfAbbrevDWOSection =
523 Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0,
524 SectionKind::getMetadata());
525 DwarfStrDWOSection =
526 Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS,
527 ELF::SHF_MERGE | ELF::SHF_STRINGS,
528 SectionKind::getMergeable1ByteCString());
529 DwarfLineDWOSection =
530 Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0,
531 SectionKind::getMetadata());
532 DwarfLocDWOSection =
533 Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0,
534 SectionKind::getMetadata());
Eric Christopherc0fa8672013-01-04 17:59:22 +0000535 DwarfStrOffDWOSection =
536 Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0,
537 SectionKind::getMetadata());
Eric Christopher962c9082013-01-15 23:56:56 +0000538 DwarfAddrSection =
539 Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0,
540 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000541}
542
543
544void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
545 // COFF
David Majnemer3d96acb2013-08-13 01:23:53 +0000546 BSSSection =
547 Ctx->getCOFFSection(".bss",
548 COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
549 COFF::IMAGE_SCN_MEM_READ |
550 COFF::IMAGE_SCN_MEM_WRITE,
551 SectionKind::getBSS());
Evan Cheng76792992011-07-20 05:58:47 +0000552 TextSection =
553 Ctx->getCOFFSection(".text",
554 COFF::IMAGE_SCN_CNT_CODE |
555 COFF::IMAGE_SCN_MEM_EXECUTE |
556 COFF::IMAGE_SCN_MEM_READ,
557 SectionKind::getText());
558 DataSection =
559 Ctx->getCOFFSection(".data",
560 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
561 COFF::IMAGE_SCN_MEM_READ |
562 COFF::IMAGE_SCN_MEM_WRITE,
563 SectionKind::getDataRel());
564 ReadOnlySection =
565 Ctx->getCOFFSection(".rdata",
566 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
567 COFF::IMAGE_SCN_MEM_READ,
568 SectionKind::getReadOnly());
Saleem Abdulrasooledbdd2e2014-03-27 22:50:05 +0000569 if (T.isKnownWindowsMSVCEnvironment()) {
Michael J. Spencerb560d072012-02-23 21:56:08 +0000570 StaticCtorSection =
571 Ctx->getCOFFSection(".CRT$XCU",
572 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
573 COFF::IMAGE_SCN_MEM_READ,
574 SectionKind::getReadOnly());
575 } else {
576 StaticCtorSection =
577 Ctx->getCOFFSection(".ctors",
578 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
579 COFF::IMAGE_SCN_MEM_READ |
580 COFF::IMAGE_SCN_MEM_WRITE,
581 SectionKind::getDataRel());
582 }
583
584
Saleem Abdulrasooledbdd2e2014-03-27 22:50:05 +0000585 if (T.isKnownWindowsMSVCEnvironment()) {
Anton Korobeynikov37d73002012-09-23 15:53:47 +0000586 StaticDtorSection =
587 Ctx->getCOFFSection(".CRT$XTX",
588 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
589 COFF::IMAGE_SCN_MEM_READ,
590 SectionKind::getReadOnly());
591 } else {
592 StaticDtorSection =
593 Ctx->getCOFFSection(".dtors",
594 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
595 COFF::IMAGE_SCN_MEM_READ |
596 COFF::IMAGE_SCN_MEM_WRITE,
597 SectionKind::getDataRel());
598 }
Evan Cheng76792992011-07-20 05:58:47 +0000599
600 // FIXME: We're emitting LSDA info into a readonly section on COFF, even
601 // though it contains relocatable pointers. In PIC mode, this is probably a
602 // big runtime hit for C++ apps. Either the contents of the LSDA need to be
603 // adjusted or this should be a data section.
Kai Nacke42097302013-07-08 04:43:23 +0000604 LSDASection =
605 Ctx->getCOFFSection(".gcc_except_table",
606 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
607 COFF::IMAGE_SCN_MEM_READ,
608 SectionKind::getReadOnly());
Evan Cheng76792992011-07-20 05:58:47 +0000609
610 // Debug info.
Timur Iskhodzhanov31377c52014-01-28 03:48:44 +0000611 COFFDebugSymbolsSection =
612 Ctx->getCOFFSection(".debug$S",
613 COFF::IMAGE_SCN_MEM_DISCARDABLE |
614 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
615 COFF::IMAGE_SCN_MEM_READ,
616 SectionKind::getMetadata());
617
Evan Cheng76792992011-07-20 05:58:47 +0000618 DwarfAbbrevSection =
619 Ctx->getCOFFSection(".debug_abbrev",
620 COFF::IMAGE_SCN_MEM_DISCARDABLE |
621 COFF::IMAGE_SCN_MEM_READ,
622 SectionKind::getMetadata());
623 DwarfInfoSection =
624 Ctx->getCOFFSection(".debug_info",
625 COFF::IMAGE_SCN_MEM_DISCARDABLE |
626 COFF::IMAGE_SCN_MEM_READ,
627 SectionKind::getMetadata());
628 DwarfLineSection =
629 Ctx->getCOFFSection(".debug_line",
630 COFF::IMAGE_SCN_MEM_DISCARDABLE |
631 COFF::IMAGE_SCN_MEM_READ,
632 SectionKind::getMetadata());
633 DwarfFrameSection =
634 Ctx->getCOFFSection(".debug_frame",
635 COFF::IMAGE_SCN_MEM_DISCARDABLE |
636 COFF::IMAGE_SCN_MEM_READ,
637 SectionKind::getMetadata());
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000638 DwarfPubNamesSection =
639 Ctx->getCOFFSection(".debug_pubnames",
640 COFF::IMAGE_SCN_MEM_DISCARDABLE |
641 COFF::IMAGE_SCN_MEM_READ,
642 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000643 DwarfPubTypesSection =
644 Ctx->getCOFFSection(".debug_pubtypes",
645 COFF::IMAGE_SCN_MEM_DISCARDABLE |
646 COFF::IMAGE_SCN_MEM_READ,
647 SectionKind::getMetadata());
NAKAMURA Takumi0229e352013-09-10 06:01:56 +0000648 DwarfGnuPubNamesSection =
Eric Christopherb0e76942013-09-09 20:03:14 +0000649 Ctx->getCOFFSection(".debug_gnu_pubnames",
650 COFF::IMAGE_SCN_MEM_DISCARDABLE |
651 COFF::IMAGE_SCN_MEM_READ,
652 SectionKind::getMetadata());
NAKAMURA Takumi0229e352013-09-10 06:01:56 +0000653 DwarfGnuPubTypesSection =
Eric Christopherb0e76942013-09-09 20:03:14 +0000654 Ctx->getCOFFSection(".debug_gnu_pubtypes",
655 COFF::IMAGE_SCN_MEM_DISCARDABLE |
656 COFF::IMAGE_SCN_MEM_READ,
657 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000658 DwarfStrSection =
659 Ctx->getCOFFSection(".debug_str",
660 COFF::IMAGE_SCN_MEM_DISCARDABLE |
661 COFF::IMAGE_SCN_MEM_READ,
662 SectionKind::getMetadata());
663 DwarfLocSection =
664 Ctx->getCOFFSection(".debug_loc",
665 COFF::IMAGE_SCN_MEM_DISCARDABLE |
666 COFF::IMAGE_SCN_MEM_READ,
667 SectionKind::getMetadata());
668 DwarfARangesSection =
669 Ctx->getCOFFSection(".debug_aranges",
670 COFF::IMAGE_SCN_MEM_DISCARDABLE |
671 COFF::IMAGE_SCN_MEM_READ,
672 SectionKind::getMetadata());
673 DwarfRangesSection =
674 Ctx->getCOFFSection(".debug_ranges",
675 COFF::IMAGE_SCN_MEM_DISCARDABLE |
676 COFF::IMAGE_SCN_MEM_READ,
677 SectionKind::getMetadata());
678 DwarfMacroInfoSection =
679 Ctx->getCOFFSection(".debug_macinfo",
680 COFF::IMAGE_SCN_MEM_DISCARDABLE |
681 COFF::IMAGE_SCN_MEM_READ,
682 SectionKind::getMetadata());
David Blaikie62dd7df2014-03-26 03:05:10 +0000683 DwarfInfoDWOSection =
684 Ctx->getCOFFSection(".debug_info.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
685 COFF::IMAGE_SCN_MEM_READ,
686 SectionKind::getMetadata());
687 DwarfAbbrevDWOSection =
688 Ctx->getCOFFSection(".debug_abbrev.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
689 COFF::IMAGE_SCN_MEM_READ,
690 SectionKind::getMetadata());
691 DwarfStrDWOSection =
692 Ctx->getCOFFSection(".debug_str.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
693 COFF::IMAGE_SCN_MEM_READ,
694 SectionKind::getMetadata());
695 DwarfLineDWOSection =
696 Ctx->getCOFFSection(".debug_line.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
697 COFF::IMAGE_SCN_MEM_READ,
698 SectionKind::getMetadata());
699 DwarfLocDWOSection =
700 Ctx->getCOFFSection(".debug_loc.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
701 COFF::IMAGE_SCN_MEM_READ,
702 SectionKind::getMetadata());
703 DwarfStrOffDWOSection =
704 Ctx->getCOFFSection(".debug_str_offsets.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
705 COFF::IMAGE_SCN_MEM_READ,
706 SectionKind::getMetadata());
707 DwarfAddrSection = Ctx->getCOFFSection(
708 ".debug_addr", COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_MEM_READ,
709 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000710
711 DrectveSection =
712 Ctx->getCOFFSection(".drectve",
713 COFF::IMAGE_SCN_LNK_INFO,
714 SectionKind::getMetadata());
715
716 PDataSection =
717 Ctx->getCOFFSection(".pdata",
718 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
Anton Korobeynikovcc8c5392012-08-08 12:46:46 +0000719 COFF::IMAGE_SCN_MEM_READ,
Evan Cheng76792992011-07-20 05:58:47 +0000720 SectionKind::getDataRel());
721
722 XDataSection =
723 Ctx->getCOFFSection(".xdata",
724 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
Anton Korobeynikovcc8c5392012-08-08 12:46:46 +0000725 COFF::IMAGE_SCN_MEM_READ,
Evan Cheng76792992011-07-20 05:58:47 +0000726 SectionKind::getDataRel());
Anton Korobeynikovc6b40172012-02-11 17:26:53 +0000727 TLSDataSection =
728 Ctx->getCOFFSection(".tls$",
729 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
730 COFF::IMAGE_SCN_MEM_READ |
731 COFF::IMAGE_SCN_MEM_WRITE,
732 SectionKind::getDataRel());
Evan Cheng76792992011-07-20 05:58:47 +0000733}
734
735void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000736 CodeModel::Model cm,
Evan Cheng76792992011-07-20 05:58:47 +0000737 MCContext &ctx) {
738 RelocM = relocm;
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000739 CMModel = cm;
Evan Cheng76792992011-07-20 05:58:47 +0000740 Ctx = &ctx;
741
742 // Common.
743 CommDirectiveSupportsAlignment = true;
744 SupportsWeakOmittedEHFrame = true;
745 IsFunctionEHFrameSymbolPrivate = true;
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000746
747 PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding =
748 TTypeEncoding = dwarf::DW_EH_PE_absptr;
749
Bill Wendling2d1df6b2013-04-10 21:42:06 +0000750 CompactUnwindDwarfEHFrameOnly = 0;
751
Eric Christopher4996c702011-11-07 09:24:32 +0000752 EHFrameSection = 0; // Created on demand.
753 CompactUnwindSection = 0; // Used only by selected targets.
754 DwarfAccelNamesSection = 0; // Used only by selected targets.
755 DwarfAccelObjCSection = 0; // Used only by selected targets.
756 DwarfAccelNamespaceSection = 0; // Used only by selected targets.
757 DwarfAccelTypesSection = 0; // Used only by selected targets.
Evan Cheng76792992011-07-20 05:58:47 +0000758
759 Triple T(TT);
760 Triple::ArchType Arch = T.getArch();
761 // FIXME: Checking for Arch here to filter out bogus triples such as
762 // cellspu-apple-darwin. Perhaps we should fix in Triple?
763 if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
764 Arch == Triple::arm || Arch == Triple::thumb ||
765 Arch == Triple::ppc || Arch == Triple::ppc64 ||
766 Arch == Triple::UnknownArch) &&
Saleem Abdulrasool35476332014-03-06 20:47:11 +0000767 (T.isOSDarwin() || T.isOSBinFormatMachO())) {
Evan Cheng76792992011-07-20 05:58:47 +0000768 Env = IsMachO;
769 InitMachOMCObjectFileInfo(T);
Saleem Abdulrasool5715e522014-03-06 23:02:15 +0000770 } else if ((Arch == Triple::x86 || Arch == Triple::x86_64) &&
771 T.getObjectFormat() != Triple::ELF && T.isOSWindows()) {
Evan Cheng76792992011-07-20 05:58:47 +0000772 Env = IsCOFF;
773 InitCOFFMCObjectFileInfo(T);
774 } else {
775 Env = IsELF;
776 InitELFMCObjectFileInfo(T);
777 }
778}
779
David Blaikiebc563272013-12-13 21:33:40 +0000780const MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
781 return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
782 SectionKind::getMetadata(), 0, utostr(Hash));
783}
784
785const MCSection *
786MCObjectFileInfo::getDwarfTypesDWOSection(uint64_t Hash) const {
David Blaikie15ed5eb2014-01-10 01:38:41 +0000787 return Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS,
788 ELF::SHF_GROUP, SectionKind::getMetadata(), 0,
789 utostr(Hash));
David Blaikiebc563272013-12-13 21:33:40 +0000790}
791
David Chisnall85dd3092012-02-17 16:51:02 +0000792void MCObjectFileInfo::InitEHFrameSection() {
793 if (Env == IsMachO)
794 EHFrameSection =
795 Ctx->getMachOSection("__TEXT", "__eh_frame",
David Majnemer7b583052014-03-07 07:36:05 +0000796 MachO::S_COALESCED |
797 MachO::S_ATTR_NO_TOC |
798 MachO::S_ATTR_STRIP_STATIC_SYMS |
799 MachO::S_ATTR_LIVE_SUPPORT,
David Chisnall85dd3092012-02-17 16:51:02 +0000800 SectionKind::getReadOnly());
801 else if (Env == IsELF)
802 EHFrameSection =
David Chisnallbbec8722012-04-10 11:44:33 +0000803 Ctx->getELFSection(".eh_frame", EHSectionType,
David Chisnall07f8d3e2012-02-17 17:31:15 +0000804 EHSectionFlags,
David Chisnall85dd3092012-02-17 16:51:02 +0000805 SectionKind::getDataRel());
806 else
807 EHFrameSection =
808 Ctx->getCOFFSection(".eh_frame",
809 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
810 COFF::IMAGE_SCN_MEM_READ |
811 COFF::IMAGE_SCN_MEM_WRITE,
812 SectionKind::getDataRel());
813}