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.
31 /// Metadata - Debug info sections or other metadata.
34 /// Text - Text section, used for functions and other executable code.
37 /// ReadOnly - Data that is never written to at program runtime by the
38 /// program or the dynamic linker. Things in the top-level readonly
39 /// SectionKind are not mergeable.
42 /// MergeableCString - This is a special section for nul-terminated
43 /// strings. The linker can unique the C strings, knowing their
44 /// semantics. Because it uniques based on the nul terminators, the
45 /// compiler can't put strings in this section that have embeded nuls
49 /// MergeableConst - These are sections for merging fixed-length
50 /// constants together. For example, this can be used to unique
51 /// constant pool entries etc.
54 /// MergeableConst4 - This is a section used by 4-byte constants,
55 /// for example, floats.
58 /// MergeableConst8 - This is a section used by 8-byte constants,
59 /// for example, doubles.
62 /// MergeableConst16 - This is a section used by 16-byte constants,
63 /// for example, vectors.
66 /// Writeable - This is the base of all segments that need to be written
67 /// to during program runtime.
69 /// ThreadLocal - This is the base of all TLS segments. All TLS
70 /// objects must be writeable, otherwise there is no reason for them to
73 /// ThreadBSS - Zero-initialized TLS data objects.
76 /// ThreadData - Initialized TLS data objects.
79 /// GlobalWriteableData - Writeable data that is global (not thread
82 /// BSS - Zero initialized writeable data.
85 /// DataRel - This is the most general form of data that is written
86 /// to by the program, it can have random relocations to arbitrary
90 /// DataRelLocal - This is writeable data that has a non-zero
91 /// initializer and has relocations in it, but all of the
92 /// relocations are known to be within the final linked image
93 /// the global is linked into.
96 /// DataNoRel - This is writeable data that has a non-zero
97 /// initializer, but whose initializer is known to have no
101 /// ReadOnlyWithRel - These are global variables that are never
102 /// written to by the program, but that have relocations, so they
103 /// must be stuck in a writeable section so that the dynamic linker
104 /// can write to them. If it chooses to, the dynamic linker can
105 /// mark the pages these globals end up on as read-only after it is
106 /// done with its relocation phase.
109 /// ReadOnlyWithRelLocal - This is data that is readonly by the
110 /// program, but must be writeable so that the dynamic linker
111 /// can perform relocations in it. This is used when we know
112 /// that all the relocations are to globals in this final
122 bool isMetadata() const { return K == Metadata; }
123 bool isText() const { return K == Text; }
125 bool isReadOnly() const {
126 return K == ReadOnly || K == MergeableCString || isMergeableConst();
129 bool isMergeableCString() const { return K == MergeableCString; }
130 bool isMergeableConst() const {
131 return K == MergeableConst || K == MergeableConst4 ||
132 K == MergeableConst8 || K == MergeableConst16;
135 bool isMergeableConst4() const { return K == MergeableConst4; }
136 bool isMergeableConst8() const { return K == MergeableConst8; }
137 bool isMergeableConst16() const { return K == MergeableConst16; }
139 bool isWriteable() const {
140 return isThreadLocal() || isGlobalWriteableData();
143 bool isThreadLocal() const {
144 return K == ThreadData || K == ThreadBSS;
147 bool isThreadBSS() const { return K == ThreadBSS; }
148 bool isThreadData() const { return K == ThreadData; }
150 bool isGlobalWriteableData() const {
151 return isBSS() || isDataRel() || isReadOnlyWithRel();
154 bool isBSS() const { return K == BSS; }
156 bool isDataRel() const {
157 return K == DataRel || K == DataRelLocal || K == DataNoRel;
160 bool isDataRelLocal() const {
161 return K == DataRelLocal || K == DataNoRel;
164 bool isDataNoRel() const { return K == DataNoRel; }
166 bool isReadOnlyWithRel() const {
167 return K == ReadOnlyWithRel || K == ReadOnlyWithRelLocal;
170 bool isReadOnlyWithRelLocal() const {
171 return K == ReadOnlyWithRelLocal;
174 static SectionKind get(Kind K) {
180 static SectionKind getMetadata() { return get(Metadata); }
181 static SectionKind getText() { return get(Text); }
182 static SectionKind getReadOnly() { return get(ReadOnly); }
183 static SectionKind getMergeableCString() { return get(MergeableCString); }
184 static SectionKind getMergeableConst() { return get(MergeableConst); }
185 static SectionKind getMergeableConst4() { return get(MergeableConst4); }
186 static SectionKind getMergeableConst8() { return get(MergeableConst8); }
187 static SectionKind getMergeableConst16() { return get(MergeableConst16); }
188 static SectionKind getThreadBSS() { return get(ThreadBSS); }
189 static SectionKind getThreadData() { return get(ThreadData); }
190 static SectionKind getBSS() { return get(BSS); }
191 static SectionKind getDataRel() { return get(DataRel); }
192 static SectionKind getDataRelLocal() { return get(DataRelLocal); }
193 static SectionKind getDataNoRel() { return get(DataNoRel); }
194 static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); }
195 static SectionKind getReadOnlyWithRelLocal(){
196 return get(ReadOnlyWithRelLocal);
200 } // end namespace llvm