1
//===-- llvm/Target/TargetLoweringObjectFile.h - Object Info ----*- C++ -*-===//
3
// The LLVM Compiler Infrastructure
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
8
//===----------------------------------------------------------------------===//
10
// This file implements classes used to handle lowerings specific to common
11
// object file formats.
13
//===----------------------------------------------------------------------===//
15
#ifndef LLVM_MC_SECTIONKIND_H
16
#define LLVM_MC_SECTIONKIND_H
20
/// SectionKind - This is a simple POD value that classifies the properties of
21
/// a section. A section is classified into the deepest possible
22
/// classification, and then the target maps them onto their sections based on
23
/// what capabilities they have.
25
/// The comments below describe these as if they were an inheritance hierarchy
26
/// in order to explain the predicates below.
30
/// Metadata - Debug info sections or other metadata.
33
/// Text - Text section, used for functions and other executable code.
36
/// ReadOnly - Data that is never written to at program runtime by the
37
/// program or the dynamic linker. Things in the top-level readonly
38
/// SectionKind are not mergeable.
41
/// MergableCString - Any null-terminated string which allows merging.
42
/// These values are known to end in a nul value of the specified size,
43
/// not otherwise contain a nul value, and be mergable. This allows the
44
/// linker to unique the strings if it so desires.
46
/// Mergeable1ByteCString - 1 byte mergable, null terminated, string.
47
Mergeable1ByteCString,
49
/// Mergeable2ByteCString - 2 byte mergable, null terminated, string.
50
Mergeable2ByteCString,
52
/// Mergeable4ByteCString - 4 byte mergable, null terminated, string.
53
Mergeable4ByteCString,
55
/// MergeableConst - These are sections for merging fixed-length
56
/// constants together. For example, this can be used to unique
57
/// constant pool entries etc.
60
/// MergeableConst4 - This is a section used by 4-byte constants,
61
/// for example, floats.
64
/// MergeableConst8 - This is a section used by 8-byte constants,
65
/// for example, doubles.
68
/// MergeableConst16 - This is a section used by 16-byte constants,
69
/// for example, vectors.
72
/// Writeable - This is the base of all segments that need to be written
73
/// to during program runtime.
75
/// ThreadLocal - This is the base of all TLS segments. All TLS
76
/// objects must be writeable, otherwise there is no reason for them to
79
/// ThreadBSS - Zero-initialized TLS data objects.
82
/// ThreadData - Initialized TLS data objects.
85
/// GlobalWriteableData - Writeable data that is global (not thread
88
/// BSS - Zero initialized writeable data.
91
/// BSSLocal - This is BSS (zero initialized and writable) data
92
/// which has local linkage.
95
/// BSSExtern - This is BSS data with normal external linkage.
98
/// Common - Data with common linkage. These represent tentative
99
/// definitions, which always have a zero initializer and are never
100
/// marked 'constant'.
103
/// DataRel - This is the most general form of data that is written
104
/// to by the program, it can have random relocations to arbitrary
108
/// DataRelLocal - This is writeable data that has a non-zero
109
/// initializer and has relocations in it, but all of the
110
/// relocations are known to be within the final linked image
111
/// the global is linked into.
114
/// DataNoRel - This is writeable data that has a non-zero
115
/// initializer, but whose initializer is known to have no
119
/// ReadOnlyWithRel - These are global variables that are never
120
/// written to by the program, but that have relocations, so they
121
/// must be stuck in a writeable section so that the dynamic linker
122
/// can write to them. If it chooses to, the dynamic linker can
123
/// mark the pages these globals end up on as read-only after it is
124
/// done with its relocation phase.
127
/// ReadOnlyWithRelLocal - This is data that is readonly by the
128
/// program, but must be writeable so that the dynamic linker
129
/// can perform relocations in it. This is used when we know
130
/// that all the relocations are to globals in this final
137
bool isMetadata() const { return K == Metadata; }
138
bool isText() const { return K == Text; }
140
bool isReadOnly() const {
141
return K == ReadOnly || isMergeableCString() ||
145
bool isMergeableCString() const {
146
return K == Mergeable1ByteCString || K == Mergeable2ByteCString ||
147
K == Mergeable4ByteCString;
149
bool isMergeable1ByteCString() const { return K == Mergeable1ByteCString; }
150
bool isMergeable2ByteCString() const { return K == Mergeable2ByteCString; }
151
bool isMergeable4ByteCString() const { return K == Mergeable4ByteCString; }
153
bool isMergeableConst() const {
154
return K == MergeableConst || K == MergeableConst4 ||
155
K == MergeableConst8 || K == MergeableConst16;
157
bool isMergeableConst4() const { return K == MergeableConst4; }
158
bool isMergeableConst8() const { return K == MergeableConst8; }
159
bool isMergeableConst16() const { return K == MergeableConst16; }
161
bool isWriteable() const {
162
return isThreadLocal() || isGlobalWriteableData();
165
bool isThreadLocal() const {
166
return K == ThreadData || K == ThreadBSS;
169
bool isThreadBSS() const { return K == ThreadBSS; }
170
bool isThreadData() const { return K == ThreadData; }
172
bool isGlobalWriteableData() const {
173
return isBSS() || isCommon() || isDataRel() || isReadOnlyWithRel();
176
bool isBSS() const { return K == BSS || K == BSSLocal || K == BSSExtern; }
177
bool isBSSLocal() const { return K == BSSLocal; }
178
bool isBSSExtern() const { return K == BSSExtern; }
180
bool isCommon() const { return K == Common; }
182
bool isDataRel() const {
183
return K == DataRel || K == DataRelLocal || K == DataNoRel;
186
bool isDataRelLocal() const {
187
return K == DataRelLocal || K == DataNoRel;
190
bool isDataNoRel() const { return K == DataNoRel; }
192
bool isReadOnlyWithRel() const {
193
return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal;
196
bool isReadOnlyWithRelLocal() const {
197
return K == ReadOnlyWithRelLocal;
200
static SectionKind get(Kind K) {
207
static SectionKind getMetadata() { return get(Metadata); }
208
static SectionKind getText() { return get(Text); }
209
static SectionKind getReadOnly() { return get(ReadOnly); }
210
static SectionKind getMergeable1ByteCString() {
211
return get(Mergeable1ByteCString);
213
static SectionKind getMergeable2ByteCString() {
214
return get(Mergeable2ByteCString);
216
static SectionKind getMergeable4ByteCString() {
217
return get(Mergeable4ByteCString);
219
static SectionKind getMergeableConst() { return get(MergeableConst); }
220
static SectionKind getMergeableConst4() { return get(MergeableConst4); }
221
static SectionKind getMergeableConst8() { return get(MergeableConst8); }
222
static SectionKind getMergeableConst16() { return get(MergeableConst16); }
223
static SectionKind getThreadBSS() { return get(ThreadBSS); }
224
static SectionKind getThreadData() { return get(ThreadData); }
225
static SectionKind getBSS() { return get(BSS); }
226
static SectionKind getBSSLocal() { return get(BSSLocal); }
227
static SectionKind getBSSExtern() { return get(BSSExtern); }
228
static SectionKind getCommon() { return get(Common); }
229
static SectionKind getDataRel() { return get(DataRel); }
230
static SectionKind getDataRelLocal() { return get(DataRelLocal); }
231
static SectionKind getDataNoRel() { return get(DataNoRel); }
232
static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); }
233
static SectionKind getReadOnlyWithRelLocal(){
234
return get(ReadOnlyWithRelLocal);
238
} // end namespace llvm