Coverage Report

Created: 2018-07-18 22:01

/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
  /// PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values
46
  /// for EH.
47
  unsigned PersonalityEncoding;
48
  unsigned LSDAEncoding;
49
  unsigned FDECFIEncoding;
50
  unsigned TTypeEncoding;
51
52
  /// Compact unwind encoding indicating that we should emit only an EH frame.
53
  unsigned CompactUnwindDwarfEHFrameOnly;
54
55
  /// Section directive for standard text.
56
  MCSection *TextSection;
57
58
  /// Section directive for standard data.
59
  MCSection *DataSection;
60
61
  /// Section that is default initialized to zero.
62
  MCSection *BSSSection;
63
64
  /// Section that is readonly and can contain arbitrary initialized data.
65
  /// Targets are not required to have a readonly section. If they don't,
66
  /// various bits of code will fall back to using the data section for
67
  /// constants.
68
  MCSection *ReadOnlySection;
69
70
  /// If exception handling is supported by the target, this is the section the
71
  /// Language Specific Data Area information is emitted to.
72
  MCSection *LSDASection;
73
74
  /// If exception handling is supported by the target and the target can
75
  /// support a compact representation of the CIE and FDE, this is the section
76
  /// to emit them into.
77
  MCSection *CompactUnwindSection;
78
79
  // Dwarf sections for debug info.  If a target supports debug info, these must
80
  // be set.
81
  MCSection *DwarfAbbrevSection;
82
  MCSection *DwarfInfoSection;
83
  MCSection *DwarfLineSection;
84
  MCSection *DwarfLineStrSection;
85
  MCSection *DwarfFrameSection;
86
  MCSection *DwarfPubTypesSection;
87
  const MCSection *DwarfDebugInlineSection;
88
  MCSection *DwarfStrSection;
89
  MCSection *DwarfLocSection;
90
  MCSection *DwarfARangesSection;
91
  MCSection *DwarfRangesSection;
92
  MCSection *DwarfMacinfoSection;
93
  // The pubnames section is no longer generated by default.  The generation
94
  // can be enabled by a compiler flag.
95
  MCSection *DwarfPubNamesSection;
96
97
  /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
98
  /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
99
  /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
100
  /// extensions.
101
  MCSection *DwarfDebugNamesSection;
102
  MCSection *DwarfAccelNamesSection;
103
  MCSection *DwarfAccelObjCSection;
104
  MCSection *DwarfAccelNamespaceSection;
105
  MCSection *DwarfAccelTypesSection;
106
107
  // These are used for the Fission separate debug information files.
108
  MCSection *DwarfInfoDWOSection;
109
  MCSection *DwarfTypesDWOSection;
110
  MCSection *DwarfAbbrevDWOSection;
111
  MCSection *DwarfStrDWOSection;
112
  MCSection *DwarfLineDWOSection;
113
  MCSection *DwarfLocDWOSection;
114
  MCSection *DwarfStrOffDWOSection;
115
116
  /// The DWARF v5 string offset and address table sections.
117
  MCSection *DwarfStrOffSection;
118
  MCSection *DwarfAddrSection;
119
  /// The DWARF v5 range list section.
120
  MCSection *DwarfRnglistsSection;
121
122
  /// The DWARF v5 range list section for fission.
123
  MCSection *DwarfRnglistsDWOSection;
124
125
  // These are for Fission DWP files.
126
  MCSection *DwarfCUIndexSection;
127
  MCSection *DwarfTUIndexSection;
128
129
  /// Section for newer gnu pubnames.
130
  MCSection *DwarfGnuPubNamesSection;
131
  /// Section for newer gnu pubtypes.
132
  MCSection *DwarfGnuPubTypesSection;
133
134
  // Section for Swift AST
135
  MCSection *DwarfSwiftASTSection;
136
137
  MCSection *COFFDebugSymbolsSection;
138
  MCSection *COFFDebugTypesSection;
139
  MCSection *COFFGlobalTypeHashesSection;
140
141
  /// Extra TLS Variable Data section.
142
  ///
143
  /// If the target needs to put additional information for a TLS variable,
144
  /// it'll go here.
145
  MCSection *TLSExtraDataSection;
146
147
  /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
148
  MCSection *TLSDataSection; // Defaults to ".tdata".
149
150
  /// Section directive for Thread Local uninitialized data.
151
  ///
152
  /// Null if this target doesn't support a BSS section. ELF and MachO only.
153
  MCSection *TLSBSSSection; // Defaults to ".tbss".
154
155
  /// StackMap section.
156
  MCSection *StackMapSection;
157
158
  /// FaultMap section.
159
  MCSection *FaultMapSection;
160
161
  /// EH frame section.
162
  ///
163
  /// It is initialized on demand so it can be overwritten (with uniquing).
164
  MCSection *EHFrameSection;
165
166
  /// Section containing metadata on function stack sizes.
167
  MCSection *StackSizesSection;
168
  mutable DenseMap<const MCSymbol *, unsigned> StackSizesUniquing;
169
170
  // ELF specific sections.
171
  MCSection *DataRelROSection;
172
  MCSection *MergeableConst4Section;
173
  MCSection *MergeableConst8Section;
174
  MCSection *MergeableConst16Section;
175
  MCSection *MergeableConst32Section;
176
177
  // MachO specific sections.
178
179
  /// Section for thread local structure information.
180
  ///
181
  /// Contains the source code name of the variable, visibility and a pointer to
182
  /// the initial value (.tdata or .tbss).
183
  MCSection *TLSTLVSection; // Defaults to ".tlv".
184
185
  /// Section for thread local data initialization functions.
186
  const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
187
188
  MCSection *CStringSection;
189
  MCSection *UStringSection;
190
  MCSection *TextCoalSection;
191
  MCSection *ConstTextCoalSection;
192
  MCSection *ConstDataSection;
193
  MCSection *DataCoalSection;
194
  MCSection *ConstDataCoalSection;
195
  MCSection *DataCommonSection;
196
  MCSection *DataBSSSection;
197
  MCSection *FourByteConstantSection;
198
  MCSection *EightByteConstantSection;
199
  MCSection *SixteenByteConstantSection;
200
  MCSection *LazySymbolPointerSection;
201
  MCSection *NonLazySymbolPointerSection;
202
  MCSection *ThreadLocalPointerSection;
203
204
  /// COFF specific sections.
205
  MCSection *DrectveSection;
206
  MCSection *PDataSection;
207
  MCSection *XDataSection;
208
  MCSection *SXDataSection;
209
  MCSection *GFIDsSection;
210
211
public:
212
  void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
213
                            bool LargeCodeModel = false);
214
215
0
  bool getSupportsWeakOmittedEHFrame() const {
216
0
    return SupportsWeakOmittedEHFrame;
217
0
  }
218
5.57k
  bool getSupportsCompactUnwindWithoutEHFrame() const {
219
5.57k
    return SupportsCompactUnwindWithoutEHFrame;
220
5.57k
  }
221
3.17k
  bool getOmitDwarfIfHaveCompactUnwind() const {
222
3.17k
    return OmitDwarfIfHaveCompactUnwind;
223
3.17k
  }
224
225
13.6k
  bool getCommDirectiveSupportsAlignment() const {
226
13.6k
    return CommDirectiveSupportsAlignment;
227
13.6k
  }
228
229
452k
  unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
230
426k
  unsigned getLSDAEncoding() const { return LSDAEncoding; }
231
97.8k
  unsigned getFDEEncoding() const { return FDECFIEncoding; }
232
1.68k
  unsigned getTTypeEncoding() const { return TTypeEncoding; }
233
234
128k
  unsigned getCompactUnwindDwarfEHFrameOnly() const {
235
128k
    return CompactUnwindDwarfEHFrameOnly;
236
128k
  }
237
238
50.0k
  MCSection *getTextSection() const { return TextSection; }
239
2.48k
  MCSection *getDataSection() const { return DataSection; }
240
1.14k
  MCSection *getBSSSection() const { return BSSSection; }
241
4
  MCSection *getReadOnlySection() const { return ReadOnlySection; }
242
3.18k
  MCSection *getLSDASection() const { return LSDASection; }
243
9.69k
  MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
244
6.08k
  MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
245
3.27k
  MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
246
7.36k
  MCSection *getDwarfLineSection() const { return DwarfLineSection; }
247
240
  MCSection *getDwarfLineStrSection() const { return DwarfLineStrSection; }
248
326
  MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
249
723
  MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
250
723
  MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
251
208
  MCSection *getDwarfGnuPubNamesSection() const {
252
208
    return DwarfGnuPubNamesSection;
253
208
  }
254
208
  MCSection *getDwarfGnuPubTypesSection() const {
255
208
    return DwarfGnuPubTypesSection;
256
208
  }
257
202
  const MCSection *getDwarfDebugInlineSection() const {
258
202
    return DwarfDebugInlineSection;
259
202
  }
260
3.43k
  MCSection *getDwarfStrSection() const { return DwarfStrSection; }
261
385
  MCSection *getDwarfLocSection() const { return DwarfLocSection; }
262
442
  MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
263
59.0k
  MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
264
9
  MCSection *getDwarfRnglistsSection() const { return DwarfRnglistsSection; }
265
2.43k
  MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
266
267
212
  MCSection *getDwarfDebugNamesSection() const {
268
212
    return DwarfDebugNamesSection;
269
212
  }
270
2.96k
  MCSection *getDwarfAccelNamesSection() const {
271
2.96k
    return DwarfAccelNamesSection;
272
2.96k
  }
273
2.96k
  MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
274
2.96k
  MCSection *getDwarfAccelNamespaceSection() const {
275
2.96k
    return DwarfAccelNamespaceSection;
276
2.96k
  }
277
2.96k
  MCSection *getDwarfAccelTypesSection() const {
278
2.96k
    return DwarfAccelTypesSection;
279
2.96k
  }
280
260
  MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
281
  MCSection *getDwarfTypesSection(uint64_t Hash) const;
282
274
  MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
283
256
  MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
284
256
  MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
285
256
  MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
286
256
  MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
287
260
  MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
288
276
  MCSection *getDwarfStrOffSection() const { return DwarfStrOffSection; }
289
264
  MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
290
0
  MCSection *getDwarfRnglistsDWOSection() const {
291
0
    return DwarfRnglistsDWOSection;
292
0
  }
293
235
  MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
294
235
  MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
295
203
  MCSection *getDwarfSwiftASTSection() const { return DwarfSwiftASTSection; }
296
297
701
  MCSection *getCOFFDebugSymbolsSection() const {
298
701
    return COFFDebugSymbolsSection;
299
701
  }
300
117
  MCSection *getCOFFDebugTypesSection() const {
301
117
    return COFFDebugTypesSection;
302
117
  }
303
2
  MCSection *getCOFFGlobalTypeHashesSection() const {
304
2
    return COFFGlobalTypeHashesSection;
305
2
  }
306
307
124
  MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
308
0
  const MCSection *getTLSDataSection() const { return TLSDataSection; }
309
110
  MCSection *getTLSBSSSection() const { return TLSBSSSection; }
310
311
58
  MCSection *getStackMapSection() const { return StackMapSection; }
312
4
  MCSection *getFaultMapSection() const { return FaultMapSection; }
313
314
  MCSection *getStackSizesSection(const MCSection &TextSec) const;
315
316
  // ELF specific sections.
317
0
  MCSection *getDataRelROSection() const { return DataRelROSection; }
318
0
  const MCSection *getMergeableConst4Section() const {
319
0
    return MergeableConst4Section;
320
0
  }
321
0
  const MCSection *getMergeableConst8Section() const {
322
0
    return MergeableConst8Section;
323
0
  }
324
0
  const MCSection *getMergeableConst16Section() const {
325
0
    return MergeableConst16Section;
326
0
  }
327
0
  const MCSection *getMergeableConst32Section() const {
328
0
    return MergeableConst32Section;
329
0
  }
330
331
  // MachO specific sections.
332
0
  const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
333
0
  const MCSection *getTLSThreadInitSection() const {
334
0
    return TLSThreadInitSection;
335
0
  }
336
0
  const MCSection *getCStringSection() const { return CStringSection; }
337
0
  const MCSection *getUStringSection() const { return UStringSection; }
338
159
  MCSection *getTextCoalSection() const { return TextCoalSection; }
339
0
  const MCSection *getConstTextCoalSection() const {
340
0
    return ConstTextCoalSection;
341
0
  }
342
0
  const MCSection *getConstDataSection() const { return ConstDataSection; }
343
0
  const MCSection *getDataCoalSection() const { return DataCoalSection; }
344
0
  const MCSection *getConstDataCoalSection() const {
345
0
    return ConstDataCoalSection;
346
0
  }
347
0
  const MCSection *getDataCommonSection() const { return DataCommonSection; }
348
6
  MCSection *getDataBSSSection() const { return DataBSSSection; }
349
0
  const MCSection *getFourByteConstantSection() const {
350
0
    return FourByteConstantSection;
351
0
  }
352
0
  const MCSection *getEightByteConstantSection() const {
353
0
    return EightByteConstantSection;
354
0
  }
355
0
  const MCSection *getSixteenByteConstantSection() const {
356
0
    return SixteenByteConstantSection;
357
0
  }
358
0
  MCSection *getLazySymbolPointerSection() const {
359
0
    return LazySymbolPointerSection;
360
0
  }
361
539
  MCSection *getNonLazySymbolPointerSection() const {
362
539
    return NonLazySymbolPointerSection;
363
539
  }
364
5
  MCSection *getThreadLocalPointerSection() const {
365
5
    return ThreadLocalPointerSection;
366
5
  }
367
368
  // COFF specific sections.
369
285
  MCSection *getDrectveSection() const { return DrectveSection; }
370
91
  MCSection *getPDataSection() const { return PDataSection; }
371
729
  MCSection *getXDataSection() const { return XDataSection; }
372
3
  MCSection *getSXDataSection() const { return SXDataSection; }
373
1
  MCSection *getGFIDsSection() const { return GFIDsSection; }
374
375
3.07k
  MCSection *getEHFrameSection() {
376
3.07k
    return EHFrameSection;
377
3.07k
  }
378
379
  enum Environment { IsMachO, IsELF, IsCOFF, IsWasm };
380
7.30M
  Environment getObjectFileType() const { return Env; }
381
382
4.26k
  bool isPositionIndependent() const { return PositionIndependent; }
383
384
private:
385
  Environment Env;
386
  bool PositionIndependent;
387
  MCContext *Ctx;
388
  Triple TT;
389
390
  void initMachOMCObjectFileInfo(const Triple &T);
391
  void initELFMCObjectFileInfo(const Triple &T, bool Large);
392
  void initCOFFMCObjectFileInfo(const Triple &T);
393
  void initWasmMCObjectFileInfo(const Triple &T);
394
395
public:
396
171k
  const Triple &getTargetTriple() const { return TT; }
397
};
398
399
} // end namespace llvm
400
401
#endif