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