Coverage Report

Created: 2019-07-24 05:18

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file describes common object file formats.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_MC_MCOBJECTFILEINFO_H
14
#define LLVM_MC_MCOBJECTFILEINFO_H
15
16
#include "llvm/ADT/DenseMap.h"
17
#include "llvm/ADT/Triple.h"
18
#include "llvm/MC/MCSymbol.h"
19
#include "llvm/Support/CodeGen.h"
20
#include "llvm/Support/VersionTuple.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
  /// The DWARF v5 locations list section.
121
  MCSection *DwarfLoclistsSection;
122
123
  /// The DWARF v5 range list section for fission.
124
  MCSection *DwarfRnglistsDWOSection;
125
126
  // These are for Fission DWP files.
127
  MCSection *DwarfCUIndexSection;
128
  MCSection *DwarfTUIndexSection;
129
130
  /// Section for newer gnu pubnames.
131
  MCSection *DwarfGnuPubNamesSection;
132
  /// Section for newer gnu pubtypes.
133
  MCSection *DwarfGnuPubTypesSection;
134
135
  // Section for Swift AST
136
  MCSection *DwarfSwiftASTSection;
137
138
  MCSection *COFFDebugSymbolsSection;
139
  MCSection *COFFDebugTypesSection;
140
  MCSection *COFFGlobalTypeHashesSection;
141
142
  /// Extra TLS Variable Data section.
143
  ///
144
  /// If the target needs to put additional information for a TLS variable,
145
  /// it'll go here.
146
  MCSection *TLSExtraDataSection;
147
148
  /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
149
  MCSection *TLSDataSection; // Defaults to ".tdata".
150
151
  /// Section directive for Thread Local uninitialized data.
152
  ///
153
  /// Null if this target doesn't support a BSS section. ELF and MachO only.
154
  MCSection *TLSBSSSection; // Defaults to ".tbss".
155
156
  /// StackMap section.
157
  MCSection *StackMapSection;
158
159
  /// FaultMap section.
160
  MCSection *FaultMapSection;
161
162
  /// Remarks section.
163
  MCSection *RemarksSection;
164
165
  /// EH frame section.
166
  ///
167
  /// It is initialized on demand so it can be overwritten (with uniquing).
168
  MCSection *EHFrameSection;
169
170
  /// Section containing metadata on function stack sizes.
171
  MCSection *StackSizesSection;
172
  mutable DenseMap<const MCSymbol *, unsigned> StackSizesUniquing;
173
174
  // ELF specific sections.
175
  MCSection *DataRelROSection;
176
  MCSection *MergeableConst4Section;
177
  MCSection *MergeableConst8Section;
178
  MCSection *MergeableConst16Section;
179
  MCSection *MergeableConst32Section;
180
181
  // MachO specific sections.
182
183
  /// Section for thread local structure information.
184
  ///
185
  /// Contains the source code name of the variable, visibility and a pointer to
186
  /// the initial value (.tdata or .tbss).
187
  MCSection *TLSTLVSection; // Defaults to ".tlv".
188
189
  /// Section for thread local data initialization functions.
190
  const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
191
192
  MCSection *CStringSection;
193
  MCSection *UStringSection;
194
  MCSection *TextCoalSection;
195
  MCSection *ConstTextCoalSection;
196
  MCSection *ConstDataSection;
197
  MCSection *DataCoalSection;
198
  MCSection *ConstDataCoalSection;
199
  MCSection *DataCommonSection;
200
  MCSection *DataBSSSection;
201
  MCSection *FourByteConstantSection;
202
  MCSection *EightByteConstantSection;
203
  MCSection *SixteenByteConstantSection;
204
  MCSection *LazySymbolPointerSection;
205
  MCSection *NonLazySymbolPointerSection;
206
  MCSection *ThreadLocalPointerSection;
207
208
  /// COFF specific sections.
209
  MCSection *DrectveSection;
210
  MCSection *PDataSection;
211
  MCSection *XDataSection;
212
  MCSection *SXDataSection;
213
  MCSection *GFIDsSection;
214
215
public:
216
  void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
217
                            bool LargeCodeModel = false);
218
219
0
  bool getSupportsWeakOmittedEHFrame() const {
220
0
    return SupportsWeakOmittedEHFrame;
221
0
  }
222
5.62k
  bool getSupportsCompactUnwindWithoutEHFrame() const {
223
5.62k
    return SupportsCompactUnwindWithoutEHFrame;
224
5.62k
  }
225
2.95k
  bool getOmitDwarfIfHaveCompactUnwind() const {
226
2.95k
    return OmitDwarfIfHaveCompactUnwind;
227
2.95k
  }
228
229
14.2k
  bool getCommDirectiveSupportsAlignment() const {
230
14.2k
    return CommDirectiveSupportsAlignment;
231
14.2k
  }
232
233
90.9k
  unsigned getFDEEncoding() const { return FDECFIEncoding; }
234
235
128k
  unsigned getCompactUnwindDwarfEHFrameOnly() const {
236
128k
    return CompactUnwindDwarfEHFrameOnly;
237
128k
  }
238
239
59.9k
  MCSection *getTextSection() const { return TextSection; }
240
2.84k
  MCSection *getDataSection() const { return DataSection; }
241
1.49k
  MCSection *getBSSSection() const { return BSSSection; }
242
3.26k
  MCSection *getReadOnlySection() const { return ReadOnlySection; }
243
3.45k
  MCSection *getLSDASection() const { return LSDASection; }
244
9.70k
  MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
245
6.45k
  MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
246
3.59k
  MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
247
5
  MCSection *getDwarfInfoSection(uint64_t Hash) const {
248
5
    return getDwarfComdatSection(".debug_info", Hash);
249
5
  }
250
7.74k
  MCSection *getDwarfLineSection() const { return DwarfLineSection; }
251
314
  MCSection *getDwarfLineStrSection() const { return DwarfLineStrSection; }
252
370
  MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
253
794
  MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
254
792
  MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
255
1.61k
  MCSection *getDwarfGnuPubNamesSection() const {
256
1.61k
    return DwarfGnuPubNamesSection;
257
1.61k
  }
258
1.61k
  MCSection *getDwarfGnuPubTypesSection() const {
259
1.61k
    return DwarfGnuPubTypesSection;
260
1.61k
  }
261
216
  const MCSection *getDwarfDebugInlineSection() const {
262
216
    return DwarfDebugInlineSection;
263
216
  }
264
3.60k
  MCSection *getDwarfStrSection() const { return DwarfStrSection; }
265
440
  MCSection *getDwarfLocSection() const { return DwarfLocSection; }
266
531
  MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
267
58.2k
  MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
268
22
  MCSection *getDwarfRnglistsSection() const { return DwarfRnglistsSection; }
269
12
  MCSection *getDwarfLoclistsSection() const { return DwarfLoclistsSection; }
270
2.57k
  MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
271
272
279
  MCSection *getDwarfDebugNamesSection() const {
273
279
    return DwarfDebugNamesSection;
274
279
  }
275
2.87k
  MCSection *getDwarfAccelNamesSection() const {
276
2.87k
    return DwarfAccelNamesSection;
277
2.87k
  }
278
2.87k
  MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
279
2.87k
  MCSection *getDwarfAccelNamespaceSection() const {
280
2.87k
    return DwarfAccelNamespaceSection;
281
2.87k
  }
282
2.87k
  MCSection *getDwarfAccelTypesSection() const {
283
2.87k
    return DwarfAccelTypesSection;
284
2.87k
  }
285
302
  MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
286
18
  MCSection *getDwarfTypesSection(uint64_t Hash) const {
287
18
    return getDwarfComdatSection(".debug_types", Hash);
288
18
  }
289
290
  MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
290
292
  MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
291
292
  MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
292
292
  MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
293
252
  MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
294
299
  MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
295
536
  MCSection *getDwarfStrOffSection() const { return DwarfStrOffSection; }
296
3.54k
  MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
297
1
  MCSection *getDwarfRnglistsDWOSection() const {
298
1
    return DwarfRnglistsDWOSection;
299
1
  }
300
254
  MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
301
254
  MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
302
217
  MCSection *getDwarfSwiftASTSection() const { return DwarfSwiftASTSection; }
303
304
1.13k
  MCSection *getCOFFDebugSymbolsSection() const {
305
1.13k
    return COFFDebugSymbolsSection;
306
1.13k
  }
307
190
  MCSection *getCOFFDebugTypesSection() const {
308
190
    return COFFDebugTypesSection;
309
190
  }
310
2
  MCSection *getCOFFGlobalTypeHashesSection() const {
311
2
    return COFFGlobalTypeHashesSection;
312
2
  }
313
314
126
  MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
315
0
  const MCSection *getTLSDataSection() const { return TLSDataSection; }
316
114
  MCSection *getTLSBSSSection() const { return TLSBSSSection; }
317
318
63
  MCSection *getStackMapSection() const { return StackMapSection; }
319
5
  MCSection *getFaultMapSection() const { return FaultMapSection; }
320
3
  MCSection *getRemarksSection() const { return RemarksSection; }
321
322
  MCSection *getStackSizesSection(const MCSection &TextSec) const;
323
324
  // ELF specific sections.
325
0
  MCSection *getDataRelROSection() const { return DataRelROSection; }
326
0
  const MCSection *getMergeableConst4Section() const {
327
0
    return MergeableConst4Section;
328
0
  }
329
0
  const MCSection *getMergeableConst8Section() const {
330
0
    return MergeableConst8Section;
331
0
  }
332
0
  const MCSection *getMergeableConst16Section() const {
333
0
    return MergeableConst16Section;
334
0
  }
335
0
  const MCSection *getMergeableConst32Section() const {
336
0
    return MergeableConst32Section;
337
0
  }
338
339
  // MachO specific sections.
340
0
  const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
341
0
  const MCSection *getTLSThreadInitSection() const {
342
0
    return TLSThreadInitSection;
343
0
  }
344
0
  const MCSection *getCStringSection() const { return CStringSection; }
345
0
  const MCSection *getUStringSection() const { return UStringSection; }
346
0
  MCSection *getTextCoalSection() const { return TextCoalSection; }
347
0
  const MCSection *getConstTextCoalSection() const {
348
0
    return ConstTextCoalSection;
349
0
  }
350
0
  const MCSection *getConstDataSection() const { return ConstDataSection; }
351
0
  const MCSection *getDataCoalSection() const { return DataCoalSection; }
352
0
  const MCSection *getConstDataCoalSection() const {
353
0
    return ConstDataCoalSection;
354
0
  }
355
0
  const MCSection *getDataCommonSection() const { return DataCommonSection; }
356
6
  MCSection *getDataBSSSection() const { return DataBSSSection; }
357
0
  const MCSection *getFourByteConstantSection() const {
358
0
    return FourByteConstantSection;
359
0
  }
360
0
  const MCSection *getEightByteConstantSection() const {
361
0
    return EightByteConstantSection;
362
0
  }
363
0
  const MCSection *getSixteenByteConstantSection() const {
364
0
    return SixteenByteConstantSection;
365
0
  }
366
0
  MCSection *getLazySymbolPointerSection() const {
367
0
    return LazySymbolPointerSection;
368
0
  }
369
509
  MCSection *getNonLazySymbolPointerSection() const {
370
509
    return NonLazySymbolPointerSection;
371
509
  }
372
5
  MCSection *getThreadLocalPointerSection() const {
373
5
    return ThreadLocalPointerSection;
374
5
  }
375
376
  // COFF specific sections.
377
302
  MCSection *getDrectveSection() const { return DrectveSection; }
378
216
  MCSection *getPDataSection() const { return PDataSection; }
379
1.37k
  MCSection *getXDataSection() const { return XDataSection; }
380
6
  MCSection *getSXDataSection() const { return SXDataSection; }
381
1
  MCSection *getGFIDsSection() const { return GFIDsSection; }
382
383
2.84k
  MCSection *getEHFrameSection() {
384
2.84k
    return EHFrameSection;
385
2.84k
  }
386
387
  enum Environment { IsMachO, IsELF, IsCOFF, IsWasm, IsXCOFF };
388
7.35M
  Environment getObjectFileType() const { return Env; }
389
390
18.9k
  bool isPositionIndependent() const { return PositionIndependent; }
391
392
private:
393
  Environment Env;
394
  bool PositionIndependent;
395
  MCContext *Ctx;
396
  Triple TT;
397
  VersionTuple SDKVersion;
398
399
  void initMachOMCObjectFileInfo(const Triple &T);
400
  void initELFMCObjectFileInfo(const Triple &T, bool Large);
401
  void initCOFFMCObjectFileInfo(const Triple &T);
402
  void initWasmMCObjectFileInfo(const Triple &T);
403
  void initXCOFFMCObjectFileInfo(const Triple &T);
404
  MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
405
406
public:
407
227k
  const Triple &getTargetTriple() const { return TT; }
408
409
76
  void setSDKVersion(const VersionTuple &TheSDKVersion) {
410
76
    SDKVersion = TheSDKVersion;
411
76
  }
412
413
13.9k
  const VersionTuple &getSDKVersion() const { return SDKVersion; }
414
};
415
416
} // end namespace llvm
417
418
#endif