blob: ff1f58494376ce7719a2586e4fda4597f1886a1d [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 }
Tim Northovere0e3aef2013-01-31 12:12:40 +0000286 } else if (T.getArch() == Triple::aarch64) {
Tim Northovere0e3aef2013-01-31 12:12:40 +0000287 // The small model guarantees static code/data size < 4GB, but not where it
288 // will be in memory. Most of these could end up >2GB away so even a signed
289 // pc-relative 32-bit address is insufficient, theoretically.
290 if (RelocM == Reloc::PIC_) {
291 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
292 dwarf::DW_EH_PE_sdata8;
293 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8;
294 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
295 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
296 dwarf::DW_EH_PE_sdata8;
297 } else {
298 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
299 LSDAEncoding = dwarf::DW_EH_PE_absptr;
300 FDEEncoding = dwarf::DW_EH_PE_udata4;
301 TTypeEncoding = dwarf::DW_EH_PE_absptr;
302 }
Bill Schmidt0a9170d2013-07-26 01:35:43 +0000303 } else if (T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le) {
Adhemerval Zanella1ae22482013-01-09 17:08:15 +0000304 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
305 dwarf::DW_EH_PE_udata8;
Adhemerval Zanella1ae22482013-01-09 17:08:15 +0000306 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
307 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
308 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
309 dwarf::DW_EH_PE_udata8;
Jakob Stoklund Olesen83c67732014-01-28 02:52:26 +0000310 } else if (T.getArch() == Triple::sparc) {
311 if (RelocM == Reloc::PIC_) {
312 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
313 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
314 dwarf::DW_EH_PE_sdata4;
315 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
316 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
317 dwarf::DW_EH_PE_sdata4;
318 } else {
319 LSDAEncoding = dwarf::DW_EH_PE_absptr;
320 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
321 FDEEncoding = dwarf::DW_EH_PE_udata4;
322 TTypeEncoding = dwarf::DW_EH_PE_absptr;
323 }
324 } else if (T.getArch() == Triple::sparcv9) {
325 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
326 if (RelocM == Reloc::PIC_) {
327 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
328 dwarf::DW_EH_PE_sdata4;
329 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
330 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
331 dwarf::DW_EH_PE_sdata4;
332 } else {
333 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
334 FDEEncoding = dwarf::DW_EH_PE_udata4;
335 TTypeEncoding = dwarf::DW_EH_PE_absptr;
336 }
Ulrich Weigand0213e7f2013-05-06 16:11:12 +0000337 } else if (T.getArch() == Triple::systemz) {
338 // All currently-defined code models guarantee that 4-byte PC-relative
339 // values will be in range.
Ulrich Weigande7c6dfe2013-05-06 17:28:30 +0000340 if (RelocM == Reloc::PIC_) {
341 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
342 dwarf::DW_EH_PE_sdata4;
343 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
344 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
345 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
346 dwarf::DW_EH_PE_sdata4;
347 } else {
348 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
349 LSDAEncoding = dwarf::DW_EH_PE_absptr;
350 FDEEncoding = dwarf::DW_EH_PE_absptr;
351 TTypeEncoding = dwarf::DW_EH_PE_absptr;
352 }
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000353 }
354
David Chisnall07f8d3e2012-02-17 17:31:15 +0000355 // Solaris requires different flags for .eh_frame to seemingly every other
356 // platform.
David Chisnallbbec8722012-04-10 11:44:33 +0000357 EHSectionType = ELF::SHT_PROGBITS;
David Chisnall07f8d3e2012-02-17 17:31:15 +0000358 EHSectionFlags = ELF::SHF_ALLOC;
David Chisnallbbec8722012-04-10 11:44:33 +0000359 if (T.getOS() == Triple::Solaris) {
360 if (T.getArch() == Triple::x86_64)
361 EHSectionType = ELF::SHT_X86_64_UNWIND;
362 else
363 EHSectionFlags |= ELF::SHF_WRITE;
364 }
David Chisnall07f8d3e2012-02-17 17:31:15 +0000365
366
Evan Cheng76792992011-07-20 05:58:47 +0000367 // ELF
368 BSSSection =
369 Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
Anton Korobeynikov7722a2d2012-01-25 22:24:19 +0000370 ELF::SHF_WRITE | ELF::SHF_ALLOC,
Evan Cheng76792992011-07-20 05:58:47 +0000371 SectionKind::getBSS());
372
373 TextSection =
374 Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
375 ELF::SHF_EXECINSTR |
376 ELF::SHF_ALLOC,
377 SectionKind::getText());
378
379 DataSection =
380 Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
381 ELF::SHF_WRITE |ELF::SHF_ALLOC,
382 SectionKind::getDataRel());
383
384 ReadOnlySection =
385 Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS,
386 ELF::SHF_ALLOC,
387 SectionKind::getReadOnly());
388
389 TLSDataSection =
390 Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
391 ELF::SHF_ALLOC | ELF::SHF_TLS |
392 ELF::SHF_WRITE,
393 SectionKind::getThreadData());
394
395 TLSBSSSection =
396 Ctx->getELFSection(".tbss", ELF::SHT_NOBITS,
397 ELF::SHF_ALLOC | ELF::SHF_TLS |
398 ELF::SHF_WRITE,
399 SectionKind::getThreadBSS());
400
401 DataRelSection =
402 Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS,
403 ELF::SHF_ALLOC |ELF::SHF_WRITE,
404 SectionKind::getDataRel());
405
406 DataRelLocalSection =
407 Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS,
408 ELF::SHF_ALLOC |ELF::SHF_WRITE,
409 SectionKind::getDataRelLocal());
410
411 DataRelROSection =
412 Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
413 ELF::SHF_ALLOC |ELF::SHF_WRITE,
414 SectionKind::getReadOnlyWithRel());
415
416 DataRelROLocalSection =
417 Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS,
418 ELF::SHF_ALLOC |ELF::SHF_WRITE,
419 SectionKind::getReadOnlyWithRelLocal());
420
421 MergeableConst4Section =
422 Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
423 ELF::SHF_ALLOC |ELF::SHF_MERGE,
424 SectionKind::getMergeableConst4());
425
426 MergeableConst8Section =
427 Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
428 ELF::SHF_ALLOC |ELF::SHF_MERGE,
429 SectionKind::getMergeableConst8());
430
431 MergeableConst16Section =
432 Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
433 ELF::SHF_ALLOC |ELF::SHF_MERGE,
434 SectionKind::getMergeableConst16());
435
436 StaticCtorSection =
437 Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS,
438 ELF::SHF_ALLOC |ELF::SHF_WRITE,
439 SectionKind::getDataRel());
440
441 StaticDtorSection =
442 Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS,
443 ELF::SHF_ALLOC |ELF::SHF_WRITE,
444 SectionKind::getDataRel());
445
446 // Exception Handling Sections.
447
448 // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
449 // it contains relocatable pointers. In PIC mode, this is probably a big
450 // runtime hit for C++ apps. Either the contents of the LSDA need to be
451 // adjusted or this should be a data section.
452 LSDASection =
453 Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
454 ELF::SHF_ALLOC,
455 SectionKind::getReadOnly());
456
Timur Iskhodzhanovf166f6c2014-01-30 01:39:17 +0000457 COFFDebugSymbolsSection = 0;
458
Evan Cheng76792992011-07-20 05:58:47 +0000459 // Debug Info Sections.
460 DwarfAbbrevSection =
461 Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0,
462 SectionKind::getMetadata());
463 DwarfInfoSection =
464 Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0,
465 SectionKind::getMetadata());
466 DwarfLineSection =
467 Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0,
468 SectionKind::getMetadata());
469 DwarfFrameSection =
470 Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0,
471 SectionKind::getMetadata());
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000472 DwarfPubNamesSection =
473 Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0,
474 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000475 DwarfPubTypesSection =
476 Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0,
477 SectionKind::getMetadata());
Eric Christopherb0e76942013-09-09 20:03:14 +0000478 DwarfGnuPubNamesSection =
479 Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0,
480 SectionKind::getMetadata());
481 DwarfGnuPubTypesSection =
482 Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0,
483 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000484 DwarfStrSection =
Nick Lewycky1a62d782011-10-26 18:44:32 +0000485 Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS,
486 ELF::SHF_MERGE | ELF::SHF_STRINGS,
487 SectionKind::getMergeable1ByteCString());
Evan Cheng76792992011-07-20 05:58:47 +0000488 DwarfLocSection =
489 Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0,
490 SectionKind::getMetadata());
491 DwarfARangesSection =
492 Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0,
493 SectionKind::getMetadata());
494 DwarfRangesSection =
495 Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0,
496 SectionKind::getMetadata());
497 DwarfMacroInfoSection =
498 Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0,
499 SectionKind::getMetadata());
Eric Christopher27ed8ec2012-11-28 02:49:34 +0000500
501 // DWARF5 Experimental Debug Info
502
503 // Accelerator Tables
Eric Christophera0ad67d2012-10-08 21:41:30 +0000504 DwarfAccelNamesSection =
505 Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0,
506 SectionKind::getMetadata());
507 DwarfAccelObjCSection =
508 Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0,
509 SectionKind::getMetadata());
510 DwarfAccelNamespaceSection =
511 Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0,
512 SectionKind::getMetadata());
513 DwarfAccelTypesSection =
514 Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0,
515 SectionKind::getMetadata());
Eric Christopherc3b434b2012-11-28 02:49:38 +0000516
517 // Fission Sections
518 DwarfInfoDWOSection =
519 Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0,
520 SectionKind::getMetadata());
Eric Christopher3c230092012-11-30 06:47:06 +0000521 DwarfAbbrevDWOSection =
522 Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0,
523 SectionKind::getMetadata());
524 DwarfStrDWOSection =
525 Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS,
526 ELF::SHF_MERGE | ELF::SHF_STRINGS,
527 SectionKind::getMergeable1ByteCString());
528 DwarfLineDWOSection =
529 Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0,
530 SectionKind::getMetadata());
531 DwarfLocDWOSection =
532 Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0,
533 SectionKind::getMetadata());
Eric Christopherc0fa8672013-01-04 17:59:22 +0000534 DwarfStrOffDWOSection =
535 Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0,
536 SectionKind::getMetadata());
Eric Christopher962c9082013-01-15 23:56:56 +0000537 DwarfAddrSection =
538 Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0,
539 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000540}
541
542
543void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
544 // COFF
David Majnemer3d96acb2013-08-13 01:23:53 +0000545 BSSSection =
546 Ctx->getCOFFSection(".bss",
547 COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
548 COFF::IMAGE_SCN_MEM_READ |
549 COFF::IMAGE_SCN_MEM_WRITE,
550 SectionKind::getBSS());
Evan Cheng76792992011-07-20 05:58:47 +0000551 TextSection =
552 Ctx->getCOFFSection(".text",
553 COFF::IMAGE_SCN_CNT_CODE |
554 COFF::IMAGE_SCN_MEM_EXECUTE |
555 COFF::IMAGE_SCN_MEM_READ,
556 SectionKind::getText());
557 DataSection =
558 Ctx->getCOFFSection(".data",
559 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
560 COFF::IMAGE_SCN_MEM_READ |
561 COFF::IMAGE_SCN_MEM_WRITE,
562 SectionKind::getDataRel());
563 ReadOnlySection =
564 Ctx->getCOFFSection(".rdata",
565 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
566 COFF::IMAGE_SCN_MEM_READ,
567 SectionKind::getReadOnly());
Michael J. Spencerb560d072012-02-23 21:56:08 +0000568 if (T.getOS() == Triple::Win32) {
569 StaticCtorSection =
570 Ctx->getCOFFSection(".CRT$XCU",
571 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
572 COFF::IMAGE_SCN_MEM_READ,
573 SectionKind::getReadOnly());
574 } else {
575 StaticCtorSection =
576 Ctx->getCOFFSection(".ctors",
577 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
578 COFF::IMAGE_SCN_MEM_READ |
579 COFF::IMAGE_SCN_MEM_WRITE,
580 SectionKind::getDataRel());
581 }
582
583
Anton Korobeynikov37d73002012-09-23 15:53:47 +0000584 if (T.getOS() == Triple::Win32) {
585 StaticDtorSection =
586 Ctx->getCOFFSection(".CRT$XTX",
587 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
588 COFF::IMAGE_SCN_MEM_READ,
589 SectionKind::getReadOnly());
590 } else {
591 StaticDtorSection =
592 Ctx->getCOFFSection(".dtors",
593 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
594 COFF::IMAGE_SCN_MEM_READ |
595 COFF::IMAGE_SCN_MEM_WRITE,
596 SectionKind::getDataRel());
597 }
Evan Cheng76792992011-07-20 05:58:47 +0000598
599 // FIXME: We're emitting LSDA info into a readonly section on COFF, even
600 // though it contains relocatable pointers. In PIC mode, this is probably a
601 // big runtime hit for C++ apps. Either the contents of the LSDA need to be
602 // adjusted or this should be a data section.
Kai Nacke42097302013-07-08 04:43:23 +0000603 LSDASection =
604 Ctx->getCOFFSection(".gcc_except_table",
605 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
606 COFF::IMAGE_SCN_MEM_READ,
607 SectionKind::getReadOnly());
Evan Cheng76792992011-07-20 05:58:47 +0000608
609 // Debug info.
Timur Iskhodzhanov31377c52014-01-28 03:48:44 +0000610 COFFDebugSymbolsSection =
611 Ctx->getCOFFSection(".debug$S",
612 COFF::IMAGE_SCN_MEM_DISCARDABLE |
613 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
614 COFF::IMAGE_SCN_MEM_READ,
615 SectionKind::getMetadata());
616
Evan Cheng76792992011-07-20 05:58:47 +0000617 DwarfAbbrevSection =
618 Ctx->getCOFFSection(".debug_abbrev",
619 COFF::IMAGE_SCN_MEM_DISCARDABLE |
620 COFF::IMAGE_SCN_MEM_READ,
621 SectionKind::getMetadata());
622 DwarfInfoSection =
623 Ctx->getCOFFSection(".debug_info",
624 COFF::IMAGE_SCN_MEM_DISCARDABLE |
625 COFF::IMAGE_SCN_MEM_READ,
626 SectionKind::getMetadata());
627 DwarfLineSection =
628 Ctx->getCOFFSection(".debug_line",
629 COFF::IMAGE_SCN_MEM_DISCARDABLE |
630 COFF::IMAGE_SCN_MEM_READ,
631 SectionKind::getMetadata());
632 DwarfFrameSection =
633 Ctx->getCOFFSection(".debug_frame",
634 COFF::IMAGE_SCN_MEM_DISCARDABLE |
635 COFF::IMAGE_SCN_MEM_READ,
636 SectionKind::getMetadata());
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000637 DwarfPubNamesSection =
638 Ctx->getCOFFSection(".debug_pubnames",
639 COFF::IMAGE_SCN_MEM_DISCARDABLE |
640 COFF::IMAGE_SCN_MEM_READ,
641 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000642 DwarfPubTypesSection =
643 Ctx->getCOFFSection(".debug_pubtypes",
644 COFF::IMAGE_SCN_MEM_DISCARDABLE |
645 COFF::IMAGE_SCN_MEM_READ,
646 SectionKind::getMetadata());
NAKAMURA Takumi0229e352013-09-10 06:01:56 +0000647 DwarfGnuPubNamesSection =
Eric Christopherb0e76942013-09-09 20:03:14 +0000648 Ctx->getCOFFSection(".debug_gnu_pubnames",
649 COFF::IMAGE_SCN_MEM_DISCARDABLE |
650 COFF::IMAGE_SCN_MEM_READ,
651 SectionKind::getMetadata());
NAKAMURA Takumi0229e352013-09-10 06:01:56 +0000652 DwarfGnuPubTypesSection =
Eric Christopherb0e76942013-09-09 20:03:14 +0000653 Ctx->getCOFFSection(".debug_gnu_pubtypes",
654 COFF::IMAGE_SCN_MEM_DISCARDABLE |
655 COFF::IMAGE_SCN_MEM_READ,
656 SectionKind::getMetadata());
Evan Cheng76792992011-07-20 05:58:47 +0000657 DwarfStrSection =
658 Ctx->getCOFFSection(".debug_str",
659 COFF::IMAGE_SCN_MEM_DISCARDABLE |
660 COFF::IMAGE_SCN_MEM_READ,
661 SectionKind::getMetadata());
662 DwarfLocSection =
663 Ctx->getCOFFSection(".debug_loc",
664 COFF::IMAGE_SCN_MEM_DISCARDABLE |
665 COFF::IMAGE_SCN_MEM_READ,
666 SectionKind::getMetadata());
667 DwarfARangesSection =
668 Ctx->getCOFFSection(".debug_aranges",
669 COFF::IMAGE_SCN_MEM_DISCARDABLE |
670 COFF::IMAGE_SCN_MEM_READ,
671 SectionKind::getMetadata());
672 DwarfRangesSection =
673 Ctx->getCOFFSection(".debug_ranges",
674 COFF::IMAGE_SCN_MEM_DISCARDABLE |
675 COFF::IMAGE_SCN_MEM_READ,
676 SectionKind::getMetadata());
677 DwarfMacroInfoSection =
678 Ctx->getCOFFSection(".debug_macinfo",
679 COFF::IMAGE_SCN_MEM_DISCARDABLE |
680 COFF::IMAGE_SCN_MEM_READ,
681 SectionKind::getMetadata());
682
683 DrectveSection =
684 Ctx->getCOFFSection(".drectve",
685 COFF::IMAGE_SCN_LNK_INFO,
686 SectionKind::getMetadata());
687
688 PDataSection =
689 Ctx->getCOFFSection(".pdata",
690 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
Anton Korobeynikovcc8c5392012-08-08 12:46:46 +0000691 COFF::IMAGE_SCN_MEM_READ,
Evan Cheng76792992011-07-20 05:58:47 +0000692 SectionKind::getDataRel());
693
694 XDataSection =
695 Ctx->getCOFFSection(".xdata",
696 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
Anton Korobeynikovcc8c5392012-08-08 12:46:46 +0000697 COFF::IMAGE_SCN_MEM_READ,
Evan Cheng76792992011-07-20 05:58:47 +0000698 SectionKind::getDataRel());
Anton Korobeynikovc6b40172012-02-11 17:26:53 +0000699 TLSDataSection =
700 Ctx->getCOFFSection(".tls$",
701 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
702 COFF::IMAGE_SCN_MEM_READ |
703 COFF::IMAGE_SCN_MEM_WRITE,
704 SectionKind::getDataRel());
Evan Cheng76792992011-07-20 05:58:47 +0000705}
706
707void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000708 CodeModel::Model cm,
Evan Cheng76792992011-07-20 05:58:47 +0000709 MCContext &ctx) {
710 RelocM = relocm;
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000711 CMModel = cm;
Evan Cheng76792992011-07-20 05:58:47 +0000712 Ctx = &ctx;
713
714 // Common.
715 CommDirectiveSupportsAlignment = true;
716 SupportsWeakOmittedEHFrame = true;
717 IsFunctionEHFrameSymbolPrivate = true;
Evan Chengbbf3b0d2011-07-20 19:50:42 +0000718
719 PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding =
720 TTypeEncoding = dwarf::DW_EH_PE_absptr;
721
Bill Wendling2d1df6b2013-04-10 21:42:06 +0000722 CompactUnwindDwarfEHFrameOnly = 0;
723
Eric Christopher4996c702011-11-07 09:24:32 +0000724 EHFrameSection = 0; // Created on demand.
725 CompactUnwindSection = 0; // Used only by selected targets.
726 DwarfAccelNamesSection = 0; // Used only by selected targets.
727 DwarfAccelObjCSection = 0; // Used only by selected targets.
728 DwarfAccelNamespaceSection = 0; // Used only by selected targets.
729 DwarfAccelTypesSection = 0; // Used only by selected targets.
Evan Cheng76792992011-07-20 05:58:47 +0000730
731 Triple T(TT);
732 Triple::ArchType Arch = T.getArch();
733 // FIXME: Checking for Arch here to filter out bogus triples such as
734 // cellspu-apple-darwin. Perhaps we should fix in Triple?
735 if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
736 Arch == Triple::arm || Arch == Triple::thumb ||
737 Arch == Triple::ppc || Arch == Triple::ppc64 ||
738 Arch == Triple::UnknownArch) &&
Saleem Abdulrasool35476332014-03-06 20:47:11 +0000739 (T.isOSDarwin() || T.isOSBinFormatMachO())) {
Evan Cheng76792992011-07-20 05:58:47 +0000740 Env = IsMachO;
741 InitMachOMCObjectFileInfo(T);
Saleem Abdulrasool5715e522014-03-06 23:02:15 +0000742 } else if ((Arch == Triple::x86 || Arch == Triple::x86_64) &&
743 T.getObjectFormat() != Triple::ELF && T.isOSWindows()) {
Evan Cheng76792992011-07-20 05:58:47 +0000744 Env = IsCOFF;
745 InitCOFFMCObjectFileInfo(T);
746 } else {
747 Env = IsELF;
748 InitELFMCObjectFileInfo(T);
749 }
750}
751
David Blaikiebc563272013-12-13 21:33:40 +0000752const MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
753 return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
754 SectionKind::getMetadata(), 0, utostr(Hash));
755}
756
757const MCSection *
758MCObjectFileInfo::getDwarfTypesDWOSection(uint64_t Hash) const {
David Blaikie15ed5eb2014-01-10 01:38:41 +0000759 return Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS,
760 ELF::SHF_GROUP, SectionKind::getMetadata(), 0,
761 utostr(Hash));
David Blaikiebc563272013-12-13 21:33:40 +0000762}
763
David Chisnall85dd3092012-02-17 16:51:02 +0000764void MCObjectFileInfo::InitEHFrameSection() {
765 if (Env == IsMachO)
766 EHFrameSection =
767 Ctx->getMachOSection("__TEXT", "__eh_frame",
David Majnemer7b583052014-03-07 07:36:05 +0000768 MachO::S_COALESCED |
769 MachO::S_ATTR_NO_TOC |
770 MachO::S_ATTR_STRIP_STATIC_SYMS |
771 MachO::S_ATTR_LIVE_SUPPORT,
David Chisnall85dd3092012-02-17 16:51:02 +0000772 SectionKind::getReadOnly());
773 else if (Env == IsELF)
774 EHFrameSection =
David Chisnallbbec8722012-04-10 11:44:33 +0000775 Ctx->getELFSection(".eh_frame", EHSectionType,
David Chisnall07f8d3e2012-02-17 17:31:15 +0000776 EHSectionFlags,
David Chisnall85dd3092012-02-17 16:51:02 +0000777 SectionKind::getDataRel());
778 else
779 EHFrameSection =
780 Ctx->getCOFFSection(".eh_frame",
781 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
782 COFF::IMAGE_SCN_MEM_READ |
783 COFF::IMAGE_SCN_MEM_WRITE,
784 SectionKind::getDataRel());
785}