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