Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 1 | //===-- 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 Blaikie | bc56327 | 2013-12-13 21:33:40 +0000 | [diff] [blame] | 11 | #include "llvm/ADT/StringExtras.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 12 | #include "llvm/ADT/Triple.h" |
Joerg Sonnenberger | 94cbb66 | 2014-05-13 17:58:13 +0000 | [diff] [blame] | 13 | #include "llvm/MC/MCAsmInfo.h" |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCContext.h" |
| 15 | #include "llvm/MC/MCSection.h" |
| 16 | #include "llvm/MC/MCSectionCOFF.h" |
| 17 | #include "llvm/MC/MCSectionELF.h" |
| 18 | #include "llvm/MC/MCSectionMachO.h" |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 19 | using namespace llvm; |
| 20 | |
| 21 | void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) { |
| 22 | // MachO |
| 23 | IsFunctionEHFrameSymbolPrivate = false; |
| 24 | SupportsWeakOmittedEHFrame = false; |
| 25 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 26 | if (T.isOSDarwin() && |
| 27 | (T.getArch() == Triple::arm64 || T.getArch() == Triple::aarch64)) |
Tim Northover | 00ed996 | 2014-03-29 10:18:08 +0000 | [diff] [blame] | 28 | SupportsCompactUnwindWithoutEHFrame = true; |
| 29 | |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 30 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
| 31 | | dwarf::DW_EH_PE_sdata4; |
Rafael Espindola | aa7851d | 2014-05-12 13:47:05 +0000 | [diff] [blame] | 32 | LSDAEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel; |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 33 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 34 | dwarf::DW_EH_PE_sdata4; |
| 35 | |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 36 | // .comm doesn't support alignment before Leopard. |
| 37 | if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5)) |
| 38 | CommDirectiveSupportsAlignment = false; |
| 39 | |
| 40 | TextSection // .text |
| 41 | = Ctx->getMachOSection("__TEXT", "__text", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 42 | MachO::S_ATTR_PURE_INSTRUCTIONS, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 43 | SectionKind::getText()); |
| 44 | DataSection // .data |
| 45 | = Ctx->getMachOSection("__DATA", "__data", 0, |
| 46 | SectionKind::getDataRel()); |
| 47 | |
NAKAMURA Takumi | 68fa6f9 | 2013-09-21 02:34:45 +0000 | [diff] [blame] | 48 | // BSSSection might not be expected initialized on msvc. |
Craig Topper | bb694de | 2014-04-13 04:57:38 +0000 | [diff] [blame] | 49 | BSSSection = nullptr; |
NAKAMURA Takumi | 68fa6f9 | 2013-09-21 02:34:45 +0000 | [diff] [blame] | 50 | |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 51 | TLSDataSection // .tdata |
| 52 | = Ctx->getMachOSection("__DATA", "__thread_data", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 53 | MachO::S_THREAD_LOCAL_REGULAR, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 54 | SectionKind::getDataRel()); |
| 55 | TLSBSSSection // .tbss |
| 56 | = Ctx->getMachOSection("__DATA", "__thread_bss", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 57 | MachO::S_THREAD_LOCAL_ZEROFILL, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 58 | SectionKind::getThreadBSS()); |
| 59 | |
| 60 | // TODO: Verify datarel below. |
| 61 | TLSTLVSection // .tlv |
| 62 | = Ctx->getMachOSection("__DATA", "__thread_vars", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 63 | MachO::S_THREAD_LOCAL_VARIABLES, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 64 | SectionKind::getDataRel()); |
| 65 | |
| 66 | TLSThreadInitSection |
| 67 | = Ctx->getMachOSection("__DATA", "__thread_init", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 68 | MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS, |
Jim Grosbach | 0dde349 | 2011-11-15 16:46:22 +0000 | [diff] [blame] | 69 | SectionKind::getDataRel()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 70 | |
| 71 | CStringSection // .cstring |
| 72 | = Ctx->getMachOSection("__TEXT", "__cstring", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 73 | MachO::S_CSTRING_LITERALS, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 74 | SectionKind::getMergeable1ByteCString()); |
| 75 | UStringSection |
| 76 | = Ctx->getMachOSection("__TEXT","__ustring", 0, |
| 77 | SectionKind::getMergeable2ByteCString()); |
| 78 | FourByteConstantSection // .literal4 |
| 79 | = Ctx->getMachOSection("__TEXT", "__literal4", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 80 | MachO::S_4BYTE_LITERALS, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 81 | SectionKind::getMergeableConst4()); |
| 82 | EightByteConstantSection // .literal8 |
| 83 | = Ctx->getMachOSection("__TEXT", "__literal8", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 84 | MachO::S_8BYTE_LITERALS, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 85 | SectionKind::getMergeableConst8()); |
| 86 | |
Rafael Espindola | 1f3de49 | 2014-02-13 23:16:11 +0000 | [diff] [blame] | 87 | SixteenByteConstantSection // .literal16 |
| 88 | = Ctx->getMachOSection("__TEXT", "__literal16", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 89 | MachO::S_16BYTE_LITERALS, |
Rafael Espindola | 1f3de49 | 2014-02-13 23:16:11 +0000 | [diff] [blame] | 90 | SectionKind::getMergeableConst16()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 91 | |
| 92 | ReadOnlySection // .const |
| 93 | = Ctx->getMachOSection("__TEXT", "__const", 0, |
| 94 | SectionKind::getReadOnly()); |
| 95 | |
| 96 | TextCoalSection |
| 97 | = Ctx->getMachOSection("__TEXT", "__textcoal_nt", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 98 | MachO::S_COALESCED | |
| 99 | MachO::S_ATTR_PURE_INSTRUCTIONS, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 100 | SectionKind::getText()); |
| 101 | ConstTextCoalSection |
| 102 | = Ctx->getMachOSection("__TEXT", "__const_coal", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 103 | MachO::S_COALESCED, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 104 | SectionKind::getReadOnly()); |
| 105 | ConstDataSection // .const_data |
| 106 | = Ctx->getMachOSection("__DATA", "__const", 0, |
| 107 | SectionKind::getReadOnlyWithRel()); |
| 108 | DataCoalSection |
| 109 | = Ctx->getMachOSection("__DATA","__datacoal_nt", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 110 | MachO::S_COALESCED, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 111 | SectionKind::getDataRel()); |
| 112 | DataCommonSection |
| 113 | = Ctx->getMachOSection("__DATA","__common", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 114 | MachO::S_ZEROFILL, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 115 | SectionKind::getBSS()); |
| 116 | DataBSSSection |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 117 | = Ctx->getMachOSection("__DATA","__bss", MachO::S_ZEROFILL, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 118 | SectionKind::getBSS()); |
| 119 | |
| 120 | |
| 121 | LazySymbolPointerSection |
| 122 | = Ctx->getMachOSection("__DATA", "__la_symbol_ptr", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 123 | MachO::S_LAZY_SYMBOL_POINTERS, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 124 | SectionKind::getMetadata()); |
| 125 | NonLazySymbolPointerSection |
| 126 | = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 127 | MachO::S_NON_LAZY_SYMBOL_POINTERS, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 128 | SectionKind::getMetadata()); |
| 129 | |
| 130 | if (RelocM == Reloc::Static) { |
| 131 | StaticCtorSection |
| 132 | = Ctx->getMachOSection("__TEXT", "__constructor", 0, |
| 133 | SectionKind::getDataRel()); |
| 134 | StaticDtorSection |
| 135 | = Ctx->getMachOSection("__TEXT", "__destructor", 0, |
| 136 | SectionKind::getDataRel()); |
| 137 | } else { |
| 138 | StaticCtorSection |
| 139 | = Ctx->getMachOSection("__DATA", "__mod_init_func", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 140 | MachO::S_MOD_INIT_FUNC_POINTERS, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 141 | SectionKind::getDataRel()); |
| 142 | StaticDtorSection |
| 143 | = Ctx->getMachOSection("__DATA", "__mod_term_func", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 144 | MachO::S_MOD_TERM_FUNC_POINTERS, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 145 | SectionKind::getDataRel()); |
| 146 | } |
| 147 | |
| 148 | // Exception Handling. |
| 149 | LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0, |
| 150 | SectionKind::getReadOnlyWithRel()); |
| 151 | |
Craig Topper | bb694de | 2014-04-13 04:57:38 +0000 | [diff] [blame] | 152 | COFFDebugSymbolsSection = nullptr; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 153 | |
Tim Northover | 00ed996 | 2014-03-29 10:18:08 +0000 | [diff] [blame] | 154 | if ((T.isMacOSX() && !T.isMacOSXVersionLT(10, 6)) || |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 155 | (T.isOSDarwin() && |
| 156 | (T.getArch() == Triple::arm64 || T.getArch() == Triple::aarch64))) { |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 157 | CompactUnwindSection = |
| 158 | Ctx->getMachOSection("__LD", "__compact_unwind", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 159 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 160 | SectionKind::getReadOnly()); |
| 161 | |
Bill Wendling | 2d1df6b | 2013-04-10 21:42:06 +0000 | [diff] [blame] | 162 | if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86) |
| 163 | CompactUnwindDwarfEHFrameOnly = 0x04000000; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 164 | else if (T.getArch() == Triple::arm64 || T.getArch() == Triple::aarch64) |
Tim Northover | 00ed996 | 2014-03-29 10:18:08 +0000 | [diff] [blame] | 165 | CompactUnwindDwarfEHFrameOnly = 0x03000000; |
Bill Wendling | 2d1df6b | 2013-04-10 21:42:06 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 168 | // Debug Information. |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 169 | DwarfAccelNamesSection = |
| 170 | Ctx->getMachOSection("__DWARF", "__apple_names", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 171 | MachO::S_ATTR_DEBUG, |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 172 | SectionKind::getMetadata()); |
| 173 | DwarfAccelObjCSection = |
| 174 | Ctx->getMachOSection("__DWARF", "__apple_objc", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 175 | MachO::S_ATTR_DEBUG, |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 176 | SectionKind::getMetadata()); |
| 177 | // 16 character section limit... |
| 178 | DwarfAccelNamespaceSection = |
| 179 | Ctx->getMachOSection("__DWARF", "__apple_namespac", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 180 | MachO::S_ATTR_DEBUG, |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 181 | SectionKind::getMetadata()); |
| 182 | DwarfAccelTypesSection = |
| 183 | Ctx->getMachOSection("__DWARF", "__apple_types", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 184 | MachO::S_ATTR_DEBUG, |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 185 | SectionKind::getMetadata()); |
Jim Grosbach | dc1e36e | 2012-05-11 01:41:30 +0000 | [diff] [blame] | 186 | |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 187 | DwarfAbbrevSection = |
| 188 | Ctx->getMachOSection("__DWARF", "__debug_abbrev", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 189 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 190 | SectionKind::getMetadata()); |
| 191 | DwarfInfoSection = |
| 192 | Ctx->getMachOSection("__DWARF", "__debug_info", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 193 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 194 | SectionKind::getMetadata()); |
| 195 | DwarfLineSection = |
| 196 | Ctx->getMachOSection("__DWARF", "__debug_line", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 197 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 198 | SectionKind::getMetadata()); |
| 199 | DwarfFrameSection = |
| 200 | Ctx->getMachOSection("__DWARF", "__debug_frame", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 201 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 202 | SectionKind::getMetadata()); |
Krzysztof Parzyszek | 228daa6 | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 203 | DwarfPubNamesSection = |
| 204 | Ctx->getMachOSection("__DWARF", "__debug_pubnames", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 205 | MachO::S_ATTR_DEBUG, |
Krzysztof Parzyszek | 228daa6 | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 206 | SectionKind::getMetadata()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 207 | DwarfPubTypesSection = |
| 208 | Ctx->getMachOSection("__DWARF", "__debug_pubtypes", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 209 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 210 | SectionKind::getMetadata()); |
Eric Christopher | b0e7694 | 2013-09-09 20:03:14 +0000 | [diff] [blame] | 211 | DwarfGnuPubNamesSection = |
| 212 | Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 213 | MachO::S_ATTR_DEBUG, |
Eric Christopher | b0e7694 | 2013-09-09 20:03:14 +0000 | [diff] [blame] | 214 | SectionKind::getMetadata()); |
| 215 | DwarfGnuPubTypesSection = |
| 216 | Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 217 | MachO::S_ATTR_DEBUG, |
Eric Christopher | b0e7694 | 2013-09-09 20:03:14 +0000 | [diff] [blame] | 218 | SectionKind::getMetadata()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 219 | DwarfStrSection = |
| 220 | Ctx->getMachOSection("__DWARF", "__debug_str", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 221 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 222 | SectionKind::getMetadata()); |
| 223 | DwarfLocSection = |
| 224 | Ctx->getMachOSection("__DWARF", "__debug_loc", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 225 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 226 | SectionKind::getMetadata()); |
| 227 | DwarfARangesSection = |
| 228 | Ctx->getMachOSection("__DWARF", "__debug_aranges", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 229 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 230 | SectionKind::getMetadata()); |
| 231 | DwarfRangesSection = |
| 232 | Ctx->getMachOSection("__DWARF", "__debug_ranges", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 233 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 234 | SectionKind::getMetadata()); |
| 235 | DwarfMacroInfoSection = |
| 236 | Ctx->getMachOSection("__DWARF", "__debug_macinfo", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 237 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 238 | SectionKind::getMetadata()); |
| 239 | DwarfDebugInlineSection = |
| 240 | Ctx->getMachOSection("__DWARF", "__debug_inlined", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 241 | MachO::S_ATTR_DEBUG, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 242 | SectionKind::getMetadata()); |
Lang Hames | 3078977 | 2013-11-08 22:14:49 +0000 | [diff] [blame] | 243 | StackMapSection = |
| 244 | Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps", 0, |
| 245 | SectionKind::getMetadata()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 246 | |
| 247 | TLSExtraDataSection = TLSTLVSection; |
| 248 | } |
| 249 | |
| 250 | void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) { |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 251 | switch (T.getArch()) { |
| 252 | case Triple::mips: |
| 253 | case Triple::mipsel: |
Rafael Espindola | b9b7ae0 | 2013-04-03 03:13:19 +0000 | [diff] [blame] | 254 | FDECFIEncoding = dwarf::DW_EH_PE_sdata4; |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 255 | break; |
| 256 | case Triple::mips64: |
| 257 | case Triple::mips64el: |
Rafael Espindola | b9b7ae0 | 2013-04-03 03:13:19 +0000 | [diff] [blame] | 258 | FDECFIEncoding = dwarf::DW_EH_PE_sdata8; |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 259 | break; |
| 260 | default: |
Rafael Espindola | ef9d349 | 2013-03-15 05:51:57 +0000 | [diff] [blame] | 261 | FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 262 | break; |
| 263 | } |
Rafael Espindola | ef9d349 | 2013-03-15 05:51:57 +0000 | [diff] [blame] | 264 | |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 265 | switch (T.getArch()) { |
Joerg Sonnenberger | cf86ce1 | 2014-05-07 07:49:34 +0000 | [diff] [blame] | 266 | case Triple::arm: |
| 267 | case Triple::armeb: |
| 268 | case Triple::thumb: |
| 269 | case Triple::thumbeb: |
Joerg Sonnenberger | 94cbb66 | 2014-05-13 17:58:13 +0000 | [diff] [blame] | 270 | if (Ctx->getAsmInfo()->getExceptionHandlingType() == ExceptionHandling::ARM) |
| 271 | break; |
| 272 | // Fallthrough if not using EHABI |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 273 | case Triple::x86: |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 274 | PersonalityEncoding = (RelocM == Reloc::PIC_) |
Jim Grosbach | 0dde349 | 2011-11-15 16:46:22 +0000 | [diff] [blame] | 275 | ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 276 | : dwarf::DW_EH_PE_absptr; |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 277 | LSDAEncoding = (RelocM == Reloc::PIC_) |
| 278 | ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 279 | : dwarf::DW_EH_PE_absptr; |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 280 | TTypeEncoding = (RelocM == Reloc::PIC_) |
Jim Grosbach | 0dde349 | 2011-11-15 16:46:22 +0000 | [diff] [blame] | 281 | ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 282 | : dwarf::DW_EH_PE_absptr; |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 283 | break; |
| 284 | case Triple::x86_64: |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 285 | if (RelocM == Reloc::PIC_) { |
| 286 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 287 | ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium) |
| 288 | ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); |
| 289 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | |
| 290 | (CMModel == CodeModel::Small |
| 291 | ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 292 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 293 | ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium) |
| 294 | ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); |
| 295 | } else { |
| 296 | PersonalityEncoding = |
| 297 | (CMModel == CodeModel::Small || CMModel == CodeModel::Medium) |
| 298 | ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; |
| 299 | LSDAEncoding = (CMModel == CodeModel::Small) |
| 300 | ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 301 | TTypeEncoding = (CMModel == CodeModel::Small) |
| 302 | ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; |
| 303 | } |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 304 | break; |
| 305 | case Triple::aarch64: |
| 306 | case Triple::aarch64_be: |
| 307 | case Triple::arm64: |
| 308 | case Triple::arm64_be: |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 309 | // The small model guarantees static code/data size < 4GB, but not where it |
| 310 | // will be in memory. Most of these could end up >2GB away so even a signed |
| 311 | // pc-relative 32-bit address is insufficient, theoretically. |
| 312 | if (RelocM == Reloc::PIC_) { |
| 313 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 314 | dwarf::DW_EH_PE_sdata8; |
| 315 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8; |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 316 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 317 | dwarf::DW_EH_PE_sdata8; |
| 318 | } else { |
| 319 | PersonalityEncoding = dwarf::DW_EH_PE_absptr; |
| 320 | LSDAEncoding = dwarf::DW_EH_PE_absptr; |
Tim Northover | e0e3aef | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 321 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 322 | } |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 323 | break; |
Logan Chien | c002981 | 2014-05-30 16:48:56 +0000 | [diff] [blame] | 324 | case Triple::mips: |
| 325 | case Triple::mipsel: |
| 326 | // MIPS uses indirect pointer to refer personality functions, so that the |
| 327 | // eh_frame section can be read-only. DW.ref.personality will be generated |
| 328 | // for relocation. |
| 329 | PersonalityEncoding = dwarf::DW_EH_PE_indirect; |
| 330 | break; |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 331 | case Triple::ppc64: |
| 332 | case Triple::ppc64le: |
Adhemerval Zanella | 1ae2248 | 2013-01-09 17:08:15 +0000 | [diff] [blame] | 333 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 334 | dwarf::DW_EH_PE_udata8; |
Adhemerval Zanella | 1ae2248 | 2013-01-09 17:08:15 +0000 | [diff] [blame] | 335 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8; |
Adhemerval Zanella | 1ae2248 | 2013-01-09 17:08:15 +0000 | [diff] [blame] | 336 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 337 | dwarf::DW_EH_PE_udata8; |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 338 | break; |
| 339 | case Triple::sparc: |
Jakob Stoklund Olesen | 83c6773 | 2014-01-28 02:52:26 +0000 | [diff] [blame] | 340 | if (RelocM == Reloc::PIC_) { |
| 341 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 342 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 343 | dwarf::DW_EH_PE_sdata4; |
Jakob Stoklund Olesen | 83c6773 | 2014-01-28 02:52:26 +0000 | [diff] [blame] | 344 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 345 | dwarf::DW_EH_PE_sdata4; |
| 346 | } else { |
| 347 | LSDAEncoding = dwarf::DW_EH_PE_absptr; |
| 348 | PersonalityEncoding = dwarf::DW_EH_PE_absptr; |
Jakob Stoklund Olesen | 83c6773 | 2014-01-28 02:52:26 +0000 | [diff] [blame] | 349 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 350 | } |
Joerg Sonnenberger | fa9cf65 | 2014-04-30 23:36:24 +0000 | [diff] [blame] | 351 | break; |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 352 | case Triple::sparcv9: |
Jakob Stoklund Olesen | 83c6773 | 2014-01-28 02:52:26 +0000 | [diff] [blame] | 353 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 354 | if (RelocM == Reloc::PIC_) { |
| 355 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 356 | dwarf::DW_EH_PE_sdata4; |
Jakob Stoklund Olesen | 83c6773 | 2014-01-28 02:52:26 +0000 | [diff] [blame] | 357 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 358 | dwarf::DW_EH_PE_sdata4; |
| 359 | } else { |
| 360 | PersonalityEncoding = dwarf::DW_EH_PE_absptr; |
Jakob Stoklund Olesen | 83c6773 | 2014-01-28 02:52:26 +0000 | [diff] [blame] | 361 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 362 | } |
Joerg Sonnenberger | fa9cf65 | 2014-04-30 23:36:24 +0000 | [diff] [blame] | 363 | break; |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 364 | case Triple::systemz: |
Ulrich Weigand | 0213e7f | 2013-05-06 16:11:12 +0000 | [diff] [blame] | 365 | // All currently-defined code models guarantee that 4-byte PC-relative |
| 366 | // values will be in range. |
Ulrich Weigand | e7c6dfe | 2013-05-06 17:28:30 +0000 | [diff] [blame] | 367 | if (RelocM == Reloc::PIC_) { |
| 368 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 369 | dwarf::DW_EH_PE_sdata4; |
| 370 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
Ulrich Weigand | e7c6dfe | 2013-05-06 17:28:30 +0000 | [diff] [blame] | 371 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 372 | dwarf::DW_EH_PE_sdata4; |
| 373 | } else { |
| 374 | PersonalityEncoding = dwarf::DW_EH_PE_absptr; |
| 375 | LSDAEncoding = dwarf::DW_EH_PE_absptr; |
Ulrich Weigand | e7c6dfe | 2013-05-06 17:28:30 +0000 | [diff] [blame] | 376 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 377 | } |
Joerg Sonnenberger | fa9cf65 | 2014-04-30 23:36:24 +0000 | [diff] [blame] | 378 | break; |
Joerg Sonnenberger | 7c44252 | 2014-04-30 23:23:14 +0000 | [diff] [blame] | 379 | default: |
| 380 | break; |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 381 | } |
| 382 | |
David Chisnall | 07f8d3e | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 383 | // Solaris requires different flags for .eh_frame to seemingly every other |
| 384 | // platform. |
David Chisnall | bbec872 | 2012-04-10 11:44:33 +0000 | [diff] [blame] | 385 | EHSectionType = ELF::SHT_PROGBITS; |
David Chisnall | 07f8d3e | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 386 | EHSectionFlags = ELF::SHF_ALLOC; |
David Chisnall | bbec872 | 2012-04-10 11:44:33 +0000 | [diff] [blame] | 387 | if (T.getOS() == Triple::Solaris) { |
| 388 | if (T.getArch() == Triple::x86_64) |
| 389 | EHSectionType = ELF::SHT_X86_64_UNWIND; |
| 390 | else |
| 391 | EHSectionFlags |= ELF::SHF_WRITE; |
| 392 | } |
David Chisnall | 07f8d3e | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 393 | |
| 394 | |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 395 | // ELF |
| 396 | BSSSection = |
| 397 | Ctx->getELFSection(".bss", ELF::SHT_NOBITS, |
Anton Korobeynikov | 7722a2d | 2012-01-25 22:24:19 +0000 | [diff] [blame] | 398 | ELF::SHF_WRITE | ELF::SHF_ALLOC, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 399 | SectionKind::getBSS()); |
| 400 | |
| 401 | TextSection = |
| 402 | Ctx->getELFSection(".text", ELF::SHT_PROGBITS, |
| 403 | ELF::SHF_EXECINSTR | |
| 404 | ELF::SHF_ALLOC, |
| 405 | SectionKind::getText()); |
| 406 | |
| 407 | DataSection = |
| 408 | Ctx->getELFSection(".data", ELF::SHT_PROGBITS, |
| 409 | ELF::SHF_WRITE |ELF::SHF_ALLOC, |
| 410 | SectionKind::getDataRel()); |
| 411 | |
| 412 | ReadOnlySection = |
| 413 | Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, |
| 414 | ELF::SHF_ALLOC, |
| 415 | SectionKind::getReadOnly()); |
| 416 | |
| 417 | TLSDataSection = |
| 418 | Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS, |
| 419 | ELF::SHF_ALLOC | ELF::SHF_TLS | |
| 420 | ELF::SHF_WRITE, |
| 421 | SectionKind::getThreadData()); |
| 422 | |
| 423 | TLSBSSSection = |
| 424 | Ctx->getELFSection(".tbss", ELF::SHT_NOBITS, |
| 425 | ELF::SHF_ALLOC | ELF::SHF_TLS | |
| 426 | ELF::SHF_WRITE, |
| 427 | SectionKind::getThreadBSS()); |
| 428 | |
| 429 | DataRelSection = |
| 430 | Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS, |
| 431 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 432 | SectionKind::getDataRel()); |
| 433 | |
| 434 | DataRelLocalSection = |
| 435 | Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS, |
| 436 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 437 | SectionKind::getDataRelLocal()); |
| 438 | |
| 439 | DataRelROSection = |
| 440 | Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS, |
| 441 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 442 | SectionKind::getReadOnlyWithRel()); |
| 443 | |
| 444 | DataRelROLocalSection = |
| 445 | Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS, |
| 446 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 447 | SectionKind::getReadOnlyWithRelLocal()); |
| 448 | |
| 449 | MergeableConst4Section = |
| 450 | Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS, |
| 451 | ELF::SHF_ALLOC |ELF::SHF_MERGE, |
| 452 | SectionKind::getMergeableConst4()); |
| 453 | |
| 454 | MergeableConst8Section = |
| 455 | Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS, |
| 456 | ELF::SHF_ALLOC |ELF::SHF_MERGE, |
| 457 | SectionKind::getMergeableConst8()); |
| 458 | |
| 459 | MergeableConst16Section = |
| 460 | Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS, |
| 461 | ELF::SHF_ALLOC |ELF::SHF_MERGE, |
| 462 | SectionKind::getMergeableConst16()); |
| 463 | |
| 464 | StaticCtorSection = |
| 465 | Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS, |
| 466 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 467 | SectionKind::getDataRel()); |
| 468 | |
| 469 | StaticDtorSection = |
| 470 | Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS, |
| 471 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 472 | SectionKind::getDataRel()); |
| 473 | |
| 474 | // Exception Handling Sections. |
| 475 | |
| 476 | // FIXME: We're emitting LSDA info into a readonly section on ELF, even though |
| 477 | // it contains relocatable pointers. In PIC mode, this is probably a big |
| 478 | // runtime hit for C++ apps. Either the contents of the LSDA need to be |
| 479 | // adjusted or this should be a data section. |
| 480 | LSDASection = |
| 481 | Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS, |
| 482 | ELF::SHF_ALLOC, |
| 483 | SectionKind::getReadOnly()); |
| 484 | |
Craig Topper | bb694de | 2014-04-13 04:57:38 +0000 | [diff] [blame] | 485 | COFFDebugSymbolsSection = nullptr; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 486 | |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 487 | // Debug Info Sections. |
| 488 | DwarfAbbrevSection = |
| 489 | Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0, |
| 490 | SectionKind::getMetadata()); |
| 491 | DwarfInfoSection = |
| 492 | Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0, |
| 493 | SectionKind::getMetadata()); |
| 494 | DwarfLineSection = |
| 495 | Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0, |
| 496 | SectionKind::getMetadata()); |
| 497 | DwarfFrameSection = |
| 498 | Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0, |
| 499 | SectionKind::getMetadata()); |
Krzysztof Parzyszek | 228daa6 | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 500 | DwarfPubNamesSection = |
| 501 | Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0, |
| 502 | SectionKind::getMetadata()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 503 | DwarfPubTypesSection = |
| 504 | Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0, |
| 505 | SectionKind::getMetadata()); |
Eric Christopher | b0e7694 | 2013-09-09 20:03:14 +0000 | [diff] [blame] | 506 | DwarfGnuPubNamesSection = |
| 507 | Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0, |
| 508 | SectionKind::getMetadata()); |
| 509 | DwarfGnuPubTypesSection = |
| 510 | Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0, |
| 511 | SectionKind::getMetadata()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 512 | DwarfStrSection = |
Nick Lewycky | 1a62d78 | 2011-10-26 18:44:32 +0000 | [diff] [blame] | 513 | Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS, |
| 514 | ELF::SHF_MERGE | ELF::SHF_STRINGS, |
| 515 | SectionKind::getMergeable1ByteCString()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 516 | DwarfLocSection = |
| 517 | Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0, |
| 518 | SectionKind::getMetadata()); |
| 519 | DwarfARangesSection = |
| 520 | Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0, |
| 521 | SectionKind::getMetadata()); |
| 522 | DwarfRangesSection = |
| 523 | Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0, |
| 524 | SectionKind::getMetadata()); |
| 525 | DwarfMacroInfoSection = |
| 526 | Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0, |
| 527 | SectionKind::getMetadata()); |
Eric Christopher | 27ed8ec | 2012-11-28 02:49:34 +0000 | [diff] [blame] | 528 | |
| 529 | // DWARF5 Experimental Debug Info |
| 530 | |
| 531 | // Accelerator Tables |
Eric Christopher | a0ad67d | 2012-10-08 21:41:30 +0000 | [diff] [blame] | 532 | DwarfAccelNamesSection = |
| 533 | Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0, |
| 534 | SectionKind::getMetadata()); |
| 535 | DwarfAccelObjCSection = |
| 536 | Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0, |
| 537 | SectionKind::getMetadata()); |
| 538 | DwarfAccelNamespaceSection = |
| 539 | Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0, |
| 540 | SectionKind::getMetadata()); |
| 541 | DwarfAccelTypesSection = |
| 542 | Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0, |
| 543 | SectionKind::getMetadata()); |
Eric Christopher | c3b434b | 2012-11-28 02:49:38 +0000 | [diff] [blame] | 544 | |
| 545 | // Fission Sections |
| 546 | DwarfInfoDWOSection = |
| 547 | Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0, |
| 548 | SectionKind::getMetadata()); |
Eric Christopher | 3c23009 | 2012-11-30 06:47:06 +0000 | [diff] [blame] | 549 | DwarfAbbrevDWOSection = |
| 550 | Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0, |
| 551 | SectionKind::getMetadata()); |
| 552 | DwarfStrDWOSection = |
| 553 | Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS, |
| 554 | ELF::SHF_MERGE | ELF::SHF_STRINGS, |
| 555 | SectionKind::getMergeable1ByteCString()); |
| 556 | DwarfLineDWOSection = |
| 557 | Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0, |
| 558 | SectionKind::getMetadata()); |
| 559 | DwarfLocDWOSection = |
| 560 | Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0, |
| 561 | SectionKind::getMetadata()); |
Eric Christopher | c0fa867 | 2013-01-04 17:59:22 +0000 | [diff] [blame] | 562 | DwarfStrOffDWOSection = |
| 563 | Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0, |
| 564 | SectionKind::getMetadata()); |
Eric Christopher | 962c908 | 2013-01-15 23:56:56 +0000 | [diff] [blame] | 565 | DwarfAddrSection = |
| 566 | Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0, |
| 567 | SectionKind::getMetadata()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | |
| 571 | void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) { |
David Majnemer | a9bdb32 | 2014-04-08 22:33:40 +0000 | [diff] [blame] | 572 | // The object file format cannot represent common symbols with explicit |
| 573 | // alignments. |
| 574 | CommDirectiveSupportsAlignment = false; |
| 575 | |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 576 | // COFF |
David Majnemer | 3d96acb | 2013-08-13 01:23:53 +0000 | [diff] [blame] | 577 | BSSSection = |
| 578 | Ctx->getCOFFSection(".bss", |
| 579 | COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA | |
| 580 | COFF::IMAGE_SCN_MEM_READ | |
| 581 | COFF::IMAGE_SCN_MEM_WRITE, |
| 582 | SectionKind::getBSS()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 583 | TextSection = |
| 584 | Ctx->getCOFFSection(".text", |
| 585 | COFF::IMAGE_SCN_CNT_CODE | |
| 586 | COFF::IMAGE_SCN_MEM_EXECUTE | |
| 587 | COFF::IMAGE_SCN_MEM_READ, |
| 588 | SectionKind::getText()); |
| 589 | DataSection = |
| 590 | Ctx->getCOFFSection(".data", |
| 591 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 592 | COFF::IMAGE_SCN_MEM_READ | |
| 593 | COFF::IMAGE_SCN_MEM_WRITE, |
| 594 | SectionKind::getDataRel()); |
| 595 | ReadOnlySection = |
| 596 | Ctx->getCOFFSection(".rdata", |
| 597 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 598 | COFF::IMAGE_SCN_MEM_READ, |
| 599 | SectionKind::getReadOnly()); |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 600 | |
Saleem Abdulrasool | ed7fc4b | 2014-06-08 00:34:27 +0000 | [diff] [blame^] | 601 | if (T.isKnownWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) { |
Michael J. Spencer | b560d07 | 2012-02-23 21:56:08 +0000 | [diff] [blame] | 602 | StaticCtorSection = |
| 603 | Ctx->getCOFFSection(".CRT$XCU", |
| 604 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 605 | COFF::IMAGE_SCN_MEM_READ, |
| 606 | SectionKind::getReadOnly()); |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 607 | StaticDtorSection = |
| 608 | Ctx->getCOFFSection(".CRT$XTX", |
| 609 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 610 | COFF::IMAGE_SCN_MEM_READ, |
| 611 | SectionKind::getReadOnly()); |
Michael J. Spencer | b560d07 | 2012-02-23 21:56:08 +0000 | [diff] [blame] | 612 | } else { |
| 613 | StaticCtorSection = |
| 614 | Ctx->getCOFFSection(".ctors", |
| 615 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 616 | COFF::IMAGE_SCN_MEM_READ | |
| 617 | COFF::IMAGE_SCN_MEM_WRITE, |
| 618 | SectionKind::getDataRel()); |
Anton Korobeynikov | 37d7300 | 2012-09-23 15:53:47 +0000 | [diff] [blame] | 619 | StaticDtorSection = |
| 620 | Ctx->getCOFFSection(".dtors", |
| 621 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 622 | COFF::IMAGE_SCN_MEM_READ | |
| 623 | COFF::IMAGE_SCN_MEM_WRITE, |
| 624 | SectionKind::getDataRel()); |
| 625 | } |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 626 | |
| 627 | // FIXME: We're emitting LSDA info into a readonly section on COFF, even |
| 628 | // though it contains relocatable pointers. In PIC mode, this is probably a |
| 629 | // big runtime hit for C++ apps. Either the contents of the LSDA need to be |
| 630 | // adjusted or this should be a data section. |
Kai Nacke | 4209730 | 2013-07-08 04:43:23 +0000 | [diff] [blame] | 631 | LSDASection = |
| 632 | Ctx->getCOFFSection(".gcc_except_table", |
| 633 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 634 | COFF::IMAGE_SCN_MEM_READ, |
| 635 | SectionKind::getReadOnly()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 636 | |
| 637 | // Debug info. |
Timur Iskhodzhanov | 31377c5 | 2014-01-28 03:48:44 +0000 | [diff] [blame] | 638 | COFFDebugSymbolsSection = |
| 639 | Ctx->getCOFFSection(".debug$S", |
| 640 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 641 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 642 | COFF::IMAGE_SCN_MEM_READ, |
| 643 | SectionKind::getMetadata()); |
| 644 | |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 645 | DwarfAbbrevSection = |
| 646 | Ctx->getCOFFSection(".debug_abbrev", |
| 647 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 648 | COFF::IMAGE_SCN_MEM_READ, |
| 649 | SectionKind::getMetadata()); |
| 650 | DwarfInfoSection = |
| 651 | Ctx->getCOFFSection(".debug_info", |
| 652 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 653 | COFF::IMAGE_SCN_MEM_READ, |
| 654 | SectionKind::getMetadata()); |
| 655 | DwarfLineSection = |
| 656 | Ctx->getCOFFSection(".debug_line", |
| 657 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 658 | COFF::IMAGE_SCN_MEM_READ, |
| 659 | SectionKind::getMetadata()); |
| 660 | DwarfFrameSection = |
| 661 | Ctx->getCOFFSection(".debug_frame", |
| 662 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 663 | COFF::IMAGE_SCN_MEM_READ, |
| 664 | SectionKind::getMetadata()); |
Krzysztof Parzyszek | 228daa6 | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 665 | DwarfPubNamesSection = |
| 666 | Ctx->getCOFFSection(".debug_pubnames", |
| 667 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 668 | COFF::IMAGE_SCN_MEM_READ, |
| 669 | SectionKind::getMetadata()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 670 | DwarfPubTypesSection = |
| 671 | Ctx->getCOFFSection(".debug_pubtypes", |
| 672 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 673 | COFF::IMAGE_SCN_MEM_READ, |
| 674 | SectionKind::getMetadata()); |
NAKAMURA Takumi | 0229e35 | 2013-09-10 06:01:56 +0000 | [diff] [blame] | 675 | DwarfGnuPubNamesSection = |
Eric Christopher | b0e7694 | 2013-09-09 20:03:14 +0000 | [diff] [blame] | 676 | Ctx->getCOFFSection(".debug_gnu_pubnames", |
| 677 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 678 | COFF::IMAGE_SCN_MEM_READ, |
| 679 | SectionKind::getMetadata()); |
NAKAMURA Takumi | 0229e35 | 2013-09-10 06:01:56 +0000 | [diff] [blame] | 680 | DwarfGnuPubTypesSection = |
Eric Christopher | b0e7694 | 2013-09-09 20:03:14 +0000 | [diff] [blame] | 681 | Ctx->getCOFFSection(".debug_gnu_pubtypes", |
| 682 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 683 | COFF::IMAGE_SCN_MEM_READ, |
| 684 | SectionKind::getMetadata()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 685 | DwarfStrSection = |
| 686 | Ctx->getCOFFSection(".debug_str", |
| 687 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 688 | COFF::IMAGE_SCN_MEM_READ, |
| 689 | SectionKind::getMetadata()); |
| 690 | DwarfLocSection = |
| 691 | Ctx->getCOFFSection(".debug_loc", |
| 692 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 693 | COFF::IMAGE_SCN_MEM_READ, |
| 694 | SectionKind::getMetadata()); |
| 695 | DwarfARangesSection = |
| 696 | Ctx->getCOFFSection(".debug_aranges", |
| 697 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 698 | COFF::IMAGE_SCN_MEM_READ, |
| 699 | SectionKind::getMetadata()); |
| 700 | DwarfRangesSection = |
| 701 | Ctx->getCOFFSection(".debug_ranges", |
| 702 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 703 | COFF::IMAGE_SCN_MEM_READ, |
| 704 | SectionKind::getMetadata()); |
| 705 | DwarfMacroInfoSection = |
| 706 | Ctx->getCOFFSection(".debug_macinfo", |
| 707 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 708 | COFF::IMAGE_SCN_MEM_READ, |
| 709 | SectionKind::getMetadata()); |
David Blaikie | 62dd7df | 2014-03-26 03:05:10 +0000 | [diff] [blame] | 710 | DwarfInfoDWOSection = |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 711 | Ctx->getCOFFSection(".debug_info.dwo", |
| 712 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 713 | COFF::IMAGE_SCN_MEM_READ, |
David Blaikie | 62dd7df | 2014-03-26 03:05:10 +0000 | [diff] [blame] | 714 | SectionKind::getMetadata()); |
| 715 | DwarfAbbrevDWOSection = |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 716 | Ctx->getCOFFSection(".debug_abbrev.dwo", |
| 717 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 718 | COFF::IMAGE_SCN_MEM_READ, |
David Blaikie | 62dd7df | 2014-03-26 03:05:10 +0000 | [diff] [blame] | 719 | SectionKind::getMetadata()); |
| 720 | DwarfStrDWOSection = |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 721 | Ctx->getCOFFSection(".debug_str.dwo", |
| 722 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 723 | COFF::IMAGE_SCN_MEM_READ, |
David Blaikie | 62dd7df | 2014-03-26 03:05:10 +0000 | [diff] [blame] | 724 | SectionKind::getMetadata()); |
| 725 | DwarfLineDWOSection = |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 726 | Ctx->getCOFFSection(".debug_line.dwo", |
| 727 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 728 | COFF::IMAGE_SCN_MEM_READ, |
David Blaikie | 62dd7df | 2014-03-26 03:05:10 +0000 | [diff] [blame] | 729 | SectionKind::getMetadata()); |
| 730 | DwarfLocDWOSection = |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 731 | Ctx->getCOFFSection(".debug_loc.dwo", |
| 732 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 733 | COFF::IMAGE_SCN_MEM_READ, |
David Blaikie | 62dd7df | 2014-03-26 03:05:10 +0000 | [diff] [blame] | 734 | SectionKind::getMetadata()); |
| 735 | DwarfStrOffDWOSection = |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 736 | Ctx->getCOFFSection(".debug_str_offsets.dwo", |
| 737 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 738 | COFF::IMAGE_SCN_MEM_READ, |
David Blaikie | 62dd7df | 2014-03-26 03:05:10 +0000 | [diff] [blame] | 739 | SectionKind::getMetadata()); |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 740 | |
| 741 | DwarfAddrSection = |
| 742 | Ctx->getCOFFSection(".debug_addr", |
| 743 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 744 | COFF::IMAGE_SCN_MEM_READ, |
| 745 | SectionKind::getMetadata()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 746 | |
| 747 | DrectveSection = |
| 748 | Ctx->getCOFFSection(".drectve", |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 749 | COFF::IMAGE_SCN_LNK_INFO | |
| 750 | COFF::IMAGE_SCN_LNK_REMOVE, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 751 | SectionKind::getMetadata()); |
| 752 | |
| 753 | PDataSection = |
| 754 | Ctx->getCOFFSection(".pdata", |
| 755 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
Anton Korobeynikov | cc8c539 | 2012-08-08 12:46:46 +0000 | [diff] [blame] | 756 | COFF::IMAGE_SCN_MEM_READ, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 757 | SectionKind::getDataRel()); |
| 758 | |
| 759 | XDataSection = |
| 760 | Ctx->getCOFFSection(".xdata", |
| 761 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
Anton Korobeynikov | cc8c539 | 2012-08-08 12:46:46 +0000 | [diff] [blame] | 762 | COFF::IMAGE_SCN_MEM_READ, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 763 | SectionKind::getDataRel()); |
Saleem Abdulrasool | a35f04a | 2014-06-08 00:34:23 +0000 | [diff] [blame] | 764 | |
Anton Korobeynikov | c6b4017 | 2012-02-11 17:26:53 +0000 | [diff] [blame] | 765 | TLSDataSection = |
| 766 | Ctx->getCOFFSection(".tls$", |
| 767 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 768 | COFF::IMAGE_SCN_MEM_READ | |
| 769 | COFF::IMAGE_SCN_MEM_WRITE, |
| 770 | SectionKind::getDataRel()); |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm, |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 774 | CodeModel::Model cm, |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 775 | MCContext &ctx) { |
| 776 | RelocM = relocm; |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 777 | CMModel = cm; |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 778 | Ctx = &ctx; |
| 779 | |
| 780 | // Common. |
| 781 | CommDirectiveSupportsAlignment = true; |
| 782 | SupportsWeakOmittedEHFrame = true; |
| 783 | IsFunctionEHFrameSymbolPrivate = true; |
Tim Northover | d1c6f51 | 2014-03-29 09:03:13 +0000 | [diff] [blame] | 784 | SupportsCompactUnwindWithoutEHFrame = false; |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 785 | |
Rafael Espindola | aa7851d | 2014-05-12 13:47:05 +0000 | [diff] [blame] | 786 | PersonalityEncoding = LSDAEncoding = FDECFIEncoding = TTypeEncoding = |
| 787 | dwarf::DW_EH_PE_absptr; |
Evan Cheng | bbf3b0d | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 788 | |
Bill Wendling | 2d1df6b | 2013-04-10 21:42:06 +0000 | [diff] [blame] | 789 | CompactUnwindDwarfEHFrameOnly = 0; |
| 790 | |
Craig Topper | bb694de | 2014-04-13 04:57:38 +0000 | [diff] [blame] | 791 | EHFrameSection = nullptr; // Created on demand. |
| 792 | CompactUnwindSection = nullptr; // Used only by selected targets. |
| 793 | DwarfAccelNamesSection = nullptr; // Used only by selected targets. |
| 794 | DwarfAccelObjCSection = nullptr; // Used only by selected targets. |
| 795 | DwarfAccelNamespaceSection = nullptr; // Used only by selected targets. |
| 796 | DwarfAccelTypesSection = nullptr; // Used only by selected targets. |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 797 | |
| 798 | Triple T(TT); |
| 799 | Triple::ArchType Arch = T.getArch(); |
| 800 | // FIXME: Checking for Arch here to filter out bogus triples such as |
| 801 | // cellspu-apple-darwin. Perhaps we should fix in Triple? |
| 802 | if ((Arch == Triple::x86 || Arch == Triple::x86_64 || |
| 803 | Arch == Triple::arm || Arch == Triple::thumb || |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 804 | Arch == Triple::arm64 || Arch == Triple::aarch64 || |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 805 | Arch == Triple::ppc || Arch == Triple::ppc64 || |
| 806 | Arch == Triple::UnknownArch) && |
Saleem Abdulrasool | 3547633 | 2014-03-06 20:47:11 +0000 | [diff] [blame] | 807 | (T.isOSDarwin() || T.isOSBinFormatMachO())) { |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 808 | Env = IsMachO; |
| 809 | InitMachOMCObjectFileInfo(T); |
Saleem Abdulrasool | ffdb92a70 | 2014-04-27 04:54:16 +0000 | [diff] [blame] | 810 | } else if ((Arch == Triple::x86 || Arch == Triple::x86_64 || |
| 811 | Arch == Triple::arm || Arch == Triple::thumb) && |
| 812 | (T.isOSWindows() && T.getObjectFormat() == Triple::COFF)) { |
Evan Cheng | 7679299 | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 813 | Env = IsCOFF; |
| 814 | InitCOFFMCObjectFileInfo(T); |
| 815 | } else { |
| 816 | Env = IsELF; |
| 817 | InitELFMCObjectFileInfo(T); |
| 818 | } |
| 819 | } |
| 820 | |
David Blaikie | bc56327 | 2013-12-13 21:33:40 +0000 | [diff] [blame] | 821 | const MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const { |
| 822 | return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP, |
| 823 | SectionKind::getMetadata(), 0, utostr(Hash)); |
| 824 | } |
| 825 | |
David Blaikie | 2da282b | 2014-05-21 23:27:41 +0000 | [diff] [blame] | 826 | const MCSection * |
| 827 | MCObjectFileInfo::getDwarfTypesDWOSection(uint64_t Hash) const { |
| 828 | return Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS, |
| 829 | ELF::SHF_GROUP, SectionKind::getMetadata(), 0, |
| 830 | utostr(Hash)); |
| 831 | } |
| 832 | |
David Chisnall | 85dd309 | 2012-02-17 16:51:02 +0000 | [diff] [blame] | 833 | void MCObjectFileInfo::InitEHFrameSection() { |
| 834 | if (Env == IsMachO) |
| 835 | EHFrameSection = |
| 836 | Ctx->getMachOSection("__TEXT", "__eh_frame", |
David Majnemer | 7b58305 | 2014-03-07 07:36:05 +0000 | [diff] [blame] | 837 | MachO::S_COALESCED | |
| 838 | MachO::S_ATTR_NO_TOC | |
| 839 | MachO::S_ATTR_STRIP_STATIC_SYMS | |
| 840 | MachO::S_ATTR_LIVE_SUPPORT, |
David Chisnall | 85dd309 | 2012-02-17 16:51:02 +0000 | [diff] [blame] | 841 | SectionKind::getReadOnly()); |
| 842 | else if (Env == IsELF) |
| 843 | EHFrameSection = |
David Chisnall | bbec872 | 2012-04-10 11:44:33 +0000 | [diff] [blame] | 844 | Ctx->getELFSection(".eh_frame", EHSectionType, |
David Chisnall | 07f8d3e | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 845 | EHSectionFlags, |
David Chisnall | 85dd309 | 2012-02-17 16:51:02 +0000 | [diff] [blame] | 846 | SectionKind::getDataRel()); |
| 847 | else |
| 848 | EHFrameSection = |
| 849 | Ctx->getCOFFSection(".eh_frame", |
| 850 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 851 | COFF::IMAGE_SCN_MEM_READ | |
| 852 | COFF::IMAGE_SCN_MEM_WRITE, |
| 853 | SectionKind::getDataRel()); |
| 854 | } |