LLVM: lib/DWARFLinker/Parallel/OutputSections.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_OUTPUTSECTIONS_H
10#define LLVM_LIB_DWARFLINKER_PARALLEL_OUTPUTSECTIONS_H
11
28#include
29#include
30
31namespace llvm {
34
36
37
38
39
40
44
45
49
50
54
55
56
61
62
63
67
68
72 bool AddLocalValue = false)
74
76};
77
78
86
87
95
96
102
103
112
121
130
141
142
144
145
147
149
150
151
154
158 ListDebugStrPatch(&GlobalData.getAllocator()),
159 ListDebugLineStrPatch(&GlobalData.getAllocator()),
160 ListDebugRangePatch(&GlobalData.getAllocator()),
161 ListDebugLocPatch(&GlobalData.getAllocator()),
162 ListDebugDieRefPatch(&GlobalData.getAllocator()),
163 ListDebugULEB128DieRefPatch(&GlobalData.getAllocator()),
164 ListDebugOffsetPatch(&GlobalData.getAllocator()),
165 ListDebugDieTypeRefPatch(&GlobalData.getAllocator()),
166 ListDebugType2TypeDieRefPatch(&GlobalData.getAllocator()),
167 ListDebugTypeStrPatch(&GlobalData.getAllocator()),
168 ListDebugTypeLineStrPatch(&GlobalData.getAllocator()),
169 ListDebugTypeDeclFilePatch(&GlobalData.getAllocator()),
171
172
174
175
177
178
179
180
181
183
184protected:
185
187
188public:
189
191
192
193#define ADD_PATCHES_LIST(T) \
194 T ¬ePatch(const T &Patch) { return List##T.add(Patch); } \
195 ArrayList List##T;
196
209
210
211
212
213
214 template
217 PatchesOffsetsList.emplace_back(¬ePatch(Patch).PatchOffset);
218 }
219
220
221
222
224
225
233
234
239
240
246
247
251
252
254
256
258
259
264
265
270
271
273
274
276
277protected:
278
280
281
283
284
286
287
289 this->Format = Format;
291 }
292
294
295
296
297
300};
301
302
303
304
306public:
308
309
311 this->Format = Format;
313 }
314
315
316
317
321
325 .str()
327
328 return *It->second;
329 }
330
331
332
333
336
340 .str()
342
343 assert(It->second.get() != nullptr);
344
345 return *It->second;
346 }
347
348
349
350 std::optional<const SectionDescriptor *>
353
355 return std::nullopt;
356
357 return It->second.get();
358 }
359
360
361
362 std::optional<SectionDescriptor *>
365
367 return std::nullopt;
368
369 return It->second.get();
370 }
371
372
373
377
378 if (Inserted)
381
382 return *It->second;
383 }
384
385
388 Section.second->clearAllSectionData();
389 }
390
391
394 assert(Section.second.get() != nullptr);
395 Handler(*(Section.second));
396 }
397 }
398
399
401 function_ref<void(std::shared_ptr Section)> Handler) {
403 Handler(Section.second);
404 }
405
406
407
408
410 std::array<uint64_t, SectionKindsNum> &SectionSizesAccumulator) {
412 Section.second->StartOffset =
413 SectionSizesAccumulator[static_cast<uint8_t>(
414 Section.second->getKind())];
415 SectionSizesAccumulator[static_cast<uint8_t>(
416 Section.second->getKind())] += Section.second->getContents().size();
417 }
418 }
419
420
425
426
428
429
431
432
434 return Format.Version >= 5 ? 12 : 11;
435 }
436
437
442
443
448
449
451
452protected:
454
455
457
458
460
461
463 std::map<DebugSectionKind, std::shared_ptr>;
465};
466
467}
468}
469}
470
471#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains constants used for implementing Dwarf debug support.
#define ADD_PATCHES_LIST(T)
Section patches.
Definition OutputSections.h:193
This file defines the SmallString class.
A structured debug information entry.
PointerIntPair - This class implements a pair of a pointer and small integer.
SectionKind - This is a simple POD value that classifies the properties of a section.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Stores all information related to a compile unit, be it in its original instance of the object file o...
This class keeps data and services common for the whole linking process.
This class keeps contents and offsets to the debug sections.
Definition OutputSections.h:305
std::optional< SectionDescriptor * > tryGetSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
Definition OutputSections.h:363
void applyPatches(SectionDescriptor &Section, StringEntryToDwarfStringPoolEntryMap &DebugStrStrings, StringEntryToDwarfStringPoolEntryMap &DebugLineStrStrings, TypeUnit *TypeUnitPtr)
Enumerate all sections, for each section apply all section patches.
uint16_t getDebugStrOffsetsHeaderSize() const
Return size of header of debug_str_offsets table.
Definition OutputSections.h:444
OutputSections(LinkingGlobalData &GlobalData)
Definition OutputSections.h:307
LinkingGlobalData & GlobalData
Definition OutputSections.h:453
llvm::endianness Endianness
Endiannes for sections.
Definition OutputSections.h:459
dwarf::FormParams Format
Format for sections.
Definition OutputSections.h:456
const dwarf::FormParams & getFormParams() const
Return size of address.
Definition OutputSections.h:450
void eraseSections()
Erases data of all sections.
Definition OutputSections.h:386
std::optional< const SectionDescriptor * > tryGetSectionDescriptor(DebugSectionKind SectionKind) const
Returns descriptor for the specified section of SectionKind.
Definition OutputSections.h:351
std::map< DebugSectionKind, std::shared_ptr< SectionDescriptor > > SectionsSetTy
All keeping sections.
Definition OutputSections.h:462
void setOutputFormat(dwarf::FormParams Format, llvm::endianness Endianness)
Sets output format for all keeping sections.
Definition OutputSections.h:310
uint16_t getVersion() const
Return DWARF version.
Definition OutputSections.h:430
SectionsSetTy SectionDescriptors
Definition OutputSections.h:464
uint16_t getDebugInfoHeaderSize() const
Return size of header of debug_info table.
Definition OutputSections.h:433
uint16_t getDebugAddrHeaderSize() const
Return size of header of debug_ table.
Definition OutputSections.h:438
void forEach(function_ref< void(std::shared_ptr< SectionDescriptor > Section)> Handler)
Enumerate all sections and call Handler for each.
Definition OutputSections.h:400
void forEach(function_ref< void(SectionDescriptor &)> Handler)
Enumerate all sections and call Handler for each.
Definition OutputSections.h:392
llvm::endianness getEndianness() const
Endiannes for the sections.
Definition OutputSections.h:427
SectionDescriptor & getOrCreateSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
Definition OutputSections.h:375
void assignSectionsOffsetAndAccumulateSize(std::array< uint64_t, SectionKindsNum > &SectionSizesAccumulator)
Enumerate all sections, for each section set current offset (kept by SectionSizesAccumulator),...
Definition OutputSections.h:409
const SectionDescriptor & getSectionDescriptor(DebugSectionKind SectionKind) const
Returns descriptor for the specified section of SectionKind.
Definition OutputSections.h:319
SectionDescriptor & getSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
Definition OutputSections.h:334
This class creates a DwarfStringPoolEntry for the corresponding StringEntry.
Type Unit is used to represent an artificial compilation unit which keeps all type information.
An efficient, type-erasing, non-owning reference to a callable.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
SmallString< 0 > OutSectionDataTy
Type for section data.
Definition OutputSections.h:143
SmallVector< uint64_t * > OffsetsPtrVector
Type for list of pointers to patches offsets.
Definition OutputSections.h:146
StringMapEntry< std::atomic< TypeEntryBody * > > TypeEntry
static constexpr const StringLiteral & getSectionName(DebugSectionKind SectionKind)
Return the name of the section.
DebugSectionKind
List of tracked debug tables.
StringMapEntry< EmptyStringSetTag > StringEntry
StringEntry keeps data of the string: the length, external offset and a string body which is placed r...
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
This is an optimization pass for GlobalISel generic memory operations.
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
FunctionAddr VTableAddr uintptr_t uintptr_t Data
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
uint64_t RefDieIdxOrClonedOffset
Definition OutputSections.h:84
PointerIntPair< CompileUnit *, 1 > RefCU
Definition OutputSections.h:83
DebugDieRefPatch(uint64_t PatchOffset, CompileUnit *SrcCU, CompileUnit *RefCU, uint32_t RefIdx)
TypeEntry * RefTypeName
Definition OutputSections.h:100
DebugDieTypeRefPatch(uint64_t PatchOffset, TypeEntry *RefTypeName)
This structure is used to update strings offsets into .debug_line_str.
Definition OutputSections.h:51
const StringEntry * String
Definition OutputSections.h:52
This structure is used to update location list offset into .debug_loc/.debug_loclists.
Definition OutputSections.h:64
int64_t AddrAdjustmentValue
Definition OutputSections.h:65
DebugOffsetPatch(uint64_t PatchOffset, SectionDescriptor *SectionPtr, bool AddLocalValue=false)
Definition OutputSections.h:71
PointerIntPair< SectionDescriptor *, 1 > SectionPtr
Definition OutputSections.h:75
This structure is used to update range list offset into .debug_ranges/.debug_rnglists.
Definition OutputSections.h:57
bool IsCompileUnitRanges
Indicates patch which points to immediate compile unit's attribute.
Definition OutputSections.h:59
This structure is used to update strings offsets into .debug_str.
Definition OutputSections.h:46
const StringEntry * String
Definition OutputSections.h:47
DIE * Die
Definition OutputSections.h:108
TypeEntry * RefTypeName
Definition OutputSections.h:110
DebugType2TypeDieRefPatch(uint64_t PatchOffset, DIE *Die, TypeEntry *TypeName, TypeEntry *RefTypeName)
TypeEntry * TypeName
Definition OutputSections.h:109
TypeEntry * TypeName
Definition OutputSections.h:136
uint32_t FileID
Definition OutputSections.h:139
StringEntry * Directory
Definition OutputSections.h:137
DIE * Die
Definition OutputSections.h:135
DebugTypeDeclFilePatch(DIE *Die, TypeEntry *TypeName, StringEntry *Directory, StringEntry *FilePath)
StringEntry * FilePath
Definition OutputSections.h:138
TypeEntry * TypeName
Definition OutputSections.h:127
DebugTypeLineStrPatch(uint64_t PatchOffset, DIE *Die, TypeEntry *TypeName, StringEntry *String)
DIE * Die
Definition OutputSections.h:126
StringEntry * String
Definition OutputSections.h:128
TypeEntry * TypeName
Definition OutputSections.h:118
DebugTypeStrPatch(uint64_t PatchOffset, DIE *Die, TypeEntry *TypeName, StringEntry *String)
DIE * Die
Definition OutputSections.h:117
StringEntry * String
Definition OutputSections.h:119
DebugULEB128DieRefPatch(uint64_t PatchOffset, CompileUnit *SrcCU, CompileUnit *RefCU, uint32_t RefIdx)
uint64_t RefDieIdxOrClonedOffset
Definition OutputSections.h:93
PointerIntPair< CompileUnit *, 1 > RefCU
Definition OutputSections.h:92
DebugSectionKind SectionKind
The section kind.
dwarf::FormParams getFormParams() const
Returns FormParams used by section.
llvm::endianness Endianess
SectionDescriptorBase(DebugSectionKind SectionKind, dwarf::FormParams Format, llvm::endianness Endianess)
dwarf::FormParams Format
Output format.
This structure is used to keep data of the concrete section.
Definition OutputSections.h:152
raw_svector_ostream OS
Stream which stores data to the Contents.
Definition OutputSections.h:190
void setSizesForSectionCreatedByAsmPrinter()
Some sections are emitted using AsmPrinter.
friend OutputSections
Definition OutputSections.h:153
void emitUnitLength(uint64_t Length)
Emit unit length into the current section contents.
Definition OutputSections.h:235
void emitOffset(uint64_t Val)
Emit specified offset value into the current section contents.
Definition OutputSections.h:248
OutSectionDataTy Contents
Section data bits.
Definition OutputSections.h:186
void emitString(dwarf::Form StringForm, const char *StringVal)
void applyIntVal(uint64_t PatchOffset, uint64_t Val, unsigned Size)
Writes integer value Val of Size by specified PatchOffset.
void emitIntVal(uint64_t Val, unsigned Size)
Emit specified integer value into the current section contents.
void applySLEB128(uint64_t PatchOffset, uint64_t Val)
Writes integer value Val of SLEB128 format by specified PatchOffset.
void applyULEB128(uint64_t PatchOffset, uint64_t Val)
Writes integer value Val of ULEB128 format by specified PatchOffset.
void maybeEmitDwarf64Mark()
Emit DWARF64 mark into the current section contents.
Definition OutputSections.h:241
void apply(uint64_t PatchOffset, dwarf::Form AttrForm, uint64_t Val)
Write specified Value of AttrForm to the PatchOffset.
void emitInplaceString(StringRef String)
Emit specified inplace string value into the current section contents.
Definition OutputSections.h:260
uint64_t getIntVal(uint64_t PatchOffset, unsigned Size)
Returns integer value of Size located by specified PatchOffset.
void clearSectionContent()
Erase only section output data bits.
void emitBinaryData(llvm::StringRef Data)
StringRef getContents() override
Returns section content.
Definition OutputSections.h:226
void setOutputFormat(dwarf::FormParams Format, llvm::endianness Endianess)
Sets output format.
Definition OutputSections.h:288
size_t SectionOffsetInsideAsmPrinterOutputStart
Some sections are generated using AsmPrinter.
Definition OutputSections.h:298
void clearAllSectionData()
Erase whole section content(data bits, list of patches).
size_t SectionOffsetInsideAsmPrinterOutputEnd
Definition OutputSections.h:299
SectionDescriptor(DebugSectionKind SectionKind, LinkingGlobalData &GlobalData, dwarf::FormParams Format, llvm::endianness Endianess)
Definition OutputSections.h:155
void emitStringPlaceholder()
Emit string placeholder into the current section contents.
Definition OutputSections.h:266
void notePatchWithOffsetUpdate(const T &Patch, OffsetsPtrVector &PatchesOffsetsList)
While creating patches, offsets to attributes may be partially unknown(because size of abbreviation n...
Definition OutputSections.h:215
LinkingGlobalData & GlobalData
Definition OutputSections.h:293
uint64_t StartOffset
When objects(f.e.
Definition OutputSections.h:182
There are fields(sizes, offsets) which should be updated after sections are generated.
Definition OutputSections.h:41
uint64_t PatchOffset
Definition OutputSections.h:42