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