1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

MC: Remove superfluous section attribute flag definitions

Summary:
llvm/MC/MCSectionMachO.h and llvm/Support/MachO.h both had the same
definitions for the section flags.  Instead, grab the definitions out of
support.

No functionality change.

Reviewers: grosbach, Bigcheese, rafael

Reviewed By: rafael

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2998

llvm-svn: 203211
This commit is contained in:
David Majnemer 2014-03-07 07:36:05 +00:00
parent fe02f42eb8
commit b702f79917
12 changed files with 152 additions and 240 deletions

View File

@ -16,6 +16,7 @@
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCSection.h" #include "llvm/MC/MCSection.h"
#include "llvm/Support/MachO.h"
namespace llvm { namespace llvm {
@ -39,99 +40,6 @@ class MCSectionMachO : public MCSection {
friend class MCContext; friend class MCContext;
public: public:
/// These are the section type and attributes fields. A MachO section can
/// have only one Type, but can have any of the attributes specified.
enum : uint32_t {
// TypeAndAttributes bitmasks.
SECTION_TYPE = 0x000000FFU,
SECTION_ATTRIBUTES = 0xFFFFFF00U,
// Valid section types.
/// S_REGULAR - Regular section.
S_REGULAR = 0x00U,
/// S_ZEROFILL - Zero fill on demand section.
S_ZEROFILL = 0x01U,
/// S_CSTRING_LITERALS - Section with literal C strings.
S_CSTRING_LITERALS = 0x02U,
/// S_4BYTE_LITERALS - Section with 4 byte literals.
S_4BYTE_LITERALS = 0x03U,
/// S_8BYTE_LITERALS - Section with 8 byte literals.
S_8BYTE_LITERALS = 0x04U,
/// S_LITERAL_POINTERS - Section with pointers to literals.
S_LITERAL_POINTERS = 0x05U,
/// S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
S_NON_LAZY_SYMBOL_POINTERS = 0x06U,
/// S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers.
S_LAZY_SYMBOL_POINTERS = 0x07U,
/// S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in
/// the Reserved2 field.
S_SYMBOL_STUBS = 0x08U,
/// S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for
/// initialization.
S_MOD_INIT_FUNC_POINTERS = 0x09U,
/// S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for
/// termination.
S_MOD_TERM_FUNC_POINTERS = 0x0AU,
/// S_COALESCED - Section contains symbols that are to be coalesced.
S_COALESCED = 0x0BU,
/// S_GB_ZEROFILL - Zero fill on demand section (that can be larger than 4
/// gigabytes).
S_GB_ZEROFILL = 0x0CU,
/// S_INTERPOSING - Section with only pairs of function pointers for
/// interposing.
S_INTERPOSING = 0x0DU,
/// S_16BYTE_LITERALS - Section with only 16 byte literals.
S_16BYTE_LITERALS = 0x0EU,
/// S_DTRACE_DOF - Section contains DTrace Object Format.
S_DTRACE_DOF = 0x0FU,
/// S_LAZY_DYLIB_SYMBOL_POINTERS - Section with lazy symbol pointers to
/// lazy loaded dylibs.
S_LAZY_DYLIB_SYMBOL_POINTERS = 0x10U,
/// S_THREAD_LOCAL_REGULAR - Section with ....
S_THREAD_LOCAL_REGULAR = 0x11U,
/// S_THREAD_LOCAL_ZEROFILL - Thread local zerofill section.
S_THREAD_LOCAL_ZEROFILL = 0x12U,
/// S_THREAD_LOCAL_VARIABLES - Section with thread local variable structure
/// data.
S_THREAD_LOCAL_VARIABLES = 0x13U,
/// S_THREAD_LOCAL_VARIABLE_POINTERS - Section with ....
S_THREAD_LOCAL_VARIABLE_POINTERS = 0x14U,
/// S_THREAD_LOCAL_INIT_FUNCTION_POINTERS - Section with thread local
/// variable initialization pointers to functions.
S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15U,
LAST_KNOWN_SECTION_TYPE = S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
// Valid section attributes.
/// S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine
/// instructions.
S_ATTR_PURE_INSTRUCTIONS = 1U << 31,
/// S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be
/// in a ranlib table of contents.
S_ATTR_NO_TOC = 1U << 30,
/// S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section
/// in files with the MY_DYLDLINK flag.
S_ATTR_STRIP_STATIC_SYMS = 1U << 29,
/// S_ATTR_NO_DEAD_STRIP - No dead stripping.
S_ATTR_NO_DEAD_STRIP = 1U << 28,
/// S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks.
S_ATTR_LIVE_SUPPORT = 1U << 27,
/// S_ATTR_SELF_MODIFYING_CODE - Used with i386 code stubs written on by
/// dyld.
S_ATTR_SELF_MODIFYING_CODE = 1U << 26,
/// S_ATTR_DEBUG - A debug section.
S_ATTR_DEBUG = 1U << 25,
/// S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions.
S_ATTR_SOME_INSTRUCTIONS = 1U << 10,
/// S_ATTR_EXT_RELOC - Section has external relocation entries.
S_ATTR_EXT_RELOC = 1U << 9,
/// S_ATTR_LOC_RELOC - Section has local relocation entries.
S_ATTR_LOC_RELOC = 1U << 8
};
StringRef getSegmentName() const { StringRef getSegmentName() const {
// SegmentName is not necessarily null terminated! // SegmentName is not necessarily null terminated!
if (SegmentName[15]) if (SegmentName[15])
@ -156,7 +64,7 @@ public:
unsigned getTypeAndAttributes() const { return TypeAndAttributes; } unsigned getTypeAndAttributes() const { return TypeAndAttributes; }
unsigned getStubSize() const { return Reserved2; } unsigned getStubSize() const { return Reserved2; }
unsigned getType() const { return TypeAndAttributes & SECTION_TYPE; } unsigned getType() const { return TypeAndAttributes & MachO::SECTION_TYPE; }
bool hasAttribute(unsigned Value) const { bool hasAttribute(unsigned Value) const {
return (TypeAndAttributes & Value) != 0; return (TypeAndAttributes & Value) != 0;
} }

View File

@ -147,7 +147,9 @@ namespace llvm {
SECTION_ATTRIBUTES_SYS = 0x00ffff00u // SECTION_ATTRIBUTES_SYS SECTION_ATTRIBUTES_SYS = 0x00ffff00u // SECTION_ATTRIBUTES_SYS
}; };
enum SectionType { /// These are the section type and attributes fields. A MachO section can
/// have only one Type, but can have any of the attributes specified.
enum SectionType : uint32_t {
// Constant masks for the "flags[7:0]" field in llvm::MachO::section and // Constant masks for the "flags[7:0]" field in llvm::MachO::section and
// llvm::MachO::section_64 (mask "flags" with SECTION_TYPE) // llvm::MachO::section_64 (mask "flags" with SECTION_TYPE)
S_REGULAR = 0x00u, S_REGULAR = 0x00u,
@ -171,7 +173,9 @@ namespace llvm {
S_THREAD_LOCAL_ZEROFILL = 0x12u, S_THREAD_LOCAL_ZEROFILL = 0x12u,
S_THREAD_LOCAL_VARIABLES = 0x13u, S_THREAD_LOCAL_VARIABLES = 0x13u,
S_THREAD_LOCAL_VARIABLE_POINTERS = 0x14u, S_THREAD_LOCAL_VARIABLE_POINTERS = 0x14u,
S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15u S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15u,
LAST_KNOWN_SECTION_TYPE = S_THREAD_LOCAL_INIT_FUNCTION_POINTERS
}; };
enum : uint32_t { enum : uint32_t {

View File

@ -548,15 +548,15 @@ bool TargetLoweringObjectFileMachO::isSectionAtomizableBySymbols(
// These sections are atomized at the element boundaries without using // These sections are atomized at the element boundaries without using
// symbols. // symbols.
case MCSectionMachO::S_4BYTE_LITERALS: case MachO::S_4BYTE_LITERALS:
case MCSectionMachO::S_8BYTE_LITERALS: case MachO::S_8BYTE_LITERALS:
case MCSectionMachO::S_16BYTE_LITERALS: case MachO::S_16BYTE_LITERALS:
case MCSectionMachO::S_LITERAL_POINTERS: case MachO::S_LITERAL_POINTERS:
case MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS: case MachO::S_NON_LAZY_SYMBOL_POINTERS:
case MCSectionMachO::S_LAZY_SYMBOL_POINTERS: case MachO::S_LAZY_SYMBOL_POINTERS:
case MCSectionMachO::S_MOD_INIT_FUNC_POINTERS: case MachO::S_MOD_INIT_FUNC_POINTERS:
case MCSectionMachO::S_MOD_TERM_FUNC_POINTERS: case MachO::S_MOD_TERM_FUNC_POINTERS:
case MCSectionMachO::S_INTERPOSING: case MachO::S_INTERPOSING:
return false; return false;
} }
} }

View File

@ -34,7 +34,7 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
TextSection // .text TextSection // .text
= Ctx->getMachOSection("__TEXT", "__text", = Ctx->getMachOSection("__TEXT", "__text",
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
SectionKind::getText()); SectionKind::getText());
DataSection // .data DataSection // .data
= Ctx->getMachOSection("__DATA", "__data", 0, = Ctx->getMachOSection("__DATA", "__data", 0,
@ -45,43 +45,43 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
TLSDataSection // .tdata TLSDataSection // .tdata
= Ctx->getMachOSection("__DATA", "__thread_data", = Ctx->getMachOSection("__DATA", "__thread_data",
MCSectionMachO::S_THREAD_LOCAL_REGULAR, MachO::S_THREAD_LOCAL_REGULAR,
SectionKind::getDataRel()); SectionKind::getDataRel());
TLSBSSSection // .tbss TLSBSSSection // .tbss
= Ctx->getMachOSection("__DATA", "__thread_bss", = Ctx->getMachOSection("__DATA", "__thread_bss",
MCSectionMachO::S_THREAD_LOCAL_ZEROFILL, MachO::S_THREAD_LOCAL_ZEROFILL,
SectionKind::getThreadBSS()); SectionKind::getThreadBSS());
// TODO: Verify datarel below. // TODO: Verify datarel below.
TLSTLVSection // .tlv TLSTLVSection // .tlv
= Ctx->getMachOSection("__DATA", "__thread_vars", = Ctx->getMachOSection("__DATA", "__thread_vars",
MCSectionMachO::S_THREAD_LOCAL_VARIABLES, MachO::S_THREAD_LOCAL_VARIABLES,
SectionKind::getDataRel()); SectionKind::getDataRel());
TLSThreadInitSection TLSThreadInitSection
= Ctx->getMachOSection("__DATA", "__thread_init", = Ctx->getMachOSection("__DATA", "__thread_init",
MCSectionMachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS, MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
SectionKind::getDataRel()); SectionKind::getDataRel());
CStringSection // .cstring CStringSection // .cstring
= Ctx->getMachOSection("__TEXT", "__cstring", = Ctx->getMachOSection("__TEXT", "__cstring",
MCSectionMachO::S_CSTRING_LITERALS, MachO::S_CSTRING_LITERALS,
SectionKind::getMergeable1ByteCString()); SectionKind::getMergeable1ByteCString());
UStringSection UStringSection
= Ctx->getMachOSection("__TEXT","__ustring", 0, = Ctx->getMachOSection("__TEXT","__ustring", 0,
SectionKind::getMergeable2ByteCString()); SectionKind::getMergeable2ByteCString());
FourByteConstantSection // .literal4 FourByteConstantSection // .literal4
= Ctx->getMachOSection("__TEXT", "__literal4", = Ctx->getMachOSection("__TEXT", "__literal4",
MCSectionMachO::S_4BYTE_LITERALS, MachO::S_4BYTE_LITERALS,
SectionKind::getMergeableConst4()); SectionKind::getMergeableConst4());
EightByteConstantSection // .literal8 EightByteConstantSection // .literal8
= Ctx->getMachOSection("__TEXT", "__literal8", = Ctx->getMachOSection("__TEXT", "__literal8",
MCSectionMachO::S_8BYTE_LITERALS, MachO::S_8BYTE_LITERALS,
SectionKind::getMergeableConst8()); SectionKind::getMergeableConst8());
SixteenByteConstantSection // .literal16 SixteenByteConstantSection // .literal16
= Ctx->getMachOSection("__TEXT", "__literal16", = Ctx->getMachOSection("__TEXT", "__literal16",
MCSectionMachO::S_16BYTE_LITERALS, MachO::S_16BYTE_LITERALS,
SectionKind::getMergeableConst16()); SectionKind::getMergeableConst16());
ReadOnlySection // .const ReadOnlySection // .const
@ -90,36 +90,36 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
TextCoalSection TextCoalSection
= Ctx->getMachOSection("__TEXT", "__textcoal_nt", = Ctx->getMachOSection("__TEXT", "__textcoal_nt",
MCSectionMachO::S_COALESCED | MachO::S_COALESCED |
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
SectionKind::getText()); SectionKind::getText());
ConstTextCoalSection ConstTextCoalSection
= Ctx->getMachOSection("__TEXT", "__const_coal", = Ctx->getMachOSection("__TEXT", "__const_coal",
MCSectionMachO::S_COALESCED, MachO::S_COALESCED,
SectionKind::getReadOnly()); SectionKind::getReadOnly());
ConstDataSection // .const_data ConstDataSection // .const_data
= Ctx->getMachOSection("__DATA", "__const", 0, = Ctx->getMachOSection("__DATA", "__const", 0,
SectionKind::getReadOnlyWithRel()); SectionKind::getReadOnlyWithRel());
DataCoalSection DataCoalSection
= Ctx->getMachOSection("__DATA","__datacoal_nt", = Ctx->getMachOSection("__DATA","__datacoal_nt",
MCSectionMachO::S_COALESCED, MachO::S_COALESCED,
SectionKind::getDataRel()); SectionKind::getDataRel());
DataCommonSection DataCommonSection
= Ctx->getMachOSection("__DATA","__common", = Ctx->getMachOSection("__DATA","__common",
MCSectionMachO::S_ZEROFILL, MachO::S_ZEROFILL,
SectionKind::getBSS()); SectionKind::getBSS());
DataBSSSection DataBSSSection
= Ctx->getMachOSection("__DATA","__bss", MCSectionMachO::S_ZEROFILL, = Ctx->getMachOSection("__DATA","__bss", MachO::S_ZEROFILL,
SectionKind::getBSS()); SectionKind::getBSS());
LazySymbolPointerSection LazySymbolPointerSection
= Ctx->getMachOSection("__DATA", "__la_symbol_ptr", = Ctx->getMachOSection("__DATA", "__la_symbol_ptr",
MCSectionMachO::S_LAZY_SYMBOL_POINTERS, MachO::S_LAZY_SYMBOL_POINTERS,
SectionKind::getMetadata()); SectionKind::getMetadata());
NonLazySymbolPointerSection NonLazySymbolPointerSection
= Ctx->getMachOSection("__DATA", "__nl_symbol_ptr", = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr",
MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS, MachO::S_NON_LAZY_SYMBOL_POINTERS,
SectionKind::getMetadata()); SectionKind::getMetadata());
if (RelocM == Reloc::Static) { if (RelocM == Reloc::Static) {
@ -132,11 +132,11 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
} else { } else {
StaticCtorSection StaticCtorSection
= Ctx->getMachOSection("__DATA", "__mod_init_func", = Ctx->getMachOSection("__DATA", "__mod_init_func",
MCSectionMachO::S_MOD_INIT_FUNC_POINTERS, MachO::S_MOD_INIT_FUNC_POINTERS,
SectionKind::getDataRel()); SectionKind::getDataRel());
StaticDtorSection StaticDtorSection
= Ctx->getMachOSection("__DATA", "__mod_term_func", = Ctx->getMachOSection("__DATA", "__mod_term_func",
MCSectionMachO::S_MOD_TERM_FUNC_POINTERS, MachO::S_MOD_TERM_FUNC_POINTERS,
SectionKind::getDataRel()); SectionKind::getDataRel());
} }
@ -149,7 +149,7 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6)) { if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6)) {
CompactUnwindSection = CompactUnwindSection =
Ctx->getMachOSection("__LD", "__compact_unwind", Ctx->getMachOSection("__LD", "__compact_unwind",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getReadOnly()); SectionKind::getReadOnly());
if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86) if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)
@ -159,77 +159,77 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
// Debug Information. // Debug Information.
DwarfAccelNamesSection = DwarfAccelNamesSection =
Ctx->getMachOSection("__DWARF", "__apple_names", Ctx->getMachOSection("__DWARF", "__apple_names",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfAccelObjCSection = DwarfAccelObjCSection =
Ctx->getMachOSection("__DWARF", "__apple_objc", Ctx->getMachOSection("__DWARF", "__apple_objc",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
// 16 character section limit... // 16 character section limit...
DwarfAccelNamespaceSection = DwarfAccelNamespaceSection =
Ctx->getMachOSection("__DWARF", "__apple_namespac", Ctx->getMachOSection("__DWARF", "__apple_namespac",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfAccelTypesSection = DwarfAccelTypesSection =
Ctx->getMachOSection("__DWARF", "__apple_types", Ctx->getMachOSection("__DWARF", "__apple_types",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfAbbrevSection = DwarfAbbrevSection =
Ctx->getMachOSection("__DWARF", "__debug_abbrev", Ctx->getMachOSection("__DWARF", "__debug_abbrev",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfInfoSection = DwarfInfoSection =
Ctx->getMachOSection("__DWARF", "__debug_info", Ctx->getMachOSection("__DWARF", "__debug_info",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfLineSection = DwarfLineSection =
Ctx->getMachOSection("__DWARF", "__debug_line", Ctx->getMachOSection("__DWARF", "__debug_line",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfFrameSection = DwarfFrameSection =
Ctx->getMachOSection("__DWARF", "__debug_frame", Ctx->getMachOSection("__DWARF", "__debug_frame",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfPubNamesSection = DwarfPubNamesSection =
Ctx->getMachOSection("__DWARF", "__debug_pubnames", Ctx->getMachOSection("__DWARF", "__debug_pubnames",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfPubTypesSection = DwarfPubTypesSection =
Ctx->getMachOSection("__DWARF", "__debug_pubtypes", Ctx->getMachOSection("__DWARF", "__debug_pubtypes",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfGnuPubNamesSection = DwarfGnuPubNamesSection =
Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn", Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfGnuPubTypesSection = DwarfGnuPubTypesSection =
Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt", Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfStrSection = DwarfStrSection =
Ctx->getMachOSection("__DWARF", "__debug_str", Ctx->getMachOSection("__DWARF", "__debug_str",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfLocSection = DwarfLocSection =
Ctx->getMachOSection("__DWARF", "__debug_loc", Ctx->getMachOSection("__DWARF", "__debug_loc",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfARangesSection = DwarfARangesSection =
Ctx->getMachOSection("__DWARF", "__debug_aranges", Ctx->getMachOSection("__DWARF", "__debug_aranges",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfRangesSection = DwarfRangesSection =
Ctx->getMachOSection("__DWARF", "__debug_ranges", Ctx->getMachOSection("__DWARF", "__debug_ranges",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfMacroInfoSection = DwarfMacroInfoSection =
Ctx->getMachOSection("__DWARF", "__debug_macinfo", Ctx->getMachOSection("__DWARF", "__debug_macinfo",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfDebugInlineSection = DwarfDebugInlineSection =
Ctx->getMachOSection("__DWARF", "__debug_inlined", Ctx->getMachOSection("__DWARF", "__debug_inlined",
MCSectionMachO::S_ATTR_DEBUG, MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
StackMapSection = StackMapSection =
Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps", 0, Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps", 0,
@ -765,10 +765,10 @@ void MCObjectFileInfo::InitEHFrameSection() {
if (Env == IsMachO) if (Env == IsMachO)
EHFrameSection = EHFrameSection =
Ctx->getMachOSection("__TEXT", "__eh_frame", Ctx->getMachOSection("__TEXT", "__eh_frame",
MCSectionMachO::S_COALESCED | MachO::S_COALESCED |
MCSectionMachO::S_ATTR_NO_TOC | MachO::S_ATTR_NO_TOC |
MCSectionMachO::S_ATTR_STRIP_STATIC_SYMS | MachO::S_ATTR_STRIP_STATIC_SYMS |
MCSectionMachO::S_ATTR_LIVE_SUPPORT, MachO::S_ATTR_LIVE_SUPPORT,
SectionKind::getReadOnly()); SectionKind::getReadOnly());
else if (Env == IsELF) else if (Env == IsELF)
EHFrameSection = EHFrameSection =

View File

@ -195,19 +195,19 @@ public:
} }
bool ParseSectionDirectiveCString(StringRef, SMLoc) { bool ParseSectionDirectiveCString(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT","__cstring", return ParseSectionSwitch("__TEXT","__cstring",
MCSectionMachO::S_CSTRING_LITERALS); MachO::S_CSTRING_LITERALS);
} }
bool ParseSectionDirectiveLiteral4(StringRef, SMLoc) { bool ParseSectionDirectiveLiteral4(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT", "__literal4", return ParseSectionSwitch("__TEXT", "__literal4",
MCSectionMachO::S_4BYTE_LITERALS, 4); MachO::S_4BYTE_LITERALS, 4);
} }
bool ParseSectionDirectiveLiteral8(StringRef, SMLoc) { bool ParseSectionDirectiveLiteral8(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT", "__literal8", return ParseSectionSwitch("__TEXT", "__literal8",
MCSectionMachO::S_8BYTE_LITERALS, 8); MachO::S_8BYTE_LITERALS, 8);
} }
bool ParseSectionDirectiveLiteral16(StringRef, SMLoc) { bool ParseSectionDirectiveLiteral16(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT","__literal16", return ParseSectionSwitch("__TEXT","__literal16",
MCSectionMachO::S_16BYTE_LITERALS, 16); MachO::S_16BYTE_LITERALS, 16);
} }
bool ParseSectionDirectiveConstructor(StringRef, SMLoc) { bool ParseSectionDirectiveConstructor(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT","__constructor"); return ParseSectionSwitch("__TEXT","__constructor");
@ -223,15 +223,15 @@ public:
} }
bool ParseSectionDirectiveSymbolStub(StringRef, SMLoc) { bool ParseSectionDirectiveSymbolStub(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT","__symbol_stub", return ParseSectionSwitch("__TEXT","__symbol_stub",
MCSectionMachO::S_SYMBOL_STUBS | MachO::S_SYMBOL_STUBS |
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
// FIXME: Different on PPC and ARM. // FIXME: Different on PPC and ARM.
0, 16); 0, 16);
} }
bool ParseSectionDirectivePICSymbolStub(StringRef, SMLoc) { bool ParseSectionDirectivePICSymbolStub(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT","__picsymbol_stub", return ParseSectionSwitch("__TEXT","__picsymbol_stub",
MCSectionMachO::S_SYMBOL_STUBS | MachO::S_SYMBOL_STUBS |
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 0, 26); MachO::S_ATTR_PURE_INSTRUCTIONS, 0, 26);
} }
bool ParseSectionDirectiveData(StringRef, SMLoc) { bool ParseSectionDirectiveData(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__data"); return ParseSectionSwitch("__DATA", "__data");
@ -241,115 +241,115 @@ public:
} }
bool ParseSectionDirectiveNonLazySymbolPointers(StringRef, SMLoc) { bool ParseSectionDirectiveNonLazySymbolPointers(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__nl_symbol_ptr", return ParseSectionSwitch("__DATA", "__nl_symbol_ptr",
MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS, 4); MachO::S_NON_LAZY_SYMBOL_POINTERS, 4);
} }
bool ParseSectionDirectiveLazySymbolPointers(StringRef, SMLoc) { bool ParseSectionDirectiveLazySymbolPointers(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__la_symbol_ptr", return ParseSectionSwitch("__DATA", "__la_symbol_ptr",
MCSectionMachO::S_LAZY_SYMBOL_POINTERS, 4); MachO::S_LAZY_SYMBOL_POINTERS, 4);
} }
bool ParseSectionDirectiveDyld(StringRef, SMLoc) { bool ParseSectionDirectiveDyld(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__dyld"); return ParseSectionSwitch("__DATA", "__dyld");
} }
bool ParseSectionDirectiveModInitFunc(StringRef, SMLoc) { bool ParseSectionDirectiveModInitFunc(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__mod_init_func", return ParseSectionSwitch("__DATA", "__mod_init_func",
MCSectionMachO::S_MOD_INIT_FUNC_POINTERS, 4); MachO::S_MOD_INIT_FUNC_POINTERS, 4);
} }
bool ParseSectionDirectiveModTermFunc(StringRef, SMLoc) { bool ParseSectionDirectiveModTermFunc(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__mod_term_func", return ParseSectionSwitch("__DATA", "__mod_term_func",
MCSectionMachO::S_MOD_TERM_FUNC_POINTERS, 4); MachO::S_MOD_TERM_FUNC_POINTERS, 4);
} }
bool ParseSectionDirectiveConstData(StringRef, SMLoc) { bool ParseSectionDirectiveConstData(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__const"); return ParseSectionSwitch("__DATA", "__const");
} }
bool ParseSectionDirectiveObjCClass(StringRef, SMLoc) { bool ParseSectionDirectiveObjCClass(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__class", return ParseSectionSwitch("__OBJC", "__class",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCMetaClass(StringRef, SMLoc) { bool ParseSectionDirectiveObjCMetaClass(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__meta_class", return ParseSectionSwitch("__OBJC", "__meta_class",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCCatClsMeth(StringRef, SMLoc) { bool ParseSectionDirectiveObjCCatClsMeth(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__cat_cls_meth", return ParseSectionSwitch("__OBJC", "__cat_cls_meth",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCCatInstMeth(StringRef, SMLoc) { bool ParseSectionDirectiveObjCCatInstMeth(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__cat_inst_meth", return ParseSectionSwitch("__OBJC", "__cat_inst_meth",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCProtocol(StringRef, SMLoc) { bool ParseSectionDirectiveObjCProtocol(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__protocol", return ParseSectionSwitch("__OBJC", "__protocol",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCStringObject(StringRef, SMLoc) { bool ParseSectionDirectiveObjCStringObject(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__string_object", return ParseSectionSwitch("__OBJC", "__string_object",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCClsMeth(StringRef, SMLoc) { bool ParseSectionDirectiveObjCClsMeth(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__cls_meth", return ParseSectionSwitch("__OBJC", "__cls_meth",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCInstMeth(StringRef, SMLoc) { bool ParseSectionDirectiveObjCInstMeth(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__inst_meth", return ParseSectionSwitch("__OBJC", "__inst_meth",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCClsRefs(StringRef, SMLoc) { bool ParseSectionDirectiveObjCClsRefs(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__cls_refs", return ParseSectionSwitch("__OBJC", "__cls_refs",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP | MachO::S_ATTR_NO_DEAD_STRIP |
MCSectionMachO::S_LITERAL_POINTERS, 4); MachO::S_LITERAL_POINTERS, 4);
} }
bool ParseSectionDirectiveObjCMessageRefs(StringRef, SMLoc) { bool ParseSectionDirectiveObjCMessageRefs(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__message_refs", return ParseSectionSwitch("__OBJC", "__message_refs",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP | MachO::S_ATTR_NO_DEAD_STRIP |
MCSectionMachO::S_LITERAL_POINTERS, 4); MachO::S_LITERAL_POINTERS, 4);
} }
bool ParseSectionDirectiveObjCSymbols(StringRef, SMLoc) { bool ParseSectionDirectiveObjCSymbols(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__symbols", return ParseSectionSwitch("__OBJC", "__symbols",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCCategory(StringRef, SMLoc) { bool ParseSectionDirectiveObjCCategory(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__category", return ParseSectionSwitch("__OBJC", "__category",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCClassVars(StringRef, SMLoc) { bool ParseSectionDirectiveObjCClassVars(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__class_vars", return ParseSectionSwitch("__OBJC", "__class_vars",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCInstanceVars(StringRef, SMLoc) { bool ParseSectionDirectiveObjCInstanceVars(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__instance_vars", return ParseSectionSwitch("__OBJC", "__instance_vars",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCModuleInfo(StringRef, SMLoc) { bool ParseSectionDirectiveObjCModuleInfo(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__module_info", return ParseSectionSwitch("__OBJC", "__module_info",
MCSectionMachO::S_ATTR_NO_DEAD_STRIP); MachO::S_ATTR_NO_DEAD_STRIP);
} }
bool ParseSectionDirectiveObjCClassNames(StringRef, SMLoc) { bool ParseSectionDirectiveObjCClassNames(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT", "__cstring", return ParseSectionSwitch("__TEXT", "__cstring",
MCSectionMachO::S_CSTRING_LITERALS); MachO::S_CSTRING_LITERALS);
} }
bool ParseSectionDirectiveObjCMethVarTypes(StringRef, SMLoc) { bool ParseSectionDirectiveObjCMethVarTypes(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT", "__cstring", return ParseSectionSwitch("__TEXT", "__cstring",
MCSectionMachO::S_CSTRING_LITERALS); MachO::S_CSTRING_LITERALS);
} }
bool ParseSectionDirectiveObjCMethVarNames(StringRef, SMLoc) { bool ParseSectionDirectiveObjCMethVarNames(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT", "__cstring", return ParseSectionSwitch("__TEXT", "__cstring",
MCSectionMachO::S_CSTRING_LITERALS); MachO::S_CSTRING_LITERALS);
} }
bool ParseSectionDirectiveObjCSelectorStrs(StringRef, SMLoc) { bool ParseSectionDirectiveObjCSelectorStrs(StringRef, SMLoc) {
return ParseSectionSwitch("__OBJC", "__selector_strs", return ParseSectionSwitch("__OBJC", "__selector_strs",
MCSectionMachO::S_CSTRING_LITERALS); MachO::S_CSTRING_LITERALS);
} }
bool ParseSectionDirectiveTData(StringRef, SMLoc) { bool ParseSectionDirectiveTData(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__thread_data", return ParseSectionSwitch("__DATA", "__thread_data",
MCSectionMachO::S_THREAD_LOCAL_REGULAR); MachO::S_THREAD_LOCAL_REGULAR);
} }
bool ParseSectionDirectiveText(StringRef, SMLoc) { bool ParseSectionDirectiveText(StringRef, SMLoc) {
return ParseSectionSwitch("__TEXT", "__text", return ParseSectionSwitch("__TEXT", "__text",
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS); MachO::S_ATTR_PURE_INSTRUCTIONS);
} }
bool ParseSectionDirectiveTLV(StringRef, SMLoc) { bool ParseSectionDirectiveTLV(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__thread_vars", return ParseSectionSwitch("__DATA", "__thread_vars",
MCSectionMachO::S_THREAD_LOCAL_VARIABLES); MachO::S_THREAD_LOCAL_VARIABLES);
} }
bool ParseSectionDirectiveIdent(StringRef, SMLoc) { bool ParseSectionDirectiveIdent(StringRef, SMLoc) {
// Darwin silently ignores the .ident directive. // Darwin silently ignores the .ident directive.
@ -358,7 +358,7 @@ public:
} }
bool ParseSectionDirectiveThreadInitFunc(StringRef, SMLoc) { bool ParseSectionDirectiveThreadInitFunc(StringRef, SMLoc) {
return ParseSectionSwitch("__DATA", "__thread_init", return ParseSectionSwitch("__DATA", "__thread_init",
MCSectionMachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS); MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS);
} }
}; };
@ -374,7 +374,7 @@ bool DarwinAsmParser::ParseSectionSwitch(const char *Segment,
Lex(); Lex();
// FIXME: Arch specific. // FIXME: Arch specific.
bool isText = TAA & MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS; bool isText = TAA & MachO::S_ATTR_PURE_INSTRUCTIONS;
getStreamer().SwitchSection(getContext().getMachOSection( getStreamer().SwitchSection(getContext().getMachOSection(
Segment, Section, TAA, StubSize, Segment, Section, TAA, StubSize,
isText ? SectionKind::getText() isText ? SectionKind::getText()
@ -429,9 +429,9 @@ bool DarwinAsmParser::ParseDirectiveIndirectSymbol(StringRef, SMLoc Loc) {
const MCSectionMachO *Current = static_cast<const MCSectionMachO*>( const MCSectionMachO *Current = static_cast<const MCSectionMachO*>(
getStreamer().getCurrentSection().first); getStreamer().getCurrentSection().first);
unsigned SectionType = Current->getType(); unsigned SectionType = Current->getType();
if (SectionType != MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS && if (SectionType != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
SectionType != MCSectionMachO::S_LAZY_SYMBOL_POINTERS && SectionType != MachO::S_LAZY_SYMBOL_POINTERS &&
SectionType != MCSectionMachO::S_SYMBOL_STUBS) SectionType != MachO::S_SYMBOL_STUBS)
return Error(Loc, "indirect symbol not in a symbol pointer or stub " return Error(Loc, "indirect symbol not in a symbol pointer or stub "
"section"); "section");
@ -729,7 +729,7 @@ bool DarwinAsmParser::ParseDirectiveTBSS(StringRef, SMLoc) {
getStreamer().EmitTBSSSymbol(getContext().getMachOSection( getStreamer().EmitTBSSSymbol(getContext().getMachOSection(
"__DATA", "__thread_bss", "__DATA", "__thread_bss",
MCSectionMachO::S_THREAD_LOCAL_ZEROFILL, MachO::S_THREAD_LOCAL_ZEROFILL,
0, SectionKind::getThreadBSS()), 0, SectionKind::getThreadBSS()),
Sym, Size, 1 << Pow2Alignment); Sym, Size, 1 << Pow2Alignment);
@ -758,7 +758,7 @@ bool DarwinAsmParser::ParseDirectiveZerofill(StringRef, SMLoc) {
if (getLexer().is(AsmToken::EndOfStatement)) { if (getLexer().is(AsmToken::EndOfStatement)) {
// Create the zerofill section but no symbol // Create the zerofill section but no symbol
getStreamer().EmitZerofill(getContext().getMachOSection( getStreamer().EmitZerofill(getContext().getMachOSection(
Segment, Section, MCSectionMachO::S_ZEROFILL, Segment, Section, MachO::S_ZEROFILL,
0, SectionKind::getBSS())); 0, SectionKind::getBSS()));
return false; return false;
} }
@ -816,7 +816,7 @@ bool DarwinAsmParser::ParseDirectiveZerofill(StringRef, SMLoc) {
// //
// FIXME: Arch specific. // FIXME: Arch specific.
getStreamer().EmitZerofill(getContext().getMachOSection( getStreamer().EmitZerofill(getContext().getMachOSection(
Segment, Section, MCSectionMachO::S_ZEROFILL, Segment, Section, MachO::S_ZEROFILL,
0, SectionKind::getBSS()), 0, SectionKind::getBSS()),
Sym, Size, 1 << Pow2Alignment); Sym, Size, 1 << Pow2Alignment);

View File

@ -18,7 +18,7 @@ using namespace llvm;
/// section type list. /// section type list.
static const struct { static const struct {
const char *AssemblerName, *EnumName; const char *AssemblerName, *EnumName;
} SectionTypeDescriptors[MCSectionMachO::LAST_KNOWN_SECTION_TYPE+1] = { } SectionTypeDescriptors[MachO::LAST_KNOWN_SECTION_TYPE+1] = {
{ "regular", "S_REGULAR" }, // 0x00 { "regular", "S_REGULAR" }, // 0x00
{ 0, "S_ZEROFILL" }, // 0x01 { 0, "S_ZEROFILL" }, // 0x01
{ "cstring_literals", "S_CSTRING_LITERALS" }, // 0x02 { "cstring_literals", "S_CSTRING_LITERALS" }, // 0x02
@ -55,7 +55,7 @@ static const struct {
const char *AssemblerName, *EnumName; const char *AssemblerName, *EnumName;
} SectionAttrDescriptors[] = { } SectionAttrDescriptors[] = {
#define ENTRY(ASMNAME, ENUM) \ #define ENTRY(ASMNAME, ENUM) \
{ MCSectionMachO::ENUM, ASMNAME, #ENUM }, { MachO::ENUM, ASMNAME, #ENUM },
ENTRY("pure_instructions", S_ATTR_PURE_INSTRUCTIONS) ENTRY("pure_instructions", S_ATTR_PURE_INSTRUCTIONS)
ENTRY("no_toc", S_ATTR_NO_TOC) ENTRY("no_toc", S_ATTR_NO_TOC)
ENTRY("strip_static_syms", S_ATTR_STRIP_STATIC_SYMS) ENTRY("strip_static_syms", S_ATTR_STRIP_STATIC_SYMS)
@ -102,8 +102,8 @@ void MCSectionMachO::PrintSwitchToSection(const MCAsmInfo &MAI,
return; return;
} }
unsigned SectionType = TAA & MCSectionMachO::SECTION_TYPE; unsigned SectionType = getType();
assert(SectionType <= MCSectionMachO::LAST_KNOWN_SECTION_TYPE && assert(SectionType <= MachO::LAST_KNOWN_SECTION_TYPE &&
"Invalid SectionType specified!"); "Invalid SectionType specified!");
if (SectionTypeDescriptors[SectionType].AssemblerName) { if (SectionTypeDescriptors[SectionType].AssemblerName) {
@ -116,7 +116,7 @@ void MCSectionMachO::PrintSwitchToSection(const MCAsmInfo &MAI,
} }
// If we don't have any attributes, we're done. // If we don't have any attributes, we're done.
unsigned SectionAttrs = TAA & MCSectionMachO::SECTION_ATTRIBUTES; unsigned SectionAttrs = TAA & MachO::SECTION_ATTRIBUTES;
if (SectionAttrs == 0) { if (SectionAttrs == 0) {
// If we have a S_SYMBOL_STUBS size specified, print it along with 'none' as // If we have a S_SYMBOL_STUBS size specified, print it along with 'none' as
// the attribute specifier. // the attribute specifier.
@ -155,13 +155,13 @@ void MCSectionMachO::PrintSwitchToSection(const MCAsmInfo &MAI,
} }
bool MCSectionMachO::UseCodeAlign() const { bool MCSectionMachO::UseCodeAlign() const {
return hasAttribute(MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS); return hasAttribute(MachO::S_ATTR_PURE_INSTRUCTIONS);
} }
bool MCSectionMachO::isVirtualSection() const { bool MCSectionMachO::isVirtualSection() const {
return (getType() == MCSectionMachO::S_ZEROFILL || return (getType() == MachO::S_ZEROFILL ||
getType() == MCSectionMachO::S_GB_ZEROFILL || getType() == MachO::S_GB_ZEROFILL ||
getType() == MCSectionMachO::S_THREAD_LOCAL_ZEROFILL); getType() == MachO::S_THREAD_LOCAL_ZEROFILL);
} }
/// StripSpaces - This removes leading and trailing spaces from the StringRef. /// StripSpaces - This removes leading and trailing spaces from the StringRef.
@ -228,13 +228,13 @@ std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec, // In.
// Figure out which section type it is. // Figure out which section type it is.
unsigned TypeID; unsigned TypeID;
for (TypeID = 0; TypeID !=MCSectionMachO::LAST_KNOWN_SECTION_TYPE+1; ++TypeID) for (TypeID = 0; TypeID != MachO::LAST_KNOWN_SECTION_TYPE + 1; ++TypeID)
if (SectionTypeDescriptors[TypeID].AssemblerName && if (SectionTypeDescriptors[TypeID].AssemblerName &&
SectionType == SectionTypeDescriptors[TypeID].AssemblerName) SectionType == SectionTypeDescriptors[TypeID].AssemblerName)
break; break;
// If we didn't find the section type, reject it. // If we didn't find the section type, reject it.
if (TypeID > MCSectionMachO::LAST_KNOWN_SECTION_TYPE) if (TypeID > MachO::LAST_KNOWN_SECTION_TYPE)
return "mach-o section specifier uses an unknown section type"; return "mach-o section specifier uses an unknown section type";
// Remember the TypeID. // Remember the TypeID.
@ -244,7 +244,7 @@ std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec, // In.
// If we have no comma after the section type, there are no attributes. // If we have no comma after the section type, there are no attributes.
if (Comma.second.empty()) { if (Comma.second.empty()) {
// S_SYMBOL_STUBS always require a symbol stub size specifier. // S_SYMBOL_STUBS always require a symbol stub size specifier.
if (TAA == MCSectionMachO::S_SYMBOL_STUBS) if (TAA == MachO::S_SYMBOL_STUBS)
return "mach-o section specifier of type 'symbol_stubs' requires a size " return "mach-o section specifier of type 'symbol_stubs' requires a size "
"specifier"; "specifier";
return ""; return "";
@ -281,14 +281,14 @@ std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec, // In.
// Okay, we've parsed the section attributes, see if we have a stub size spec. // Okay, we've parsed the section attributes, see if we have a stub size spec.
if (Comma.second.empty()) { if (Comma.second.empty()) {
// S_SYMBOL_STUBS always require a symbol stub size specifier. // S_SYMBOL_STUBS always require a symbol stub size specifier.
if (TAA == MCSectionMachO::S_SYMBOL_STUBS) if (TAA == MachO::S_SYMBOL_STUBS)
return "mach-o section specifier of type 'symbol_stubs' requires a size " return "mach-o section specifier of type 'symbol_stubs' requires a size "
"specifier"; "specifier";
return ""; return "";
} }
// If we have a stub size spec, we must have a sectiontype of S_SYMBOL_STUBS. // If we have a stub size spec, we must have a sectiontype of S_SYMBOL_STUBS.
if ((TAA & MCSectionMachO::SECTION_TYPE) != MCSectionMachO::S_SYMBOL_STUBS) if ((TAA & MachO::SECTION_TYPE) != MachO::S_SYMBOL_STUBS)
return "mach-o section specifier cannot have a stub size specified because " return "mach-o section specifier cannot have a stub size specified because "
"it does not have type 'symbol_stubs'"; "it does not have type 'symbol_stubs'";

View File

@ -229,7 +229,7 @@ void MachObjectWriter::WriteSection(const MCAssembler &Asm,
unsigned Flags = Section.getTypeAndAttributes(); unsigned Flags = Section.getTypeAndAttributes();
if (SD.hasInstructions()) if (SD.hasInstructions())
Flags |= MCSectionMachO::S_ATTR_SOME_INSTRUCTIONS; Flags |= MachO::S_ATTR_SOME_INSTRUCTIONS;
assert(isPowerOf2_32(SD.getAlignment()) && "Invalid alignment!"); assert(isPowerOf2_32(SD.getAlignment()) && "Invalid alignment!");
Write32(Log2_32(SD.getAlignment())); Write32(Log2_32(SD.getAlignment()));
@ -437,9 +437,9 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
const MCSectionMachO &Section = const MCSectionMachO &Section =
cast<MCSectionMachO>(it->SectionData->getSection()); cast<MCSectionMachO>(it->SectionData->getSection());
if (Section.getType() != MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS && if (Section.getType() != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
Section.getType() != MCSectionMachO::S_LAZY_SYMBOL_POINTERS && Section.getType() != MachO::S_LAZY_SYMBOL_POINTERS &&
Section.getType() != MCSectionMachO::S_SYMBOL_STUBS) { Section.getType() != MachO::S_SYMBOL_STUBS) {
MCSymbol &Symbol = *it->Symbol; MCSymbol &Symbol = *it->Symbol;
report_fatal_error("indirect symbol '" + Symbol.getName() + report_fatal_error("indirect symbol '" + Symbol.getName() +
"' not in a symbol pointer or stub section"); "' not in a symbol pointer or stub section");
@ -453,7 +453,7 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
const MCSectionMachO &Section = const MCSectionMachO &Section =
cast<MCSectionMachO>(it->SectionData->getSection()); cast<MCSectionMachO>(it->SectionData->getSection());
if (Section.getType() != MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS) if (Section.getType() != MachO::S_NON_LAZY_SYMBOL_POINTERS)
continue; continue;
// Initialize the section indirect symbol base, if necessary. // Initialize the section indirect symbol base, if necessary.
@ -469,8 +469,8 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
const MCSectionMachO &Section = const MCSectionMachO &Section =
cast<MCSectionMachO>(it->SectionData->getSection()); cast<MCSectionMachO>(it->SectionData->getSection());
if (Section.getType() != MCSectionMachO::S_LAZY_SYMBOL_POINTERS && if (Section.getType() != MachO::S_LAZY_SYMBOL_POINTERS &&
Section.getType() != MCSectionMachO::S_SYMBOL_STUBS) Section.getType() != MachO::S_SYMBOL_STUBS)
continue; continue;
// Initialize the section indirect symbol base, if necessary. // Initialize the section indirect symbol base, if necessary.
@ -921,7 +921,7 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
// special handling. // special handling.
const MCSectionMachO &Section = const MCSectionMachO &Section =
static_cast<const MCSectionMachO&>(it->SectionData->getSection()); static_cast<const MCSectionMachO&>(it->SectionData->getSection());
if (Section.getType() == MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS) { if (Section.getType() == MachO::S_NON_LAZY_SYMBOL_POINTERS) {
// If this symbol is defined and internal, mark it as such. // If this symbol is defined and internal, mark it as such.
if (it->Symbol->isDefined() && if (it->Symbol->isDefined() &&
!Asm.getSymbolData(*it->Symbol).isExternal()) { !Asm.getSymbolData(*it->Symbol).isExternal()) {

View File

@ -422,20 +422,20 @@ void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) {
if (RelocM == Reloc::DynamicNoPIC) { if (RelocM == Reloc::DynamicNoPIC) {
const MCSection *sect = const MCSection *sect =
OutContext.getMachOSection("__TEXT", "__symbol_stub4", OutContext.getMachOSection("__TEXT", "__symbol_stub4",
MCSectionMachO::S_SYMBOL_STUBS, MachO::S_SYMBOL_STUBS,
12, SectionKind::getText()); 12, SectionKind::getText());
OutStreamer.SwitchSection(sect); OutStreamer.SwitchSection(sect);
} else { } else {
const MCSection *sect = const MCSection *sect =
OutContext.getMachOSection("__TEXT", "__picsymbolstub4", OutContext.getMachOSection("__TEXT", "__picsymbolstub4",
MCSectionMachO::S_SYMBOL_STUBS, MachO::S_SYMBOL_STUBS,
16, SectionKind::getText()); 16, SectionKind::getText());
OutStreamer.SwitchSection(sect); OutStreamer.SwitchSection(sect);
} }
const MCSection *StaticInitSect = const MCSection *StaticInitSect =
OutContext.getMachOSection("__TEXT", "__StaticInit", OutContext.getMachOSection("__TEXT", "__StaticInit",
MCSectionMachO::S_REGULAR | MachO::S_REGULAR |
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
SectionKind::getText()); SectionKind::getText());
OutStreamer.SwitchSection(StaticInitSect); OutStreamer.SwitchSection(StaticInitSect);
} }

View File

@ -865,14 +865,14 @@ void PPCDarwinAsmPrinter::EmitStartOfAsmFile(Module &M) {
if (TM.getRelocationModel() == Reloc::PIC_) { if (TM.getRelocationModel() == Reloc::PIC_) {
OutStreamer.SwitchSection( OutStreamer.SwitchSection(
OutContext.getMachOSection("__TEXT", "__picsymbolstub1", OutContext.getMachOSection("__TEXT", "__picsymbolstub1",
MCSectionMachO::S_SYMBOL_STUBS | MachO::S_SYMBOL_STUBS |
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
32, SectionKind::getText())); 32, SectionKind::getText()));
} else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) { } else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) {
OutStreamer.SwitchSection( OutStreamer.SwitchSection(
OutContext.getMachOSection("__TEXT","__symbol_stub1", OutContext.getMachOSection("__TEXT","__symbol_stub1",
MCSectionMachO::S_SYMBOL_STUBS | MachO::S_SYMBOL_STUBS |
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
16, SectionKind::getText())); 16, SectionKind::getText()));
} }
OutStreamer.SwitchSection(getObjFileLowering().getTextSection()); OutStreamer.SwitchSection(getObjFileLowering().getTextSection());
@ -904,8 +904,8 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
if (TM.getRelocationModel() == Reloc::PIC_) { if (TM.getRelocationModel() == Reloc::PIC_) {
const MCSection *StubSection = const MCSection *StubSection =
OutContext.getMachOSection("__TEXT", "__picsymbolstub1", OutContext.getMachOSection("__TEXT", "__picsymbolstub1",
MCSectionMachO::S_SYMBOL_STUBS | MachO::S_SYMBOL_STUBS |
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
32, SectionKind::getText()); 32, SectionKind::getText());
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
OutStreamer.SwitchSection(StubSection); OutStreamer.SwitchSection(StubSection);
@ -972,8 +972,8 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
const MCSection *StubSection = const MCSection *StubSection =
OutContext.getMachOSection("__TEXT","__symbol_stub1", OutContext.getMachOSection("__TEXT","__symbol_stub1",
MCSectionMachO::S_SYMBOL_STUBS | MachO::S_SYMBOL_STUBS |
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
16, SectionKind::getText()); 16, SectionKind::getText());
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
MCSymbol *Stub = Stubs[i].first; MCSymbol *Stub = Stubs[i].first;

View File

@ -758,7 +758,7 @@ public:
// //
// See <rdar://problem/4765733>. // See <rdar://problem/4765733>.
const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section); const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section);
return SMO.getType() == MCSectionMachO::S_CSTRING_LITERALS; return SMO.getType() == MachO::S_CSTRING_LITERALS;
} }
virtual bool isSectionAtomizable(const MCSection &Section) const { virtual bool isSectionAtomizable(const MCSection &Section) const {
@ -768,15 +768,15 @@ public:
default: default:
return true; return true;
case MCSectionMachO::S_4BYTE_LITERALS: case MachO::S_4BYTE_LITERALS:
case MCSectionMachO::S_8BYTE_LITERALS: case MachO::S_8BYTE_LITERALS:
case MCSectionMachO::S_16BYTE_LITERALS: case MachO::S_16BYTE_LITERALS:
case MCSectionMachO::S_LITERAL_POINTERS: case MachO::S_LITERAL_POINTERS:
case MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS: case MachO::S_NON_LAZY_SYMBOL_POINTERS:
case MCSectionMachO::S_LAZY_SYMBOL_POINTERS: case MachO::S_LAZY_SYMBOL_POINTERS:
case MCSectionMachO::S_MOD_INIT_FUNC_POINTERS: case MachO::S_MOD_INIT_FUNC_POINTERS:
case MCSectionMachO::S_MOD_TERM_FUNC_POINTERS: case MachO::S_MOD_TERM_FUNC_POINTERS:
case MCSectionMachO::S_INTERPOSING: case MachO::S_INTERPOSING:
return false; return false;
} }
} }

View File

@ -230,7 +230,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
if (Symbol->isInSection()) { if (Symbol->isInSection()) {
const MCSectionMachO &Section = static_cast<const MCSectionMachO&>( const MCSectionMachO &Section = static_cast<const MCSectionMachO&>(
Fragment->getParent()->getSection()); Fragment->getParent()->getSection());
if (Section.hasAttribute(MCSectionMachO::S_ATTR_DEBUG)) if (Section.hasAttribute(MachO::S_ATTR_DEBUG))
Base = 0; Base = 0;
} }

View File

@ -541,9 +541,9 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
if (!Stubs.empty()) { if (!Stubs.empty()) {
const MCSection *TheSection = const MCSection *TheSection =
OutContext.getMachOSection("__IMPORT", "__jump_table", OutContext.getMachOSection("__IMPORT", "__jump_table",
MCSectionMachO::S_SYMBOL_STUBS | MachO::S_SYMBOL_STUBS |
MCSectionMachO::S_ATTR_SELF_MODIFYING_CODE | MachO::S_ATTR_SELF_MODIFYING_CODE |
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
5, SectionKind::getMetadata()); 5, SectionKind::getMetadata());
OutStreamer.SwitchSection(TheSection); OutStreamer.SwitchSection(TheSection);
@ -567,7 +567,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
if (!Stubs.empty()) { if (!Stubs.empty()) {
const MCSection *TheSection = const MCSection *TheSection =
OutContext.getMachOSection("__IMPORT", "__pointers", OutContext.getMachOSection("__IMPORT", "__pointers",
MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS, MachO::S_NON_LAZY_SYMBOL_POINTERS,
SectionKind::getMetadata()); SectionKind::getMetadata());
OutStreamer.SwitchSection(TheSection); OutStreamer.SwitchSection(TheSection);