Coverage Report

Created: 2018-09-19 08:35

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/MC/MCObjectFileInfo.h
Line
Count
Source (jump to first uncovered line)
1
//===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file describes common object file formats.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_MC_MCOBJECTFILEINFO_H
15
#define LLVM_MC_MCOBJECTFILEINFO_H
16
17
#include "llvm/ADT/DenseMap.h"
18
#include "llvm/ADT/Triple.h"
19
#include "llvm/MC/MCSymbol.h"
20
#include "llvm/Support/CodeGen.h"
21
22
namespace llvm {
23
class MCContext;
24
class MCSection;
25
26
class MCObjectFileInfo {
27
protected:
28
  /// True if .comm supports alignment.  This is a hack for as long as we
29
  /// support 10.4 Tiger, whose assembler doesn't support alignment on comm.
30
  bool CommDirectiveSupportsAlignment;
31
32
  /// True if target object file supports a weak_definition of constant 0 for an
33
  /// omitted EH frame.
34
  bool SupportsWeakOmittedEHFrame;
35
36
  /// True if the target object file supports emitting a compact unwind section
37
  /// without an associated EH frame section.
38
  bool SupportsCompactUnwindWithoutEHFrame;
39
40
  /// OmitDwarfIfHaveCompactUnwind - True if the target object file
41
  /// supports having some functions with compact unwind and other with
42
  /// dwarf unwind.
43
  bool OmitDwarfIfHaveCompactUnwind;
44
45
  /// FDE CFI encoding. Controls the encoding of the begin label in the
46
  /// .eh_frame section. Unlike the LSDA encoding, personality encoding, and
47
  /// type encodings, this is something that the assembler just "knows" about
48
  /// its target
49
  unsigned FDECFIEncoding = 0;
50
51
  /// Compact unwind encoding indicating that we should emit only an EH frame.
52
  unsigned CompactUnwindDwarfEHFrameOnly;
53
54
  /// Section directive for standard text.
55
  MCSection *TextSection;
56
57
  /// Section directive for standard data.
58
  MCSection *DataSection;
59
60
  /// Section that is default initialized to zero.
61
  MCSection *BSSSection;
62
63
  /// Section that is readonly and can contain arbitrary initialized data.
64
  /// Targets are not required to have a readonly section. If they don't,
65
  /// various bits of code will fall back to using the data section for
66
  /// constants.
67
  MCSection *ReadOnlySection;
68
69
  /// If exception handling is supported by the target, this is the section the
70
  /// Language Specific Data Area information is emitted to.
71
  MCSection *LSDASection;
72
73
  /// If exception handling is supported by the target and the target can
74
  /// support a compact representation of the CIE and FDE, this is the section
75
  /// to emit them into.
76
  MCSection *CompactUnwindSection;
77
78
  // Dwarf sections for debug info.  If a target supports debug info, these must
79
  // be set.
80
  MCSection *DwarfAbbrevSection;
81
  MCSection *DwarfInfoSection;
82
  MCSection *DwarfLineSection;
83
  MCSection *DwarfLineStrSection;
84
  MCSection *DwarfFrameSection;
85
  MCSection *DwarfPubTypesSection;
86
  const MCSection *DwarfDebugInlineSection;
87
  MCSection *DwarfStrSection;
88
  MCSection *DwarfLocSection;
89
  MCSection *DwarfARangesSection;
90
  MCSection *DwarfRangesSection;
91
  MCSection *DwarfMacinfoSection;
92
  // The pubnames section is no longer generated by default.  The generation
93
  // can be enabled by a compiler flag.
94
  MCSection *DwarfPubNamesSection;
95
96
  /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
97
  /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
98
  /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
99
  /// extensions.
100
  MCSection *DwarfDebugNamesSection;
101
  MCSection *DwarfAccelNamesSection;
102
  MCSection *DwarfAccelObjCSection;
103
  MCSection *DwarfAccelNamespaceSection;
104
  MCSection *DwarfAccelTypesSection;
105
106
  // These are used for the Fission separate debug information files.
107
  MCSection *DwarfInfoDWOSection;
108
  MCSection *DwarfTypesDWOSection;
109
  MCSection *DwarfAbbrevDWOSection;
110
  MCSection *DwarfStrDWOSection;
111
  MCSection *DwarfLineDWOSection;
112
  MCSection *DwarfLocDWOSection;
113
  MCSection *DwarfStrOffDWOSection;
114
115
  /// The DWARF v5 string offset and address table sections.
116
  MCSection *DwarfStrOffSection;
117
  MCSection *DwarfAddrSection;
118
  /// The DWARF v5 range list section.
119
  MCSection *DwarfRnglistsSection;
120
121
  /// The DWARF v5 range list section for fission.
122
  MCSection *DwarfRnglistsDWOSection;
123
124
  // These are for Fission DWP files.
125
  MCSection *DwarfCUIndexSection;
126
  MCSection *DwarfTUIndexSection;
127
128
  /// Section for newer gnu pubnames.
129
  MCSection *DwarfGnuPubNamesSection;
130
  /// Section for newer gnu pubtypes.
131
  MCSection *DwarfGnuPubTypesSection;
132
133
  // Section for Swift AST
134
  MCSection *DwarfSwiftASTSection;
135
136
  MCSection *COFFDebugSymbolsSection;
137
  MCSection *COFFDebugTypesSection;
138
  MCSection *COFFGlobalTypeHashesSection;
139
140
  /// Extra TLS Variable Data section.
141
  ///
142
  /// If the target needs to put additional information for a TLS variable,
143
  /// it'll go here.
144
  MCSection *TLSExtraDataSection;
145
146
  /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
147
  MCSection *TLSDataSection; // Defaults to ".tdata".
148
149
  /// Section directive for Thread Local uninitialized data.
150
  ///
151
  /// Null if this target doesn't support a BSS section. ELF and MachO only.
152
  MCSection *TLSBSSSection; // Defaults to ".tbss".
153
154
  /// StackMap section.
155
  MCSection *StackMapSection;
156
157
  /// FaultMap section.
158
  MCSection *FaultMapSection;
159
160
  /// EH frame section.
161
  ///
162
  /// It is initialized on demand so it can be overwritten (with uniquing).
163
  MCSection *EHFrameSection;
164
165
  /// Section containing metadata on function stack sizes.
166
  MCSection *StackSizesSection;
167
  mutable DenseMap<const MCSymbol *, unsigned> StackSizesUniquing;
168
169
  // ELF specific sections.
170
  MCSection *DataRelROSection;
171
  MCSection *MergeableConst4Section;
172
  MCSection *MergeableConst8Section;
173
  MCSection *MergeableConst16Section;
174
  MCSection *MergeableConst32Section;
175
176
  // MachO specific sections.
177
178
  /// Section for thread local structure information.
179
  ///
180
  /// Contains the source code name of the variable, visibility and a pointer to
181
  /// the initial value (.tdata or .tbss).
182
  MCSection *TLSTLVSection; // Defaults to ".tlv".
183
184
  /// Section for thread local data initialization functions.
185
  const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
186
187
  MCSection *CStringSection;
188
  MCSection *UStringSection;
189
  MCSection *TextCoalSection;
190
  MCSection *ConstTextCoalSection;
191
  MCSection *ConstDataSection;
192
  MCSection *DataCoalSection;
193
  MCSection *ConstDataCoalSection;
194
  MCSection *DataCommonSection;
195
  MCSection *DataBSSSection;
196
  MCSection *FourByteConstantSection;
197
  MCSection *EightByteConstantSection;
198
  MCSection *SixteenByteConstantSection;
199
  MCSection *LazySymbolPointerSection;
200
  MCSection *NonLazySymbolPointerSection;
201
  MCSection *ThreadLocalPointerSection;
202
203
  /// COFF specific sections.
204
  MCSection *DrectveSection;
205
  MCSection *PDataSection;
206
  MCSection *XDataSection;
207
  MCSection *SXDataSection;
208
  MCSection *GFIDsSection;
209
210
public:
211
  void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
212
                            bool LargeCodeModel = false);
213
214
0
  bool getSupportsWeakOmittedEHFrame() const {
215
0
    return SupportsWeakOmittedEHFrame;
216
0
  }
217
5.64k
  bool getSupportsCompactUnwindWithoutEHFrame() const {
218
5.64k
    return SupportsCompactUnwindWithoutEHFrame;
219
5.64k
  }
220
3.20k
  bool getOmitDwarfIfHaveCompactUnwind() const {
221
3.20k
    return OmitDwarfIfHaveCompactUnwind;
222
3.20k
  }
223
224
13.7k
  bool getCommDirectiveSupportsAlignment() const {
225
13.7k
    return CommDirectiveSupportsAlignment;
226
13.7k
  }
227
228
98.9k
  unsigned getFDEEncoding() const { return FDECFIEncoding; }
229
230
130k
  unsigned getCompactUnwindDwarfEHFrameOnly() const {
231
130k
    return CompactUnwindDwarfEHFrameOnly;
232
130k
  }
233
234
52.8k
  MCSection *getTextSection() const { return TextSection; }
235
2.59k
  MCSection *getDataSection() const { return DataSection; }
236
1.22k
  MCSection *getBSSSection() const { return BSSSection; }
237
4
  MCSection *getReadOnlySection() const { return ReadOnlySection; }
238
3.56k
  MCSection *getLSDASection() const { return LSDASection; }
239
9.82k
  MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
240
6.17k
  MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
241
3.36k
  MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
242
7.48k
  MCSection *getDwarfLineSection() const { return DwarfLineSection; }
243
266
  MCSection *getDwarfLineStrSection() const { return DwarfLineStrSection; }
244
336
  MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
245
748
  MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
246
748
  MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
247
1.72k
  MCSection *getDwarfGnuPubNamesSection() const {
248
1.72k
    return DwarfGnuPubNamesSection;
249
1.72k
  }
250
1.72k
  MCSection *getDwarfGnuPubTypesSection() const {
251
1.72k
    return DwarfGnuPubTypesSection;
252
1.72k
  }
253
205
  const MCSection *getDwarfDebugInlineSection() const {
254
205
    return DwarfDebugInlineSection;
255
205
  }
256
3.47k
  MCSection *getDwarfStrSection() const { return DwarfStrSection; }
257
391
  MCSection *getDwarfLocSection() const { return DwarfLocSection; }
258
465
  MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
259
57.6k
  MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
260
16
  MCSection *getDwarfRnglistsSection() const { return DwarfRnglistsSection; }
261
2.46k
  MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
262
263
264
  MCSection *getDwarfDebugNamesSection() const {
264
264
    return DwarfDebugNamesSection;
265
264
  }
266
2.97k
  MCSection *getDwarfAccelNamesSection() const {
267
2.97k
    return DwarfAccelNamesSection;
268
2.97k
  }
269
2.97k
  MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
270
2.97k
  MCSection *getDwarfAccelNamespaceSection() const {
271
2.97k
    return DwarfAccelNamespaceSection;
272
2.97k
  }
273
2.97k
  MCSection *getDwarfAccelTypesSection() const {
274
2.97k
    return DwarfAccelTypesSection;
275
2.97k
  }
276
269
  MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
277
  MCSection *getDwarfTypesSection(uint64_t Hash) const;
278
279
  MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
279
263
  MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
280
263
  MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
281
263
  MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
282
263
  MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
283
269
  MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
284
459
  MCSection *getDwarfStrOffSection() const { return DwarfStrOffSection; }
285
275
  MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
286
0
  MCSection *getDwarfRnglistsDWOSection() const {
287
0
    return DwarfRnglistsDWOSection;
288
0
  }
289
240
  MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
290
240
  MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
291
206
  MCSection *getDwarfSwiftASTSection() const { return DwarfSwiftASTSection; }
292
293
701
  MCSection *getCOFFDebugSymbolsSection() const {
294
701
    return COFFDebugSymbolsSection;
295
701
  }
296
117
  MCSection *getCOFFDebugTypesSection() const {
297
117
    return COFFDebugTypesSection;
298
117
  }
299
2
  MCSection *getCOFFGlobalTypeHashesSection() const {
300
2
    return COFFGlobalTypeHashesSection;
301
2
  }
302
303
117
  MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
304
0
  const MCSection *getTLSDataSection() const { return TLSDataSection; }
305
103
  MCSection *getTLSBSSSection() const { return TLSBSSSection; }
306
307
58
  MCSection *getStackMapSection() const { return StackMapSection; }
308
4
  MCSection *getFaultMapSection() const { return FaultMapSection; }
309
310
  MCSection *getStackSizesSection(const MCSection &TextSec) const;
311
312
  // ELF specific sections.
313
0
  MCSection *getDataRelROSection() const { return DataRelROSection; }
314
0
  const MCSection *getMergeableConst4Section() const {
315
0
    return MergeableConst4Section;
316
0
  }
317
0
  const MCSection *getMergeableConst8Section() const {
318
0
    return MergeableConst8Section;
319
0
  }
320
0
  const MCSection *getMergeableConst16Section() const {
321
0
    return MergeableConst16Section;
322
0
  }
323
0
  const MCSection *getMergeableConst32Section() const {
324
0
    return MergeableConst32Section;
325
0
  }
326
327
  // MachO specific sections.
328
0
  const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
329
0
  const MCSection *getTLSThreadInitSection() const {
330
0
    return TLSThreadInitSection;
331
0
  }
332
0
  const MCSection *getCStringSection() const { return CStringSection; }
333
0
  const MCSection *getUStringSection() const { return UStringSection; }
334
0
  MCSection *getTextCoalSection() const { return TextCoalSection; }
335
0
  const MCSection *getConstTextCoalSection() const {
336
0
    return ConstTextCoalSection;
337
0
  }
338
0
  const MCSection *getConstDataSection() const { return ConstDataSection; }
339
0
  const MCSection *getDataCoalSection() const { return DataCoalSection; }
340
0
  const MCSection *getConstDataCoalSection() const {
341
0
    return ConstDataCoalSection;
342
0
  }
343
0
  const MCSection *getDataCommonSection() const { return DataCommonSection; }
344
6
  MCSection *getDataBSSSection() const { return DataBSSSection; }
345
0
  const MCSection *getFourByteConstantSection() const {
346
0
    return FourByteConstantSection;
347
0
  }
348
0
  const MCSection *getEightByteConstantSection() const {
349
0
    return EightByteConstantSection;
350
0
  }
351
0
  const MCSection *getSixteenByteConstantSection() const {
352
0
    return SixteenByteConstantSection;
353
0
  }
354
0
  MCSection *getLazySymbolPointerSection() const {
355
0
    return LazySymbolPointerSection;
356
0
  }
357
512
  MCSection *getNonLazySymbolPointerSection() const {
358
512
    return NonLazySymbolPointerSection;
359
512
  }
360
5
  MCSection *getThreadLocalPointerSection() const {
361
5
    return ThreadLocalPointerSection;
362
5
  }
363
364
  // COFF specific sections.
365
286
  MCSection *getDrectveSection() const { return DrectveSection; }
366
92
  MCSection *getPDataSection() const { return PDataSection; }
367
738
  MCSection *getXDataSection() const { return XDataSection; }
368
3
  MCSection *getSXDataSection() const { return SXDataSection; }
369
1
  MCSection *getGFIDsSection() const { return GFIDsSection; }
370
371
3.10k
  MCSection *getEHFrameSection() {
372
3.10k
    return EHFrameSection;
373
3.10k
  }
374
375
  enum Environment { IsMachO, IsELF, IsCOFF, IsWasm };
376
7.42M
  Environment getObjectFileType() const { return Env; }
377
378
17.0k
  bool isPositionIndependent() const { return PositionIndependent; }
379
380
private:
381
  Environment Env;
382
  bool PositionIndependent;
383
  MCContext *Ctx;
384
  Triple TT;
385
386
  void initMachOMCObjectFileInfo(const Triple &T);
387
  void initELFMCObjectFileInfo(const Triple &T, bool Large);
388
  void initCOFFMCObjectFileInfo(const Triple &T);
389
  void initWasmMCObjectFileInfo(const Triple &T);
390
391
public:
392
176k
  const Triple &getTargetTriple() const { return TT; }
393
};
394
395
} // end namespace llvm
396
397
#endif