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()); |
Eric Christopher | 328a204 | 2013-09-09 20:03:14 +0000 | [diff] [blame^] | 202 | DwarfGnuPubNamesSection = |
| 203 | Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn", |
| 204 | MCSectionMachO::S_ATTR_DEBUG, |
| 205 | SectionKind::getMetadata()); |
| 206 | DwarfGnuPubTypesSection = |
| 207 | Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt", |
| 208 | MCSectionMachO::S_ATTR_DEBUG, |
| 209 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 210 | DwarfStrSection = |
| 211 | Ctx->getMachOSection("__DWARF", "__debug_str", |
| 212 | MCSectionMachO::S_ATTR_DEBUG, |
| 213 | SectionKind::getMetadata()); |
| 214 | DwarfLocSection = |
| 215 | Ctx->getMachOSection("__DWARF", "__debug_loc", |
| 216 | MCSectionMachO::S_ATTR_DEBUG, |
| 217 | SectionKind::getMetadata()); |
| 218 | DwarfARangesSection = |
| 219 | Ctx->getMachOSection("__DWARF", "__debug_aranges", |
| 220 | MCSectionMachO::S_ATTR_DEBUG, |
| 221 | SectionKind::getMetadata()); |
| 222 | DwarfRangesSection = |
| 223 | Ctx->getMachOSection("__DWARF", "__debug_ranges", |
| 224 | MCSectionMachO::S_ATTR_DEBUG, |
| 225 | SectionKind::getMetadata()); |
| 226 | DwarfMacroInfoSection = |
| 227 | Ctx->getMachOSection("__DWARF", "__debug_macinfo", |
| 228 | MCSectionMachO::S_ATTR_DEBUG, |
| 229 | SectionKind::getMetadata()); |
| 230 | DwarfDebugInlineSection = |
| 231 | Ctx->getMachOSection("__DWARF", "__debug_inlined", |
| 232 | MCSectionMachO::S_ATTR_DEBUG, |
| 233 | SectionKind::getMetadata()); |
| 234 | |
| 235 | TLSExtraDataSection = TLSTLVSection; |
| 236 | } |
| 237 | |
| 238 | void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) { |
Rafael Espindola | 04011e84 | 2013-04-03 03:13:19 +0000 | [diff] [blame] | 239 | if (T.getArch() == Triple::mips || |
| 240 | T.getArch() == Triple::mipsel) |
| 241 | FDECFIEncoding = dwarf::DW_EH_PE_sdata4; |
| 242 | else if (T.getArch() == Triple::mips64 || |
| 243 | T.getArch() == Triple::mips64el) |
| 244 | FDECFIEncoding = dwarf::DW_EH_PE_sdata8; |
| 245 | else |
Rafael Espindola | 7a86ffb | 2013-03-15 05:51:57 +0000 | [diff] [blame] | 246 | FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 247 | |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 248 | if (T.getArch() == Triple::x86) { |
| 249 | PersonalityEncoding = (RelocM == Reloc::PIC_) |
Jim Grosbach | 946227d | 2011-11-15 16:46:22 +0000 | [diff] [blame] | 250 | ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 251 | : dwarf::DW_EH_PE_absptr; |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 252 | LSDAEncoding = (RelocM == Reloc::PIC_) |
| 253 | ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 254 | : dwarf::DW_EH_PE_absptr; |
Rafael Espindola | 7a86ffb | 2013-03-15 05:51:57 +0000 | [diff] [blame] | 255 | FDEEncoding = (RelocM == Reloc::PIC_) |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 256 | ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 257 | : dwarf::DW_EH_PE_absptr; |
| 258 | TTypeEncoding = (RelocM == Reloc::PIC_) |
Jim Grosbach | 946227d | 2011-11-15 16:46:22 +0000 | [diff] [blame] | 259 | ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
| 260 | : dwarf::DW_EH_PE_absptr; |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 261 | } else if (T.getArch() == Triple::x86_64) { |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 262 | if (RelocM == Reloc::PIC_) { |
| 263 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 264 | ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium) |
| 265 | ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); |
| 266 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | |
| 267 | (CMModel == CodeModel::Small |
| 268 | ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); |
| 269 | FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 270 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 271 | ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium) |
| 272 | ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); |
| 273 | } else { |
| 274 | PersonalityEncoding = |
| 275 | (CMModel == CodeModel::Small || CMModel == CodeModel::Medium) |
| 276 | ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; |
| 277 | LSDAEncoding = (CMModel == CodeModel::Small) |
| 278 | ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; |
| 279 | FDEEncoding = dwarf::DW_EH_PE_udata4; |
| 280 | TTypeEncoding = (CMModel == CodeModel::Small) |
| 281 | ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; |
| 282 | } |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 283 | } else if (T.getArch() == Triple::aarch64) { |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 284 | // The small model guarantees static code/data size < 4GB, but not where it |
| 285 | // will be in memory. Most of these could end up >2GB away so even a signed |
| 286 | // pc-relative 32-bit address is insufficient, theoretically. |
| 287 | if (RelocM == Reloc::PIC_) { |
| 288 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 289 | dwarf::DW_EH_PE_sdata8; |
| 290 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8; |
| 291 | FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 292 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 293 | dwarf::DW_EH_PE_sdata8; |
| 294 | } else { |
| 295 | PersonalityEncoding = dwarf::DW_EH_PE_absptr; |
| 296 | LSDAEncoding = dwarf::DW_EH_PE_absptr; |
| 297 | FDEEncoding = dwarf::DW_EH_PE_udata4; |
| 298 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 299 | } |
Bill Schmidt | f38cc38 | 2013-07-26 01:35:43 +0000 | [diff] [blame] | 300 | } else if (T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le) { |
Adhemerval Zanella | a1db5de | 2013-01-09 17:08:15 +0000 | [diff] [blame] | 301 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 302 | dwarf::DW_EH_PE_udata8; |
Adhemerval Zanella | a1db5de | 2013-01-09 17:08:15 +0000 | [diff] [blame] | 303 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8; |
| 304 | FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8; |
| 305 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 306 | dwarf::DW_EH_PE_udata8; |
Ulrich Weigand | e96e43f | 2013-05-06 16:11:12 +0000 | [diff] [blame] | 307 | } else if (T.getArch() == Triple::systemz) { |
| 308 | // All currently-defined code models guarantee that 4-byte PC-relative |
| 309 | // values will be in range. |
Ulrich Weigand | e5c8c24 | 2013-05-06 17:28:30 +0000 | [diff] [blame] | 310 | if (RelocM == Reloc::PIC_) { |
| 311 | PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 312 | dwarf::DW_EH_PE_sdata4; |
| 313 | LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 314 | FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; |
| 315 | TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | |
| 316 | dwarf::DW_EH_PE_sdata4; |
| 317 | } else { |
| 318 | PersonalityEncoding = dwarf::DW_EH_PE_absptr; |
| 319 | LSDAEncoding = dwarf::DW_EH_PE_absptr; |
| 320 | FDEEncoding = dwarf::DW_EH_PE_absptr; |
| 321 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 322 | } |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 323 | } |
| 324 | |
David Chisnall | 4cbcee1 | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 325 | // Solaris requires different flags for .eh_frame to seemingly every other |
| 326 | // platform. |
David Chisnall | bce0de4 | 2012-04-10 11:44:33 +0000 | [diff] [blame] | 327 | EHSectionType = ELF::SHT_PROGBITS; |
David Chisnall | 4cbcee1 | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 328 | EHSectionFlags = ELF::SHF_ALLOC; |
David Chisnall | bce0de4 | 2012-04-10 11:44:33 +0000 | [diff] [blame] | 329 | if (T.getOS() == Triple::Solaris) { |
| 330 | if (T.getArch() == Triple::x86_64) |
| 331 | EHSectionType = ELF::SHT_X86_64_UNWIND; |
| 332 | else |
| 333 | EHSectionFlags |= ELF::SHF_WRITE; |
| 334 | } |
David Chisnall | 4cbcee1 | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 335 | |
| 336 | |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 337 | // ELF |
| 338 | BSSSection = |
| 339 | Ctx->getELFSection(".bss", ELF::SHT_NOBITS, |
Anton Korobeynikov | 4a99f59 | 2012-01-25 22:24:19 +0000 | [diff] [blame] | 340 | ELF::SHF_WRITE | ELF::SHF_ALLOC, |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 341 | SectionKind::getBSS()); |
| 342 | |
| 343 | TextSection = |
| 344 | Ctx->getELFSection(".text", ELF::SHT_PROGBITS, |
| 345 | ELF::SHF_EXECINSTR | |
| 346 | ELF::SHF_ALLOC, |
| 347 | SectionKind::getText()); |
| 348 | |
| 349 | DataSection = |
| 350 | Ctx->getELFSection(".data", ELF::SHT_PROGBITS, |
| 351 | ELF::SHF_WRITE |ELF::SHF_ALLOC, |
| 352 | SectionKind::getDataRel()); |
| 353 | |
| 354 | ReadOnlySection = |
| 355 | Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, |
| 356 | ELF::SHF_ALLOC, |
| 357 | SectionKind::getReadOnly()); |
| 358 | |
| 359 | TLSDataSection = |
| 360 | Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS, |
| 361 | ELF::SHF_ALLOC | ELF::SHF_TLS | |
| 362 | ELF::SHF_WRITE, |
| 363 | SectionKind::getThreadData()); |
| 364 | |
| 365 | TLSBSSSection = |
| 366 | Ctx->getELFSection(".tbss", ELF::SHT_NOBITS, |
| 367 | ELF::SHF_ALLOC | ELF::SHF_TLS | |
| 368 | ELF::SHF_WRITE, |
| 369 | SectionKind::getThreadBSS()); |
| 370 | |
| 371 | DataRelSection = |
| 372 | Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS, |
| 373 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 374 | SectionKind::getDataRel()); |
| 375 | |
| 376 | DataRelLocalSection = |
| 377 | Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS, |
| 378 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 379 | SectionKind::getDataRelLocal()); |
| 380 | |
| 381 | DataRelROSection = |
| 382 | Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS, |
| 383 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 384 | SectionKind::getReadOnlyWithRel()); |
| 385 | |
| 386 | DataRelROLocalSection = |
| 387 | Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS, |
| 388 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 389 | SectionKind::getReadOnlyWithRelLocal()); |
| 390 | |
| 391 | MergeableConst4Section = |
| 392 | Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS, |
| 393 | ELF::SHF_ALLOC |ELF::SHF_MERGE, |
| 394 | SectionKind::getMergeableConst4()); |
| 395 | |
| 396 | MergeableConst8Section = |
| 397 | Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS, |
| 398 | ELF::SHF_ALLOC |ELF::SHF_MERGE, |
| 399 | SectionKind::getMergeableConst8()); |
| 400 | |
| 401 | MergeableConst16Section = |
| 402 | Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS, |
| 403 | ELF::SHF_ALLOC |ELF::SHF_MERGE, |
| 404 | SectionKind::getMergeableConst16()); |
| 405 | |
| 406 | StaticCtorSection = |
| 407 | Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS, |
| 408 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 409 | SectionKind::getDataRel()); |
| 410 | |
| 411 | StaticDtorSection = |
| 412 | Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS, |
| 413 | ELF::SHF_ALLOC |ELF::SHF_WRITE, |
| 414 | SectionKind::getDataRel()); |
| 415 | |
| 416 | // Exception Handling Sections. |
| 417 | |
| 418 | // FIXME: We're emitting LSDA info into a readonly section on ELF, even though |
| 419 | // it contains relocatable pointers. In PIC mode, this is probably a big |
| 420 | // runtime hit for C++ apps. Either the contents of the LSDA need to be |
| 421 | // adjusted or this should be a data section. |
| 422 | LSDASection = |
| 423 | Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS, |
| 424 | ELF::SHF_ALLOC, |
| 425 | SectionKind::getReadOnly()); |
| 426 | |
| 427 | // Debug Info Sections. |
| 428 | DwarfAbbrevSection = |
| 429 | Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0, |
| 430 | SectionKind::getMetadata()); |
| 431 | DwarfInfoSection = |
| 432 | Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0, |
| 433 | SectionKind::getMetadata()); |
| 434 | DwarfLineSection = |
| 435 | Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0, |
| 436 | SectionKind::getMetadata()); |
| 437 | DwarfFrameSection = |
| 438 | Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0, |
| 439 | SectionKind::getMetadata()); |
Krzysztof Parzyszek | c5ef7ee | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 440 | DwarfPubNamesSection = |
| 441 | Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0, |
| 442 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 443 | DwarfPubTypesSection = |
| 444 | Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0, |
| 445 | SectionKind::getMetadata()); |
Eric Christopher | 328a204 | 2013-09-09 20:03:14 +0000 | [diff] [blame^] | 446 | DwarfGnuPubNamesSection = |
| 447 | Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0, |
| 448 | SectionKind::getMetadata()); |
| 449 | DwarfGnuPubTypesSection = |
| 450 | Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0, |
| 451 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 452 | DwarfStrSection = |
Nick Lewycky | 5a86c5b | 2011-10-26 18:44:32 +0000 | [diff] [blame] | 453 | Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS, |
| 454 | ELF::SHF_MERGE | ELF::SHF_STRINGS, |
| 455 | SectionKind::getMergeable1ByteCString()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 456 | DwarfLocSection = |
| 457 | Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0, |
| 458 | SectionKind::getMetadata()); |
| 459 | DwarfARangesSection = |
| 460 | Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0, |
| 461 | SectionKind::getMetadata()); |
| 462 | DwarfRangesSection = |
| 463 | Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0, |
| 464 | SectionKind::getMetadata()); |
| 465 | DwarfMacroInfoSection = |
| 466 | Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0, |
| 467 | SectionKind::getMetadata()); |
Eric Christopher | ea1504d | 2012-11-28 02:49:34 +0000 | [diff] [blame] | 468 | |
| 469 | // DWARF5 Experimental Debug Info |
| 470 | |
| 471 | // Accelerator Tables |
Eric Christopher | 5b4461c | 2012-10-08 21:41:30 +0000 | [diff] [blame] | 472 | DwarfAccelNamesSection = |
| 473 | Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0, |
| 474 | SectionKind::getMetadata()); |
| 475 | DwarfAccelObjCSection = |
| 476 | Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0, |
| 477 | SectionKind::getMetadata()); |
| 478 | DwarfAccelNamespaceSection = |
| 479 | Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0, |
| 480 | SectionKind::getMetadata()); |
| 481 | DwarfAccelTypesSection = |
| 482 | Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0, |
| 483 | SectionKind::getMetadata()); |
Eric Christopher | 6acb531 | 2012-11-28 02:49:38 +0000 | [diff] [blame] | 484 | |
| 485 | // Fission Sections |
| 486 | DwarfInfoDWOSection = |
| 487 | Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0, |
| 488 | SectionKind::getMetadata()); |
Eric Christopher | 67587f4 | 2012-11-30 06:47:06 +0000 | [diff] [blame] | 489 | DwarfAbbrevDWOSection = |
| 490 | Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0, |
| 491 | SectionKind::getMetadata()); |
| 492 | DwarfStrDWOSection = |
| 493 | Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS, |
| 494 | ELF::SHF_MERGE | ELF::SHF_STRINGS, |
| 495 | SectionKind::getMergeable1ByteCString()); |
| 496 | DwarfLineDWOSection = |
| 497 | Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0, |
| 498 | SectionKind::getMetadata()); |
| 499 | DwarfLocDWOSection = |
| 500 | Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0, |
| 501 | SectionKind::getMetadata()); |
Eric Christopher | 60230ef | 2013-01-04 17:59:22 +0000 | [diff] [blame] | 502 | DwarfStrOffDWOSection = |
| 503 | Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0, |
| 504 | SectionKind::getMetadata()); |
Eric Christopher | 72f7bfb | 2013-01-15 23:56:56 +0000 | [diff] [blame] | 505 | DwarfAddrSection = |
| 506 | Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0, |
| 507 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | |
| 511 | void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) { |
| 512 | // COFF |
David Majnemer | 6aa9315 | 2013-08-13 01:23:53 +0000 | [diff] [blame] | 513 | BSSSection = |
| 514 | Ctx->getCOFFSection(".bss", |
| 515 | COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA | |
| 516 | COFF::IMAGE_SCN_MEM_READ | |
| 517 | COFF::IMAGE_SCN_MEM_WRITE, |
| 518 | SectionKind::getBSS()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 519 | TextSection = |
| 520 | Ctx->getCOFFSection(".text", |
| 521 | COFF::IMAGE_SCN_CNT_CODE | |
| 522 | COFF::IMAGE_SCN_MEM_EXECUTE | |
| 523 | COFF::IMAGE_SCN_MEM_READ, |
| 524 | SectionKind::getText()); |
| 525 | DataSection = |
| 526 | Ctx->getCOFFSection(".data", |
| 527 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 528 | COFF::IMAGE_SCN_MEM_READ | |
| 529 | COFF::IMAGE_SCN_MEM_WRITE, |
| 530 | SectionKind::getDataRel()); |
| 531 | ReadOnlySection = |
| 532 | Ctx->getCOFFSection(".rdata", |
| 533 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 534 | COFF::IMAGE_SCN_MEM_READ, |
| 535 | SectionKind::getReadOnly()); |
Michael J. Spencer | 32d22ee | 2012-02-23 21:56:08 +0000 | [diff] [blame] | 536 | if (T.getOS() == Triple::Win32) { |
| 537 | StaticCtorSection = |
| 538 | Ctx->getCOFFSection(".CRT$XCU", |
| 539 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 540 | COFF::IMAGE_SCN_MEM_READ, |
| 541 | SectionKind::getReadOnly()); |
| 542 | } else { |
| 543 | StaticCtorSection = |
| 544 | Ctx->getCOFFSection(".ctors", |
| 545 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 546 | COFF::IMAGE_SCN_MEM_READ | |
| 547 | COFF::IMAGE_SCN_MEM_WRITE, |
| 548 | SectionKind::getDataRel()); |
| 549 | } |
| 550 | |
| 551 | |
Anton Korobeynikov | 371e17c | 2012-09-23 15:53:47 +0000 | [diff] [blame] | 552 | if (T.getOS() == Triple::Win32) { |
| 553 | StaticDtorSection = |
| 554 | Ctx->getCOFFSection(".CRT$XTX", |
| 555 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 556 | COFF::IMAGE_SCN_MEM_READ, |
| 557 | SectionKind::getReadOnly()); |
| 558 | } else { |
| 559 | StaticDtorSection = |
| 560 | Ctx->getCOFFSection(".dtors", |
| 561 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 562 | COFF::IMAGE_SCN_MEM_READ | |
| 563 | COFF::IMAGE_SCN_MEM_WRITE, |
| 564 | SectionKind::getDataRel()); |
| 565 | } |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 566 | |
| 567 | // FIXME: We're emitting LSDA info into a readonly section on COFF, even |
| 568 | // though it contains relocatable pointers. In PIC mode, this is probably a |
| 569 | // big runtime hit for C++ apps. Either the contents of the LSDA need to be |
| 570 | // adjusted or this should be a data section. |
Kai Nacke | 113d32c | 2013-07-08 04:43:23 +0000 | [diff] [blame] | 571 | LSDASection = |
| 572 | Ctx->getCOFFSection(".gcc_except_table", |
| 573 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 574 | COFF::IMAGE_SCN_MEM_READ, |
| 575 | SectionKind::getReadOnly()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 576 | |
| 577 | // Debug info. |
| 578 | DwarfAbbrevSection = |
| 579 | Ctx->getCOFFSection(".debug_abbrev", |
| 580 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 581 | COFF::IMAGE_SCN_MEM_READ, |
| 582 | SectionKind::getMetadata()); |
| 583 | DwarfInfoSection = |
| 584 | Ctx->getCOFFSection(".debug_info", |
| 585 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 586 | COFF::IMAGE_SCN_MEM_READ, |
| 587 | SectionKind::getMetadata()); |
| 588 | DwarfLineSection = |
| 589 | Ctx->getCOFFSection(".debug_line", |
| 590 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 591 | COFF::IMAGE_SCN_MEM_READ, |
| 592 | SectionKind::getMetadata()); |
| 593 | DwarfFrameSection = |
| 594 | Ctx->getCOFFSection(".debug_frame", |
| 595 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 596 | COFF::IMAGE_SCN_MEM_READ, |
| 597 | SectionKind::getMetadata()); |
Krzysztof Parzyszek | c5ef7ee | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 598 | DwarfPubNamesSection = |
| 599 | Ctx->getCOFFSection(".debug_pubnames", |
| 600 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 601 | COFF::IMAGE_SCN_MEM_READ, |
| 602 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 603 | DwarfPubTypesSection = |
| 604 | Ctx->getCOFFSection(".debug_pubtypes", |
| 605 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 606 | COFF::IMAGE_SCN_MEM_READ, |
| 607 | SectionKind::getMetadata()); |
Eric Christopher | 328a204 | 2013-09-09 20:03:14 +0000 | [diff] [blame^] | 608 | DwarfPubNamesSection = |
| 609 | Ctx->getCOFFSection(".debug_gnu_pubnames", |
| 610 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 611 | COFF::IMAGE_SCN_MEM_READ, |
| 612 | SectionKind::getMetadata()); |
| 613 | DwarfPubTypesSection = |
| 614 | Ctx->getCOFFSection(".debug_gnu_pubtypes", |
| 615 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 616 | COFF::IMAGE_SCN_MEM_READ, |
| 617 | SectionKind::getMetadata()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 618 | DwarfStrSection = |
| 619 | Ctx->getCOFFSection(".debug_str", |
| 620 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 621 | COFF::IMAGE_SCN_MEM_READ, |
| 622 | SectionKind::getMetadata()); |
| 623 | DwarfLocSection = |
| 624 | Ctx->getCOFFSection(".debug_loc", |
| 625 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 626 | COFF::IMAGE_SCN_MEM_READ, |
| 627 | SectionKind::getMetadata()); |
| 628 | DwarfARangesSection = |
| 629 | Ctx->getCOFFSection(".debug_aranges", |
| 630 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 631 | COFF::IMAGE_SCN_MEM_READ, |
| 632 | SectionKind::getMetadata()); |
| 633 | DwarfRangesSection = |
| 634 | Ctx->getCOFFSection(".debug_ranges", |
| 635 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 636 | COFF::IMAGE_SCN_MEM_READ, |
| 637 | SectionKind::getMetadata()); |
| 638 | DwarfMacroInfoSection = |
| 639 | Ctx->getCOFFSection(".debug_macinfo", |
| 640 | COFF::IMAGE_SCN_MEM_DISCARDABLE | |
| 641 | COFF::IMAGE_SCN_MEM_READ, |
| 642 | SectionKind::getMetadata()); |
| 643 | |
| 644 | DrectveSection = |
| 645 | Ctx->getCOFFSection(".drectve", |
| 646 | COFF::IMAGE_SCN_LNK_INFO, |
| 647 | SectionKind::getMetadata()); |
| 648 | |
| 649 | PDataSection = |
| 650 | Ctx->getCOFFSection(".pdata", |
| 651 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
Anton Korobeynikov | 0a0e50c | 2012-08-08 12:46:46 +0000 | [diff] [blame] | 652 | COFF::IMAGE_SCN_MEM_READ, |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 653 | SectionKind::getDataRel()); |
| 654 | |
| 655 | XDataSection = |
| 656 | Ctx->getCOFFSection(".xdata", |
| 657 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
Anton Korobeynikov | 0a0e50c | 2012-08-08 12:46:46 +0000 | [diff] [blame] | 658 | COFF::IMAGE_SCN_MEM_READ, |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 659 | SectionKind::getDataRel()); |
Anton Korobeynikov | d4a19b6 | 2012-02-11 17:26:53 +0000 | [diff] [blame] | 660 | TLSDataSection = |
| 661 | Ctx->getCOFFSection(".tls$", |
| 662 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 663 | COFF::IMAGE_SCN_MEM_READ | |
| 664 | COFF::IMAGE_SCN_MEM_WRITE, |
| 665 | SectionKind::getDataRel()); |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm, |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 669 | CodeModel::Model cm, |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 670 | MCContext &ctx) { |
| 671 | RelocM = relocm; |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 672 | CMModel = cm; |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 673 | Ctx = &ctx; |
| 674 | |
| 675 | // Common. |
| 676 | CommDirectiveSupportsAlignment = true; |
| 677 | SupportsWeakOmittedEHFrame = true; |
| 678 | IsFunctionEHFrameSymbolPrivate = true; |
Evan Cheng | 203576a | 2011-07-20 19:50:42 +0000 | [diff] [blame] | 679 | |
| 680 | PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding = |
| 681 | TTypeEncoding = dwarf::DW_EH_PE_absptr; |
| 682 | |
Bill Wendling | 62c75ad | 2013-04-10 21:42:06 +0000 | [diff] [blame] | 683 | CompactUnwindDwarfEHFrameOnly = 0; |
| 684 | |
Eric Christopher | 09ac3d8 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 685 | EHFrameSection = 0; // Created on demand. |
| 686 | CompactUnwindSection = 0; // Used only by selected targets. |
| 687 | DwarfAccelNamesSection = 0; // Used only by selected targets. |
| 688 | DwarfAccelObjCSection = 0; // Used only by selected targets. |
| 689 | DwarfAccelNamespaceSection = 0; // Used only by selected targets. |
| 690 | DwarfAccelTypesSection = 0; // Used only by selected targets. |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 691 | |
| 692 | Triple T(TT); |
| 693 | Triple::ArchType Arch = T.getArch(); |
| 694 | // FIXME: Checking for Arch here to filter out bogus triples such as |
| 695 | // cellspu-apple-darwin. Perhaps we should fix in Triple? |
| 696 | if ((Arch == Triple::x86 || Arch == Triple::x86_64 || |
| 697 | Arch == Triple::arm || Arch == Triple::thumb || |
| 698 | Arch == Triple::ppc || Arch == Triple::ppc64 || |
| 699 | Arch == Triple::UnknownArch) && |
| 700 | (T.isOSDarwin() || T.getEnvironment() == Triple::MachO)) { |
| 701 | Env = IsMachO; |
| 702 | InitMachOMCObjectFileInfo(T); |
Evan Cheng | 36c62d3 | 2011-07-20 23:53:54 +0000 | [diff] [blame] | 703 | } else if ((Arch == Triple::x86 || Arch == Triple::x86_64) && |
Andrew Kaylor | 7bbd6e3 | 2012-10-02 18:38:34 +0000 | [diff] [blame] | 704 | (T.getEnvironment() != Triple::ELF) && |
Evan Cheng | 36c62d3 | 2011-07-20 23:53:54 +0000 | [diff] [blame] | 705 | (T.getOS() == Triple::MinGW32 || T.getOS() == Triple::Cygwin || |
| 706 | T.getOS() == Triple::Win32)) { |
Evan Cheng | e76a33b | 2011-07-20 05:58:47 +0000 | [diff] [blame] | 707 | Env = IsCOFF; |
| 708 | InitCOFFMCObjectFileInfo(T); |
| 709 | } else { |
| 710 | Env = IsELF; |
| 711 | InitELFMCObjectFileInfo(T); |
| 712 | } |
| 713 | } |
| 714 | |
David Chisnall | 8bb51ef | 2012-02-17 16:51:02 +0000 | [diff] [blame] | 715 | void MCObjectFileInfo::InitEHFrameSection() { |
| 716 | if (Env == IsMachO) |
| 717 | EHFrameSection = |
| 718 | Ctx->getMachOSection("__TEXT", "__eh_frame", |
| 719 | MCSectionMachO::S_COALESCED | |
| 720 | MCSectionMachO::S_ATTR_NO_TOC | |
| 721 | MCSectionMachO::S_ATTR_STRIP_STATIC_SYMS | |
| 722 | MCSectionMachO::S_ATTR_LIVE_SUPPORT, |
| 723 | SectionKind::getReadOnly()); |
| 724 | else if (Env == IsELF) |
| 725 | EHFrameSection = |
David Chisnall | bce0de4 | 2012-04-10 11:44:33 +0000 | [diff] [blame] | 726 | Ctx->getELFSection(".eh_frame", EHSectionType, |
David Chisnall | 4cbcee1 | 2012-02-17 17:31:15 +0000 | [diff] [blame] | 727 | EHSectionFlags, |
David Chisnall | 8bb51ef | 2012-02-17 16:51:02 +0000 | [diff] [blame] | 728 | SectionKind::getDataRel()); |
| 729 | else |
| 730 | EHFrameSection = |
| 731 | Ctx->getCOFFSection(".eh_frame", |
| 732 | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | |
| 733 | COFF::IMAGE_SCN_MEM_READ | |
| 734 | COFF::IMAGE_SCN_MEM_WRITE, |
| 735 | SectionKind::getDataRel()); |
| 736 | } |