Evan Cheng | e76a33b | 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" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 11 | #include "llvm/ADT/Triple.h" |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 12 | #include "llvm/MC/MCContext.h" |
| 13 | #include "llvm/MC/MCSection.h" |
| 14 | #include "llvm/MC/MCSectionCOFF.h" |
| 15 | #include "llvm/MC/MCSectionELF.h" |
| 16 | #include "llvm/MC/MCSectionMachO.h" |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 17 | using namespace llvm; |
| 18 | |
| 19 | void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) { |
| 20 | // MachO |
| 21 | IsFunctionEHFrameSymbolPrivate = false; |
| 22 | SupportsWeakOmittedEHFrame = false; |
| 23 | |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 24 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
| 25 | | dwarf::DW_EH_PE_sdata4; |
| 26 | LSDAEncoding = FDEEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel; |
| 27 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 28 | dwarf::DW_EH_PE_sdata4; |
| 29 | |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 30 | // .comm doesn't support alignment before Leopard. |
| 31 | if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5)) |
| 32 | CommDirectiveSupportsAlignment = false; |
| 33 | |
| 34 | TextSection // .text |
| 35 | = Ctx->getMachOSection("__TEXT", "__text", |
| 36 | MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, |
| 37 | SectionKind::getText()); |
| 38 | DataSection // .data |
| 39 | = Ctx->getMachOSection("__DATA", "__data", 0, |
| 40 | SectionKind::getDataRel()); |
| 41 | |
| 42 | TLSDataSection // .tdata |
| 43 | = Ctx->getMachOSection("__DATA", "__thread_data", |
| 44 | MCSectionMachO::S_THREAD_LOCAL_REGULAR, |
| 45 | SectionKind::getDataRel()); |
| 46 | TLSBSSSection // .tbss |
| 47 | = Ctx->getMachOSection("__DATA", "__thread_bss", |
| 48 | MCSectionMachO::S_THREAD_LOCAL_ZEROFILL, |
| 49 | SectionKind::getThreadBSS()); |
| 50 | |
| 51 | // TODO: Verify datarel below. |
| 52 | TLSTLVSection // .tlv |
| 53 | = Ctx->getMachOSection("__DATA", "__thread_vars", |
| 54 | MCSectionMachO::S_THREAD_LOCAL_VARIABLES, |
| 55 | SectionKind::getDataRel()); |
| 56 | |
| 57 | TLSThreadInitSection |
| 58 | = Ctx->getMachOSection("__DATA", "__thread_init", |
Jim Grosbach | 946227d | 2011-11-15 16:46:22 +0000 | [diff] [blame] | 59 | MCSectionMachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS, |
| 60 | SectionKind::getDataRel()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 61 | |
| 62 | CStringSection // .cstring |
| 63 | = Ctx->getMachOSection("__TEXT", "__cstring", |
| 64 | MCSectionMachO::S_CSTRING_LITERALS, |
| 65 | SectionKind::getMergeable1ByteCString()); |
| 66 | UStringSection |
| 67 | = Ctx->getMachOSection("__TEXT","__ustring", 0, |
| 68 | SectionKind::getMergeable2ByteCString()); |
| 69 | FourByteConstantSection // .literal4 |
| 70 | = Ctx->getMachOSection("__TEXT", "__literal4", |
| 71 | MCSectionMachO::S_4BYTE_LITERALS, |
| 72 | SectionKind::getMergeableConst4()); |
| 73 | EightByteConstantSection // .literal8 |
| 74 | = Ctx->getMachOSection("__TEXT", "__literal8", |
| 75 | MCSectionMachO::S_8BYTE_LITERALS, |
| 76 | SectionKind::getMergeableConst8()); |
| 77 | |
| 78 | // ld_classic doesn't support .literal16 in 32-bit mode, and ld64 falls back |
| 79 | // to using it in -static mode. |
| 80 | SixteenByteConstantSection = 0; |
| 81 | if (RelocM != Reloc::Static && |
Bill Schmidt | f38cc38 | 2013-07-26 01:35:43 +0000 | [diff] [blame] | 82 | T.getArch() != Triple::x86_64 && T.getArch() != Triple::ppc64 && |
| 83 | T.getArch() != Triple::ppc64le) |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 84 | SixteenByteConstantSection = // .literal16 |
| 85 | Ctx->getMachOSection("__TEXT", "__literal16", |
| 86 | MCSectionMachO::S_16BYTE_LITERALS, |
| 87 | SectionKind::getMergeableConst16()); |
| 88 | |
| 89 | ReadOnlySection // .const |
| 90 | = Ctx->getMachOSection("__TEXT", "__const", 0, |
| 91 | SectionKind::getReadOnly()); |
| 92 | |
| 93 | TextCoalSection |
| 94 | = Ctx->getMachOSection("__TEXT", "__textcoal_nt", |
| 95 | MCSectionMachO::S_COALESCED | |
| 96 | MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, |
| 97 | SectionKind::getText()); |
| 98 | ConstTextCoalSection |
| 99 | = Ctx->getMachOSection("__TEXT", "__const_coal", |
| 100 | MCSectionMachO::S_COALESCED, |
| 101 | SectionKind::getReadOnly()); |
| 102 | ConstDataSection // .const_data |
| 103 | = Ctx->getMachOSection("__DATA", "__const", 0, |
| 104 | SectionKind::getReadOnlyWithRel()); |
| 105 | DataCoalSection |
| 106 | = Ctx->getMachOSection("__DATA","__datacoal_nt", |
| 107 | MCSectionMachO::S_COALESCED, |
| 108 | SectionKind::getDataRel()); |
| 109 | DataCommonSection |
| 110 | = Ctx->getMachOSection("__DATA","__common", |
| 111 | MCSectionMachO::S_ZEROFILL, |
| 112 | SectionKind::getBSS()); |
| 113 | DataBSSSection |
| 114 | = Ctx->getMachOSection("__DATA","__bss", MCSectionMachO::S_ZEROFILL, |
| 115 | SectionKind::getBSS()); |
| 116 | |
| 117 | |
| 118 | LazySymbolPointerSection |
| 119 | = Ctx->getMachOSection("__DATA", "__la_symbol_ptr", |
| 120 | MCSectionMachO::S_LAZY_SYMBOL_POINTERS, |
| 121 | SectionKind::getMetadata()); |
| 122 | NonLazySymbolPointerSection |
| 123 | = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr", |
| 124 | MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS, |
| 125 | SectionKind::getMetadata()); |
| 126 | |
| 127 | if (RelocM == Reloc::Static) { |
| 128 | StaticCtorSection |
| 129 | = Ctx->getMachOSection("__TEXT", "__constructor", 0, |
| 130 | SectionKind::getDataRel()); |
| 131 | StaticDtorSection |
| 132 | = Ctx->getMachOSection("__TEXT", "__destructor", 0, |
| 133 | SectionKind::getDataRel()); |
| 134 | } else { |
| 135 | StaticCtorSection |
| 136 | = Ctx->getMachOSection("__DATA", "__mod_init_func", |
| 137 | MCSectionMachO::S_MOD_INIT_FUNC_POINTERS, |
| 138 | SectionKind::getDataRel()); |
| 139 | StaticDtorSection |
| 140 | = Ctx->getMachOSection("__DATA", "__mod_term_func", |
| 141 | MCSectionMachO::S_MOD_TERM_FUNC_POINTERS, |
| 142 | SectionKind::getDataRel()); |
| 143 | } |
| 144 | |
| 145 | // Exception Handling. |
| 146 | LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0, |
| 147 | SectionKind::getReadOnlyWithRel()); |
| 148 | |
Bill Wendling | 62c75ad | 2013-04-10 21:42:06 +0000 | [diff] [blame] | 149 | if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6)) { |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 150 | CompactUnwindSection = |
| 151 | Ctx->getMachOSection("__LD", "__compact_unwind", |
| 152 | MCSectionMachO::S_ATTR_DEBUG, |
| 153 | SectionKind::getReadOnly()); |
| 154 | |
Bill Wendling | 62c75ad | 2013-04-10 21:42:06 +0000 | [diff] [blame] | 155 | if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86) |
| 156 | CompactUnwindDwarfEHFrameOnly = 0x04000000; |
| 157 | } |
| 158 | |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 159 | // Debug Information. |
Eric Christopher | 09ac3d8 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 160 | DwarfAccelNamesSection = |
| 161 | Ctx->getMachOSection("__DWARF", "__apple_names", |
| 162 | MCSectionMachO::S_ATTR_DEBUG, |
| 163 | SectionKind::getMetadata()); |
| 164 | DwarfAccelObjCSection = |
| 165 | Ctx->getMachOSection("__DWARF", "__apple_objc", |
| 166 | MCSectionMachO::S_ATTR_DEBUG, |
| 167 | SectionKind::getMetadata()); |
| 168 | // 16 character section limit... |
| 169 | DwarfAccelNamespaceSection = |
| 170 | Ctx->getMachOSection("__DWARF", "__apple_namespac", |
| 171 | MCSectionMachO::S_ATTR_DEBUG, |
| 172 | SectionKind::getMetadata()); |
| 173 | DwarfAccelTypesSection = |
| 174 | Ctx->getMachOSection("__DWARF", "__apple_types", |
| 175 | MCSectionMachO::S_ATTR_DEBUG, |
| 176 | SectionKind::getMetadata()); |
Jim Grosbach | 2684d9e | 2012-05-11 01:41:30 +0000 | [diff] [blame] | 177 | |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 178 | DwarfAbbrevSection = |
| 179 | Ctx->getMachOSection("__DWARF", "__debug_abbrev", |
| 180 | MCSectionMachO::S_ATTR_DEBUG, |
| 181 | SectionKind::getMetadata()); |
| 182 | DwarfInfoSection = |
| 183 | Ctx->getMachOSection("__DWARF", "__debug_info", |
| 184 | MCSectionMachO::S_ATTR_DEBUG, |
| 185 | SectionKind::getMetadata()); |
| 186 | DwarfLineSection = |
| 187 | Ctx->getMachOSection("__DWARF", "__debug_line", |
| 188 | MCSectionMachO::S_ATTR_DEBUG, |
| 189 | SectionKind::getMetadata()); |
| 190 | DwarfFrameSection = |
| 191 | Ctx->getMachOSection("__DWARF", "__debug_frame", |
| 192 | MCSectionMachO::S_ATTR_DEBUG, |
| 193 | SectionKind::getMetadata()); |
Krzysztof Parzyszek | c5ef7ee | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 194 | DwarfPubNamesSection = |
| 195 | Ctx->getMachOSection("__DWARF", "__debug_pubnames", |
| 196 | MCSectionMachO::S_ATTR_DEBUG, |
| 197 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 198 | DwarfPubTypesSection = |
| 199 | Ctx->getMachOSection("__DWARF", "__debug_pubtypes", |
| 200 | MCSectionMachO::S_ATTR_DEBUG, |
| 201 | SectionKind::getMetadata()); |
| 202 | DwarfStrSection = |
| 203 | Ctx->getMachOSection("__DWARF", "__debug_str", |
| 204 | MCSectionMachO::S_ATTR_DEBUG, |
| 205 | SectionKind::getMetadata()); |
| 206 | DwarfLocSection = |
| 207 | Ctx->getMachOSection("__DWARF", "__debug_loc", |
| 208 | MCSectionMachO::S_ATTR_DEBUG, |
| 209 | SectionKind::getMetadata()); |
| 210 | DwarfARangesSection = |
| 211 | Ctx->getMachOSection("__DWARF", "__debug_aranges", |
| 212 | MCSectionMachO::S_ATTR_DEBUG, |
| 213 | SectionKind::getMetadata()); |
| 214 | DwarfRangesSection = |
| 215 | Ctx->getMachOSection("__DWARF", "__debug_ranges", |
| 216 | MCSectionMachO::S_ATTR_DEBUG, |
| 217 | SectionKind::getMetadata()); |
| 218 | DwarfMacroInfoSection = |
| 219 | Ctx->getMachOSection("__DWARF", "__debug_macinfo", |
| 220 | MCSectionMachO::S_ATTR_DEBUG, |
| 221 | SectionKind::getMetadata()); |
| 222 | DwarfDebugInlineSection = |
| 223 | Ctx->getMachOSection("__DWARF", "__debug_inlined", |
| 224 | MCSectionMachO::S_ATTR_DEBUG, |
| 225 | SectionKind::getMetadata()); |
| 226 | |
| 227 | TLSExtraDataSection = TLSTLVSection; |
| 228 | } |
| 229 | |
| 230 | void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) { |
Rafael Espindola | 04011e84 | 2013-04-03 03:13:19 +0000 | [diff] [blame] | 231 | if (T.getArch() == Triple::mips || |
| 232 | T.getArch() == Triple::mipsel) |
| 233 | FDECFIEncoding = dwarf::DW_EH_PE_sdata4; |
| 234 | else if (T.getArch() == Triple::mips64 || |
| 235 | T.getArch() == Triple::mips64el) |
| 236 | FDECFIEncoding = dwarf::DW_EH_PE_sdata8; |
| 237 | else |
Rafael Espindola | 7a86ffb | 2013-03-15 05:51:57 +0000 | [diff] [blame] | 238 | FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 239 | |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 240 | if (T.getArch() == Triple::x86) { |
| 241 | PersonalityEncoding = (RelocM == Reloc::PIC_) |
Jim Grosbach | 946227d | 2011-11-15 16:46:22 +0000 | [diff] [blame] | 242 | ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 243 | : dwarf::DW_EH_PE_absptr; |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 244 | LSDAEncoding = (RelocM == Reloc::PIC_) |
| 245 | ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 246 | : dwarf::DW_EH_PE_absptr; |
Rafael Espindola | 7a86ffb | 2013-03-15 05:51:57 +0000 | [diff] [blame] | 247 | FDEEncoding = (RelocM == Reloc::PIC_) |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 248 | ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 249 | : dwarf::DW_EH_PE_absptr; |
| 250 | TTypeEncoding = (RelocM == Reloc::PIC_) |
Jim Grosbach | 946227d | 2011-11-15 16:46:22 +0000 | [diff] [blame] | 251 | ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 252 | : dwarf::DW_EH_PE_absptr; |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 253 | } else if (T.getArch() == Triple::x86_64) { |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 254 | if (RelocM == Reloc::PIC_) { |
| 255 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 256 | ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium) |
| 257 | ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); |
| 258 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | |
| 259 | (CMModel == CodeModel::Small |
| 260 | ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); |
| 261 | FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 262 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 263 | ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium) |
| 264 | ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); |
| 265 | } else { |
| 266 | PersonalityEncoding = |
| 267 | (CMModel == CodeModel::Small || CMModel == CodeModel::Medium) |
| 268 | ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; |
| 269 | LSDAEncoding = (CMModel == CodeModel::Small) |
| 270 | ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; |
| 271 | FDEEncoding = dwarf::DW_EH_PE_udata4; |
| 272 | TTypeEncoding = (CMModel == CodeModel::Small) |
| 273 | ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; |
| 274 | } |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 275 | } else if (T.getArch() == Triple::aarch64) { |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 276 | // The small model guarantees static code/data size < 4GB, but not where it |
| 277 | // will be in memory. Most of these could end up >2GB away so even a signed |
| 278 | // pc-relative 32-bit address is insufficient, theoretically. |
| 279 | if (RelocM == Reloc::PIC_) { |
| 280 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 281 | dwarf::DW_EH_PE_sdata8; |
| 282 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8; |
| 283 | FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 284 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 285 | dwarf::DW_EH_PE_sdata8; |
| 286 | } else { |
| 287 | PersonalityEncoding = dwarf::DW_EH_PE_absptr; |
| 288 | LSDAEncoding = dwarf::DW_EH_PE_absptr; |
| 289 | FDEEncoding = dwarf::DW_EH_PE_udata4; |
| 290 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 291 | } |
Bill Schmidt | f38cc38 | 2013-07-26 01:35:43 +0000 | [diff] [blame] | 292 | } else if (T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le) { |
Adhemerval Zanella | a1db5de | 2013-01-09 17:08:15 +0000 | [diff] [blame] | 293 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 294 | dwarf::DW_EH_PE_udata8; |
Adhemerval Zanella | a1db5de | 2013-01-09 17:08:15 +0000 | [diff] [blame] | 295 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8; |
| 296 | FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8; |
| 297 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 298 | dwarf::DW_EH_PE_udata8; |
Ulrich Weigand | e96e43f | 2013-05-06 16:11:12 +0000 | [diff] [blame] | 299 | } else if (T.getArch() == Triple::systemz) { |
| 300 | // All currently-defined code models guarantee that 4-byte PC-relative |
| 301 | // values will be in range. |
Ulrich Weigand | e5c8c24 | 2013-05-06 17:28:30 +0000 | [diff] [blame] | 302 | if (RelocM == Reloc::PIC_) { |
| 303 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 304 | dwarf::DW_EH_PE_sdata4; |
| 305 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 306 | FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 307 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 308 | dwarf::DW_EH_PE_sdata4; |
| 309 | } else { |
| 310 | PersonalityEncoding = dwarf::DW_EH_PE_absptr; |
| 311 | LSDAEncoding = dwarf::DW_EH_PE_absptr; |
| 312 | FDEEncoding = dwarf::DW_EH_PE_absptr; |
| 313 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 314 | } |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 315 | } |
| 316 | |
David Chisnall | 4cbcee1 | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 317 | // Solaris requires different flags for .eh_frame to seemingly every other |
| 318 | // platform. |
David Chisnall | bce0de4 | 2012-04-10 11:44:33 +0000 | [diff] [blame] | 319 | EHSectionType = ELF::SHT_PROGBITS; |
David Chisnall | 4cbcee1 | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 320 | EHSectionFlags = ELF::SHF_ALLOC; |
David Chisnall | bce0de4 | 2012-04-10 11:44:33 +0000 | [diff] [blame] | 321 | if (T.getOS() == Triple::Solaris) { |
| 322 | if (T.getArch() == Triple::x86_64) |
| 323 | EHSectionType = ELF::SHT_X86_64_UNWIND; |
| 324 | else |
| 325 | EHSectionFlags |= ELF::SHF_WRITE; |
| 326 | } |
David Chisnall | 4cbcee1 | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 327 | |
| 328 | |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 329 | // ELF |
| 330 | BSSSection = |
| 331 | Ctx->getELFSection(".bss", ELF::SHT_NOBITS, |
Anton Korobeynikov | 4a99f59 | 2012-01-25 22:24:19 +0000 | [diff] [blame] | 332 | ELF::SHF_WRITE | ELF::SHF_ALLOC, |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 333 | SectionKind::getBSS()); |
| 334 | |
| 335 | TextSection = |
| 336 | Ctx->getELFSection(".text", ELF::SHT_PROGBITS, |
| 337 | ELF::SHF_EXECINSTR | |
| 338 | ELF::SHF_ALLOC, |
| 339 | SectionKind::getText()); |
| 340 | |
| 341 | DataSection = |
| 342 | Ctx->getELFSection(".data", ELF::SHT_PROGBITS, |
| 343 | ELF::SHF_WRITE |ELF::SHF_ALLOC, |
| 344 | SectionKind::getDataRel()); |
| 345 | |
| 346 | ReadOnlySection = |
| 347 | Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, |
| 348 | ELF::SHF_ALLOC, |
| 349 | SectionKind::getReadOnly()); |
| 350 | |
| 351 | TLSDataSection = |
| 352 | Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS, |
| 353 | ELF::SHF_ALLOC | ELF::SHF_TLS | |
| 354 | ELF::SHF_WRITE, |
| 355 | SectionKind::getThreadData()); |
| 356 | |
| 357 | TLSBSSSection = |
| 358 | Ctx->getELFSection(".tbss", ELF::SHT_NOBITS, |
| 359 | ELF::SHF_ALLOC | ELF::SHF_TLS | |
| 360 | ELF::SHF_WRITE, |
| 361 | SectionKind::getThreadBSS()); |
| 362 | |
| 363 | DataRelSection = |
| 364 | Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS, |
| 365 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 366 | SectionKind::getDataRel()); |
| 367 | |
| 368 | DataRelLocalSection = |
| 369 | Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS, |
| 370 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 371 | SectionKind::getDataRelLocal()); |
| 372 | |
| 373 | DataRelROSection = |
| 374 | Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS, |
| 375 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 376 | SectionKind::getReadOnlyWithRel()); |
| 377 | |
| 378 | DataRelROLocalSection = |
| 379 | Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS, |
| 380 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 381 | SectionKind::getReadOnlyWithRelLocal()); |
| 382 | |
| 383 | MergeableConst4Section = |
| 384 | Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS, |
| 385 | ELF::SHF_ALLOC |ELF::SHF_MERGE, |
| 386 | SectionKind::getMergeableConst4()); |
| 387 | |
| 388 | MergeableConst8Section = |
| 389 | Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS, |
| 390 | ELF::SHF_ALLOC |ELF::SHF_MERGE, |
| 391 | SectionKind::getMergeableConst8()); |
| 392 | |
| 393 | MergeableConst16Section = |
| 394 | Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS, |
| 395 | ELF::SHF_ALLOC |ELF::SHF_MERGE, |
| 396 | SectionKind::getMergeableConst16()); |
| 397 | |
| 398 | StaticCtorSection = |
| 399 | Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS, |
| 400 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 401 | SectionKind::getDataRel()); |
| 402 | |
| 403 | StaticDtorSection = |
| 404 | Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS, |
| 405 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 406 | SectionKind::getDataRel()); |
| 407 | |
| 408 | // Exception Handling Sections. |
| 409 | |
| 410 | // FIXME: We're emitting LSDA info into a readonly section on ELF, even though |
| 411 | // it contains relocatable pointers. In PIC mode, this is probably a big |
| 412 | // runtime hit for C++ apps. Either the contents of the LSDA need to be |
| 413 | // adjusted or this should be a data section. |
| 414 | LSDASection = |
| 415 | Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS, |
| 416 | ELF::SHF_ALLOC, |
| 417 | SectionKind::getReadOnly()); |
| 418 | |
| 419 | // Debug Info Sections. |
| 420 | DwarfAbbrevSection = |
| 421 | Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0, |
| 422 | SectionKind::getMetadata()); |
| 423 | DwarfInfoSection = |
| 424 | Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0, |
| 425 | SectionKind::getMetadata()); |
| 426 | DwarfLineSection = |
| 427 | Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0, |
| 428 | SectionKind::getMetadata()); |
| 429 | DwarfFrameSection = |
| 430 | Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0, |
| 431 | SectionKind::getMetadata()); |
Krzysztof Parzyszek | c5ef7ee | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 432 | DwarfPubNamesSection = |
| 433 | Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0, |
| 434 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 435 | DwarfPubTypesSection = |
| 436 | Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0, |
| 437 | SectionKind::getMetadata()); |
| 438 | DwarfStrSection = |
Nick Lewycky | 5a86c5b | 2011-10-26 18:44:32 +0000 | [diff] [blame] | 439 | Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS, |
| 440 | ELF::SHF_MERGE | ELF::SHF_STRINGS, |
| 441 | SectionKind::getMergeable1ByteCString()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 442 | DwarfLocSection = |
| 443 | Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0, |
| 444 | SectionKind::getMetadata()); |
| 445 | DwarfARangesSection = |
| 446 | Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0, |
| 447 | SectionKind::getMetadata()); |
| 448 | DwarfRangesSection = |
| 449 | Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0, |
| 450 | SectionKind::getMetadata()); |
| 451 | DwarfMacroInfoSection = |
| 452 | Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0, |
| 453 | SectionKind::getMetadata()); |
Eric Christopher | ea1504d | 2012-11-28 02:49:34 +0000 | [diff] [blame] | 454 | |
| 455 | // DWARF5 Experimental Debug Info |
| 456 | |
| 457 | // Accelerator Tables |
Eric Christopher | 5b4461c | 2012-10-08 21:41:30 +0000 | [diff] [blame] | 458 | DwarfAccelNamesSection = |
| 459 | Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0, |
| 460 | SectionKind::getMetadata()); |
| 461 | DwarfAccelObjCSection = |
| 462 | Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0, |
| 463 | SectionKind::getMetadata()); |
| 464 | DwarfAccelNamespaceSection = |
| 465 | Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0, |
| 466 | SectionKind::getMetadata()); |
| 467 | DwarfAccelTypesSection = |
| 468 | Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0, |
| 469 | SectionKind::getMetadata()); |
Eric Christopher | 6acb531 | 2012-11-28 02:49:38 +0000 | [diff] [blame] | 470 | |
| 471 | // Fission Sections |
| 472 | DwarfInfoDWOSection = |
| 473 | Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0, |
| 474 | SectionKind::getMetadata()); |
Eric Christopher | 67587f4 | 2012-11-30 06:47:06 +0000 | [diff] [blame] | 475 | DwarfAbbrevDWOSection = |
| 476 | Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0, |
| 477 | SectionKind::getMetadata()); |
| 478 | DwarfStrDWOSection = |
| 479 | Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS, |
| 480 | ELF::SHF_MERGE | ELF::SHF_STRINGS, |
| 481 | SectionKind::getMergeable1ByteCString()); |
| 482 | DwarfLineDWOSection = |
| 483 | Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0, |
| 484 | SectionKind::getMetadata()); |
| 485 | DwarfLocDWOSection = |
| 486 | Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0, |
| 487 | SectionKind::getMetadata()); |
Eric Christopher | 60230ef | 2013-01-04 17:59:22 +0000 | [diff] [blame] | 488 | DwarfStrOffDWOSection = |
| 489 | Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0, |
| 490 | SectionKind::getMetadata()); |
Eric Christopher | 72f7bfb | 2013-01-15 23:56:56 +0000 | [diff] [blame] | 491 | DwarfAddrSection = |
| 492 | Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0, |
| 493 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | |
| 497 | void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) { |
| 498 | // COFF |
David Majnemer | 6aa9315 | 2013-08-13 01:23:53 +0000 | [diff] [blame] | 499 | BSSSection = |
| 500 | Ctx->getCOFFSection(".bss", |
| 501 | COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA | |
| 502 | COFF::IMAGE_SCN_MEM_READ | |
| 503 | COFF::IMAGE_SCN_MEM_WRITE, |
| 504 | SectionKind::getBSS()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 505 | TextSection = |
| 506 | Ctx->getCOFFSection(".text", |
| 507 | COFF::IMAGE_SCN_CNT_CODE | |
| 508 | COFF::IMAGE_SCN_MEM_EXECUTE | |
| 509 | COFF::IMAGE_SCN_MEM_READ, |
| 510 | SectionKind::getText()); |
| 511 | DataSection = |
| 512 | Ctx->getCOFFSection(".data", |
| 513 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 514 | COFF::IMAGE_SCN_MEM_READ | |
| 515 | COFF::IMAGE_SCN_MEM_WRITE, |
| 516 | SectionKind::getDataRel()); |
| 517 | ReadOnlySection = |
| 518 | Ctx->getCOFFSection(".rdata", |
| 519 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 520 | COFF::IMAGE_SCN_MEM_READ, |
| 521 | SectionKind::getReadOnly()); |
Michael J. Spencer | 32d22ee | 2012-02-23 21:56:08 +0000 | [diff] [blame] | 522 | if (T.getOS() == Triple::Win32) { |
| 523 | StaticCtorSection = |
| 524 | Ctx->getCOFFSection(".CRT$XCU", |
| 525 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 526 | COFF::IMAGE_SCN_MEM_READ, |
| 527 | SectionKind::getReadOnly()); |
| 528 | } else { |
| 529 | StaticCtorSection = |
| 530 | Ctx->getCOFFSection(".ctors", |
| 531 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 532 | COFF::IMAGE_SCN_MEM_READ | |
| 533 | COFF::IMAGE_SCN_MEM_WRITE, |
| 534 | SectionKind::getDataRel()); |
| 535 | } |
| 536 | |
| 537 | |
Anton Korobeynikov | 371e17c | 2012-09-23 15:53:47 +0000 | [diff] [blame] | 538 | if (T.getOS() == Triple::Win32) { |
| 539 | StaticDtorSection = |
| 540 | Ctx->getCOFFSection(".CRT$XTX", |
| 541 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 542 | COFF::IMAGE_SCN_MEM_READ, |
| 543 | SectionKind::getReadOnly()); |
| 544 | } else { |
| 545 | StaticDtorSection = |
| 546 | Ctx->getCOFFSection(".dtors", |
| 547 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 548 | COFF::IMAGE_SCN_MEM_READ | |
| 549 | COFF::IMAGE_SCN_MEM_WRITE, |
| 550 | SectionKind::getDataRel()); |
| 551 | } |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 552 | |
| 553 | // FIXME: We're emitting LSDA info into a readonly section on COFF, even |
| 554 | // though it contains relocatable pointers. In PIC mode, this is probably a |
| 555 | // big runtime hit for C++ apps. Either the contents of the LSDA need to be |
| 556 | // adjusted or this should be a data section. |
Kai Nacke | 113d32c | 2013-07-08 04:43:23 +0000 | [diff] [blame] | 557 | LSDASection = |
| 558 | Ctx->getCOFFSection(".gcc_except_table", |
| 559 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 560 | COFF::IMAGE_SCN_MEM_READ, |
| 561 | SectionKind::getReadOnly()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 562 | |
| 563 | // Debug info. |
| 564 | DwarfAbbrevSection = |
| 565 | Ctx->getCOFFSection(".debug_abbrev", |
| 566 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 567 | COFF::IMAGE_SCN_MEM_READ, |
| 568 | SectionKind::getMetadata()); |
| 569 | DwarfInfoSection = |
| 570 | Ctx->getCOFFSection(".debug_info", |
| 571 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 572 | COFF::IMAGE_SCN_MEM_READ, |
| 573 | SectionKind::getMetadata()); |
| 574 | DwarfLineSection = |
| 575 | Ctx->getCOFFSection(".debug_line", |
| 576 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 577 | COFF::IMAGE_SCN_MEM_READ, |
| 578 | SectionKind::getMetadata()); |
| 579 | DwarfFrameSection = |
| 580 | Ctx->getCOFFSection(".debug_frame", |
| 581 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 582 | COFF::IMAGE_SCN_MEM_READ, |
| 583 | SectionKind::getMetadata()); |
Krzysztof Parzyszek | c5ef7ee | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 584 | DwarfPubNamesSection = |
| 585 | Ctx->getCOFFSection(".debug_pubnames", |
| 586 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 587 | COFF::IMAGE_SCN_MEM_READ, |
| 588 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 589 | DwarfPubTypesSection = |
| 590 | Ctx->getCOFFSection(".debug_pubtypes", |
| 591 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 592 | COFF::IMAGE_SCN_MEM_READ, |
| 593 | SectionKind::getMetadata()); |
| 594 | DwarfStrSection = |
| 595 | Ctx->getCOFFSection(".debug_str", |
| 596 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 597 | COFF::IMAGE_SCN_MEM_READ, |
| 598 | SectionKind::getMetadata()); |
| 599 | DwarfLocSection = |
| 600 | Ctx->getCOFFSection(".debug_loc", |
| 601 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 602 | COFF::IMAGE_SCN_MEM_READ, |
| 603 | SectionKind::getMetadata()); |
| 604 | DwarfARangesSection = |
| 605 | Ctx->getCOFFSection(".debug_aranges", |
| 606 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 607 | COFF::IMAGE_SCN_MEM_READ, |
| 608 | SectionKind::getMetadata()); |
| 609 | DwarfRangesSection = |
| 610 | Ctx->getCOFFSection(".debug_ranges", |
| 611 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 612 | COFF::IMAGE_SCN_MEM_READ, |
| 613 | SectionKind::getMetadata()); |
| 614 | DwarfMacroInfoSection = |
| 615 | Ctx->getCOFFSection(".debug_macinfo", |
| 616 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 617 | COFF::IMAGE_SCN_MEM_READ, |
| 618 | SectionKind::getMetadata()); |
| 619 | |
| 620 | DrectveSection = |
| 621 | Ctx->getCOFFSection(".drectve", |
| 622 | COFF::IMAGE_SCN_LNK_INFO, |
| 623 | SectionKind::getMetadata()); |
| 624 | |
| 625 | PDataSection = |
| 626 | Ctx->getCOFFSection(".pdata", |
| 627 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
Anton Korobeynikov | 0a0e50c | 2012-08-08 12:46:46 +0000 | [diff] [blame] | 628 | COFF::IMAGE_SCN_MEM_READ, |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 629 | SectionKind::getDataRel()); |
| 630 | |
| 631 | XDataSection = |
| 632 | Ctx->getCOFFSection(".xdata", |
| 633 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
Anton Korobeynikov | 0a0e50c | 2012-08-08 12:46:46 +0000 | [diff] [blame] | 634 | COFF::IMAGE_SCN_MEM_READ, |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 635 | SectionKind::getDataRel()); |
Anton Korobeynikov | d4a19b6 | 2012-02-11 17:26:53 +0000 | [diff] [blame] | 636 | TLSDataSection = |
| 637 | Ctx->getCOFFSection(".tls$", |
| 638 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 639 | COFF::IMAGE_SCN_MEM_READ | |
| 640 | COFF::IMAGE_SCN_MEM_WRITE, |
| 641 | SectionKind::getDataRel()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm, |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 645 | CodeModel::Model cm, |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 646 | MCContext &ctx) { |
| 647 | RelocM = relocm; |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 648 | CMModel = cm; |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 649 | Ctx = &ctx; |
| 650 | |
| 651 | // Common. |
| 652 | CommDirectiveSupportsAlignment = true; |
| 653 | SupportsWeakOmittedEHFrame = true; |
| 654 | IsFunctionEHFrameSymbolPrivate = true; |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 655 | |
| 656 | PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding = |
| 657 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 658 | |
Bill Wendling | 62c75ad | 2013-04-10 21:42:06 +0000 | [diff] [blame] | 659 | CompactUnwindDwarfEHFrameOnly = 0; |
| 660 | |
Eric Christopher | 09ac3d8 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 661 | EHFrameSection = 0; // Created on demand. |
| 662 | CompactUnwindSection = 0; // Used only by selected targets. |
| 663 | DwarfAccelNamesSection = 0; // Used only by selected targets. |
| 664 | DwarfAccelObjCSection = 0; // Used only by selected targets. |
| 665 | DwarfAccelNamespaceSection = 0; // Used only by selected targets. |
| 666 | DwarfAccelTypesSection = 0; // Used only by selected targets. |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 667 | |
| 668 | Triple T(TT); |
| 669 | Triple::ArchType Arch = T.getArch(); |
| 670 | // FIXME: Checking for Arch here to filter out bogus triples such as |
| 671 | // cellspu-apple-darwin. Perhaps we should fix in Triple? |
| 672 | if ((Arch == Triple::x86 || Arch == Triple::x86_64 || |
| 673 | Arch == Triple::arm || Arch == Triple::thumb || |
| 674 | Arch == Triple::ppc || Arch == Triple::ppc64 || |
| 675 | Arch == Triple::UnknownArch) && |
| 676 | (T.isOSDarwin() || T.getEnvironment() == Triple::MachO)) { |
| 677 | Env = IsMachO; |
| 678 | InitMachOMCObjectFileInfo(T); |
Evan Cheng | 36c62d3 | 2011-07-20 23:53:54 +0000 | [diff] [blame] | 679 | } else if ((Arch == Triple::x86 || Arch == Triple::x86_64) && |
Andrew Kaylor | 7bbd6e3 | 2012-10-02 18:38:34 +0000 | [diff] [blame] | 680 | (T.getEnvironment() != Triple::ELF) && |
Evan Cheng | 36c62d3 | 2011-07-20 23:53:54 +0000 | [diff] [blame] | 681 | (T.getOS() == Triple::MinGW32 || T.getOS() == Triple::Cygwin || |
| 682 | T.getOS() == Triple::Win32)) { |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 683 | Env = IsCOFF; |
| 684 | InitCOFFMCObjectFileInfo(T); |
| 685 | } else { |
| 686 | Env = IsELF; |
| 687 | InitELFMCObjectFileInfo(T); |
| 688 | } |
| 689 | } |
| 690 | |
David Chisnall | 8bb51ef | 2012-02-17 16:51:02 +0000 | [diff] [blame] | 691 | void MCObjectFileInfo::InitEHFrameSection() { |
| 692 | if (Env == IsMachO) |
| 693 | EHFrameSection = |
| 694 | Ctx->getMachOSection("__TEXT", "__eh_frame", |
| 695 | MCSectionMachO::S_COALESCED | |
| 696 | MCSectionMachO::S_ATTR_NO_TOC | |
| 697 | MCSectionMachO::S_ATTR_STRIP_STATIC_SYMS | |
| 698 | MCSectionMachO::S_ATTR_LIVE_SUPPORT, |
| 699 | SectionKind::getReadOnly()); |
| 700 | else if (Env == IsELF) |
| 701 | EHFrameSection = |
David Chisnall | bce0de4 | 2012-04-10 11:44:33 +0000 | [diff] [blame] | 702 | Ctx->getELFSection(".eh_frame", EHSectionType, |
David Chisnall | 4cbcee1 | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 703 | EHSectionFlags, |
David Chisnall | 8bb51ef | 2012-02-17 16:51:02 +0000 | [diff] [blame] | 704 | SectionKind::getDataRel()); |
| 705 | else |
| 706 | EHFrameSection = |
| 707 | Ctx->getCOFFSection(".eh_frame", |
| 708 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 709 | COFF::IMAGE_SCN_MEM_READ | |
| 710 | COFF::IMAGE_SCN_MEM_WRITE, |
| 711 | SectionKind::getDataRel()); |
| 712 | } |