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 /// MergeableCString - This is a special section for nul-terminated
42 /// strings. The linker can unique the C strings, knowing their
43 /// semantics. Because it uniques based on the nul terminators, the
44 /// compiler can't put strings in this section that have embeded nuls
48 /// MergeableConst - These are sections for merging fixed-length
49 /// constants together. For example, this can be used to unique
50 /// constant pool entries etc.
53 /// MergeableConst4 - This is a section used by 4-byte constants,
54 /// for example, floats.
57 /// MergeableConst8 - This is a section used by 8-byte constants,
58 /// for example, doubles.
61 /// MergeableConst16 - This is a section used by 16-byte constants,
62 /// for example, vectors.
65 /// Writeable - This is the base of all segments that need to be written
66 /// to during program runtime.
68 /// ThreadLocal - This is the base of all TLS segments. All TLS
69 /// objects must be writeable, otherwise there is no reason for them to
72 /// ThreadBSS - Zero-initialized TLS data objects.
75 /// ThreadData - Initialized TLS data objects.
78 /// GlobalWriteableData - Writeable data that is global (not thread
81 /// BSS - Zero initialized writeable data.
84 /// DataRel - This is the most general form of data that is written
85 /// to by the program, it can have random relocations to arbitrary
89 /// DataRelLocal - This is writeable data that has a non-zero
90 /// initializer and has relocations in it, but all of the
91 /// relocations are known to be within the final linked image
92 /// the global is linked into.
95 /// DataNoRel - This is writeable data that has a non-zero
96 /// initializer, but whose initializer is known to have no
100 /// ReadOnlyWithRel - These are global variables that are never
101 /// written to by the program, but that have relocations, so they
102 /// must be stuck in a writeable section so that the dynamic linker
103 /// can write to them. If it chooses to, the dynamic linker can
104 /// mark the pages these globals end up on as read-only after it is
105 /// done with its relocation phase.
108 /// ReadOnlyWithRelLocal - This is data that is readonly by the
109 /// program, but must be writeable so that the dynamic linker
110 /// can perform relocations in it. This is used when we know
111 /// that all the relocations are to globals in this final
118 bool isMetadata() const { return K == Metadata; }
119 bool isText() const { return K == Text; }
121 bool isReadOnly() const {
122 return K == ReadOnly || K == MergeableCString || isMergeableConst();
125 bool isMergeableCString() const { return K == MergeableCString; }
126 bool isMergeableConst() const {
127 return K == MergeableConst || K == MergeableConst4 ||
128 K == MergeableConst8 || K == MergeableConst16;
131 bool isMergeableConst4() const { return K == MergeableConst4; }
132 bool isMergeableConst8() const { return K == MergeableConst8; }
133 bool isMergeableConst16() const { return K == MergeableConst16; }
135 bool isWriteable() const {
136 return isThreadLocal() || isGlobalWriteableData();
139 bool isThreadLocal() const {
140 return K == ThreadData || K == ThreadBSS;
143 bool isThreadBSS() const { return K == ThreadBSS; }
144 bool isThreadData() const { return K == ThreadData; }
146 bool isGlobalWriteableData() const {
147 return isBSS() || isDataRel() || isReadOnlyWithRel();
150 bool isBSS() const { return K == BSS; }
152 bool isDataRel() const {
153 return K == DataRel || K == DataRelLocal || K == DataNoRel;
156 bool isDataRelLocal() const {
157 return K == DataRelLocal || K == DataNoRel;
160 bool isDataNoRel() const { return K == DataNoRel; }
162 bool isReadOnlyWithRel() const {
163 return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal;
166 bool isReadOnlyWithRelLocal() const {
167 return K == ReadOnlyWithRelLocal;
170 static SectionKind get(Kind K) {
177 static SectionKind getMetadata() { return get(Metadata); }
178 static SectionKind getText() { return get(Text); }
179 static SectionKind getReadOnly() { return get(ReadOnly); }
180 static SectionKind getMergeableCString() { return get(MergeableCString); }
181 static SectionKind getMergeableConst() { return get(MergeableConst); }
182 static SectionKind getMergeableConst4() { return get(MergeableConst4); }
183 static SectionKind getMergeableConst8() { return get(MergeableConst8); }
184 static SectionKind getMergeableConst16() { return get(MergeableConst16); }
185 static SectionKind getThreadBSS() { return get(ThreadBSS); }
186 static SectionKind getThreadData() { return get(ThreadData); }
187 static SectionKind getBSS() { return get(BSS); }
188 static SectionKind getDataRel() { return get(DataRel); }
189 static SectionKind getDataRelLocal() { return get(DataRelLocal); }
190 static SectionKind getDataNoRel() { return get(DataNoRel); }
191 static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); }
192 static SectionKind getReadOnlyWithRelLocal(){
193 return get(ReadOnlyWithRelLocal);
197 } // end namespace llvm