9#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_OUTPUTSECTIONS_H
10#define LLVM_LIB_DWARFLINKER_PARALLEL_OUTPUTSECTIONS_H
32namespace dwarf_linker {
72 bool AddLocalValue =
false)
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()),
188#define ADD_PATCHES_LIST(T) \
189 T ¬ePatch(const T &Patch) { return List##T.add(Patch); } \
190 ArrayList<T> List##T;
209 template <
typename T>
212 PatchesOffsetsList.
emplace_back(¬ePatch(Patch).PatchOffset);
341 assert(It->second.get() !=
nullptr);
348 std::optional<const SectionDescriptor *>
355 return It->second.get();
360 std::optional<SectionDescriptor *>
367 return It->second.get();
386 Section.second->clearAllSectionData();
392 assert(Section.second.get() !=
nullptr);
393 Handler(*(Section.second));
399 function_ref<
void(std::shared_ptr<SectionDescriptor> Section)> Handler) {
401 Handler(Section.second);
408 std::array<uint64_t, SectionKindsNum> &SectionSizesAccumulator) {
410 Section.second->StartOffset =
411 SectionSizesAccumulator[
static_cast<uint8_t>(
412 Section.second->getKind())];
413 SectionSizesAccumulator[
static_cast<uint8_t>(
414 Section.second->getKind())] += Section.second->getContents().size();
461 std::map<DebugSectionKind, std::shared_ptr<SectionDescriptor>>;
This file contains constants used for implementing Dwarf debug support.
#define ADD_PATCHES_LIST(T)
Section patches.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
reference emplace_back(ArgTypes &&... Args)
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
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.
std::optional< SectionDescriptor * > tryGetSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
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.
OutputSections(LinkingGlobalData &GlobalData)
LinkingGlobalData & GlobalData
llvm::endianness Endianness
Endiannes for sections.
dwarf::FormParams Format
Format for sections.
const dwarf::FormParams & getFormParams() const
Return size of address.
void eraseSections()
Erases data of all sections.
std::optional< const SectionDescriptor * > tryGetSectionDescriptor(DebugSectionKind SectionKind) const
Returns descriptor for the specified section of SectionKind.
void setOutputFormat(dwarf::FormParams Format, llvm::endianness Endianness)
Sets output format for all keeping sections.
uint16_t getVersion() const
Return DWARF version.
SectionsSetTy SectionDescriptors
uint16_t getDebugInfoHeaderSize() const
Return size of header of debug_info table.
uint16_t getDebugAddrHeaderSize() const
Return size of header of debug_ table.
std::map< DebugSectionKind, std::shared_ptr< SectionDescriptor > > SectionsSetTy
All keeping sections.
void forEach(function_ref< void(std::shared_ptr< SectionDescriptor > Section)> Handler)
Enumerate all sections and call Handler for each.
void forEach(function_ref< void(SectionDescriptor &)> Handler)
Enumerate all sections and call Handler for each.
llvm::endianness getEndianness() const
Endiannes for the sections.
SectionDescriptor & getOrCreateSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
void assignSectionsOffsetAndAccumulateSize(std::array< uint64_t, SectionKindsNum > &SectionSizesAccumulator)
Enumerate all sections, for each section set current offset (kept by SectionSizesAccumulator),...
const SectionDescriptor & getSectionDescriptor(DebugSectionKind SectionKind) const
Returns descriptor for the specified section of SectionKind.
SectionDescriptor & getSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
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.
static constexpr const StringLiteral & getSectionName(DebugSectionKind SectionKind)
Return the name of the section.
DebugSectionKind
List of tracked debug tables.
@ 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)
This structure is used to update reference to the DIE.
uint64_t RefDieIdxOrClonedOffset
PointerIntPair< CompileUnit *, 1 > RefCU
This structure is used to update reference to the type DIE.
This structure is used to update strings offsets into .debug_line_str.
const StringEntry * String
This structure is used to update location list offset into .debug_loc/.debug_loclists.
int64_t AddrAdjustmentValue
DebugOffsetPatch(uint64_t PatchOffset, SectionDescriptor *SectionPtr, bool AddLocalValue=false)
PointerIntPair< SectionDescriptor *, 1 > SectionPtr
This structure is used to update range list offset into .debug_ranges/.debug_rnglists.
bool IsCompileUnitRanges
Indicates patch which points to immediate compile unit's attribute.
This structure is used to update strings offsets into .debug_str.
const StringEntry * String
This structure is used to update reference to the type DIE.
This structure is used to update reference to the DIE of ULEB128 form.
uint64_t RefDieIdxOrClonedOffset
PointerIntPair< CompileUnit *, 1 > RefCU
This structure keeps data of the concrete section.
dwarf::FormParams getFormParams() const
Returns FormParams used by section.
llvm::endianness Endianess
dwarf::FormParams Format
Output format.
This structure is used to keep data of the concrete section.
raw_svector_ostream OS
Stream which stores data to the Contents.
void setSizesForSectionCreatedByAsmPrinter()
Some sections are emitted using AsmPrinter.
void emitUnitLength(uint64_t Length)
Emit unit length into the current section contents.
void emitOffset(uint64_t Val)
Emit specified offset value into the current section contents.
OutSectionDataTy Contents
Section data bits.
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.
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.
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.
void setOutputFormat(dwarf::FormParams Format, llvm::endianness Endianess)
Sets output format.
size_t SectionOffsetInsideAsmPrinterOutputStart
Some sections are generated using AsmPrinter.
void clearAllSectionData()
Erase whole section content(data bits, list of patches).
size_t SectionOffsetInsideAsmPrinterOutputEnd
SectionDescriptor(DebugSectionKind SectionKind, LinkingGlobalData &GlobalData, dwarf::FormParams Format, llvm::endianness Endianess)
void emitStringPlaceholder()
Emit string placeholder into the current section contents.
void notePatchWithOffsetUpdate(const T &Patch, OffsetsPtrVector &PatchesOffsetsList)
While creating patches, offsets to attributes may be partially unknown(because size of abbreviation n...
LinkingGlobalData & GlobalData
uint64_t StartOffset
When objects(f.e.
There are fields(sizes, offsets) which should be updated after sections are generated.