LLVM
22.0.0git
include
llvm
MC
MCSectionMachO.h
Go to the documentation of this file.
1
//===- MCSectionMachO.h - MachO Machine Code Sections -----------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file declares the MCSectionMachO class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_MC_MCSECTIONMACHO_H
14
#define LLVM_MC_MCSECTIONMACHO_H
15
16
#include "
llvm/ADT/StringRef.h
"
17
#include "
llvm/BinaryFormat/MachO.h
"
18
#include "
llvm/MC/MCSection.h
"
19
#include "
llvm/Support/Compiler.h
"
20
21
namespace
llvm
{
22
23
/// This represents a section on a Mach-O system (used by Mac OS X). On a Mac
24
/// system, these are also described in /usr/include/mach-o/loader.h.
25
class
LLVM_ABI
MCSectionMachO
final :
public
MCSection
{
26
friend
class
MCContext
;
27
friend
class
MCAsmInfoDarwin
;
28
char
SegmentName[16];
// Not necessarily null terminated!
29
30
/// This is the SECTION_TYPE and SECTION_ATTRIBUTES field of a section, drawn
31
/// from the enums below.
32
unsigned
TypeAndAttributes;
33
34
/// The 'reserved2' field of a section, used to represent the size of stubs,
35
/// for example.
36
unsigned
Reserved2;
37
38
// The index of this section in MachObjectWriter::SectionOrder, which is
39
// different from MCSection::Ordinal.
40
unsigned
LayoutOrder = 0;
41
42
// The defining non-temporary symbol for each fragment.
43
SmallVector<const MCSymbol *, 0>
Atoms;
44
45
MCSectionMachO
(
StringRef
Segment,
StringRef
Section,
unsigned
TAA,
46
unsigned
reserved2,
SectionKind
K,
MCSymbol
*Begin);
47
public
:
48
49
StringRef
getSegmentName
()
const
{
50
// SegmentName is not necessarily null terminated!
51
if
(SegmentName[15])
52
return
StringRef
(SegmentName, 16);
53
return
StringRef
(SegmentName);
54
}
55
56
unsigned
getTypeAndAttributes
()
const
{
return
TypeAndAttributes; }
57
unsigned
getStubSize
()
const
{
return
Reserved2; }
58
59
MachO::SectionType
getType
()
const
{
60
return
static_cast<
MachO::SectionType
>
(TypeAndAttributes &
61
MachO::SECTION_TYPE);
62
}
63
bool
hasAttribute
(
unsigned
Value
)
const
{
64
return
(TypeAndAttributes &
Value
) != 0;
65
}
66
67
/// Parse the section specifier indicated by "Spec". This is a string that can
68
/// appear after a .section directive in a mach-o flavored .s file. If
69
/// successful, this fills in the specified Out parameters and returns an
70
/// empty string. When an invalid section specifier is present, this returns
71
/// an Error indicating the problem. If no TAA was parsed, TAA is not altered,
72
/// and TAAWasSet becomes false.
73
static
Error
ParseSectionSpecifier(
StringRef
Spec
,
// In.
74
StringRef
&Segment,
// Out.
75
StringRef
&Section,
// Out.
76
unsigned
&TAA,
// Out.
77
bool
&TAAParsed,
// Out.
78
unsigned
&StubSize);
// Out.
79
80
void
allocAtoms();
81
const
MCSymbol
*getAtom(
size_t
I
)
const
;
82
void
setAtom(
size_t
I
,
const
MCSymbol
*
Sym
);
83
84
unsigned
getLayoutOrder
()
const
{
return
LayoutOrder; }
85
void
setLayoutOrder
(
unsigned
Value
) { LayoutOrder =
Value
; }
86
};
87
88
}
// end namespace llvm
89
90
#endif
MachO.h
Compiler.h
LLVM_ABI
#define LLVM_ABI
Definition:
Compiler.h:213
Sym
Symbol * Sym
Definition:
ELF_riscv.cpp:479
MCSection.h
I
#define I(x, y, z)
Definition:
MD5.cpp:58
StringRef.h
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition:
Error.h:159
llvm::MCAsmInfoDarwin
Definition:
MCAsmInfoDarwin.h:21
llvm::MCContext
Context object for machine code objects.
Definition:
MCContext.h:83
llvm::MCSectionMachO
This represents a section on a Mach-O system (used by Mac OS X).
Definition:
MCSectionMachO.h:25
llvm::MCSectionMachO::getType
MachO::SectionType getType() const
Definition:
MCSectionMachO.h:59
llvm::MCSectionMachO::getSegmentName
StringRef getSegmentName() const
Definition:
MCSectionMachO.h:49
llvm::MCSectionMachO::getLayoutOrder
unsigned getLayoutOrder() const
Definition:
MCSectionMachO.h:84
llvm::MCSectionMachO::setLayoutOrder
void setLayoutOrder(unsigned Value)
Definition:
MCSectionMachO.h:85
llvm::MCSectionMachO::getTypeAndAttributes
unsigned getTypeAndAttributes() const
Definition:
MCSectionMachO.h:56
llvm::MCSectionMachO::hasAttribute
bool hasAttribute(unsigned Value) const
Definition:
MCSectionMachO.h:63
llvm::MCSectionMachO::getStubSize
unsigned getStubSize() const
Definition:
MCSectionMachO.h:57
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition:
MCSection.h:496
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition:
MCSymbol.h:42
llvm::SectionKind
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition:
SectionKind.h:22
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:
SmallVector.h:1197
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:55
llvm::Value
LLVM Value Representation.
Definition:
Value.h:75
llvm::MachO::SectionType
SectionType
These are the section type and attributes fields.
Definition:
MachO.h:122
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
llvm::Spec
Definition:
FunctionSpecialization.h:128
Generated on Sat Aug 30 2025 05:10:46 for LLVM by
1.9.6