LLVM 18.0.0git
DWARFLinker.h
Go to the documentation of this file.
1//===- DWARFLinker.h --------------------------------------------*- 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#ifndef LLVM_DWARFLINKER_DWARFLINKER_H
10#define LLVM_DWARFLINKER_DWARFLINKER_H
11
13#include "llvm/ADT/DenseMap.h"
22#include <map>
23
24namespace llvm {
25class DWARFExpression;
26class DWARFUnit;
27class DataExtractor;
28class DeclContextTree;
29template <typename T> class SmallVectorImpl;
30
32
33/// AddressesMap represents information about valid addresses used
34/// by debug information. Valid addresses are those which points to
35/// live code sections. i.e. relocations for these addresses point
36/// into sections which would be/are placed into resulting binary.
38public:
39 virtual ~AddressesMap();
40
41 /// Checks that there are valid relocations against a .debug_info
42 /// section.
43 virtual bool hasValidRelocs() = 0;
44
45 /// Checks that the specified DWARF expression operand \p Op references live
46 /// code section and returns the relocation adjustment value (to get the
47 /// linked address this value might be added to the source expression operand
48 /// address).
49 /// \returns relocation adjustment value or std::nullopt if there is no
50 /// corresponding live address.
51 virtual std::optional<int64_t>
54 uint64_t StartOffset, uint64_t EndOffset) = 0;
55
56 /// Checks that the specified subprogram \p DIE references the live code
57 /// section and returns the relocation adjustment value (to get the linked
58 /// address this value might be added to the source subprogram address).
59 /// Allowed kinds of input DIE: DW_TAG_subprogram, DW_TAG_label.
60 /// \returns relocation adjustment value or std::nullopt if there is no
61 /// corresponding live address.
62 virtual std::optional<int64_t>
64
65 /// Apply the valid relocations to the buffer \p Data, taking into
66 /// account that Data is at \p BaseOffset in the .debug_info section.
67 ///
68 /// \returns true whether any reloc has been applied.
70 bool IsLittleEndian) = 0;
71
72 /// Erases all data.
73 virtual void clear() = 0;
74};
75
77
81
84 if (It == DieValueMap.end()) {
85 It = DieValueMap.insert(std::make_pair(Value, DieValues.size())).first;
87 }
88 return It->second;
89 }
90
91 void clear() {
94 }
95};
96
97/// DwarfEmitter presents interface to generate all debug info tables.
99public:
100 virtual ~DwarfEmitter();
101
102 /// Emit section named SecName with data SecData.
103 virtual void emitSectionContents(StringRef SecData, StringRef SecName) = 0;
104
105 /// Emit the abbreviation table \p Abbrevs to the .debug_abbrev section.
106 virtual void
107 emitAbbrevs(const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs,
108 unsigned DwarfVersion) = 0;
109
110 /// Emit the string table described by \p Pool into .debug_str table.
111 virtual void emitStrings(const NonRelocatableStringpool &Pool) = 0;
112
113 /// Emit the debug string offset table described by \p StringOffsets into the
114 /// .debug_str_offsets table.
115 virtual void emitStringOffsets(const SmallVector<uint64_t> &StringOffsets,
116 uint16_t TargetDWARFVersion) = 0;
117
118 /// Emit the string table described by \p Pool into .debug_line_str table.
119 virtual void emitLineStrings(const NonRelocatableStringpool &Pool) = 0;
120
121 /// Emit DWARF debug names.
122 virtual void
124
125 /// Emit Apple namespaces accelerator table.
126 virtual void
128
129 /// Emit Apple names accelerator table.
130 virtual void
132
133 /// Emit Apple Objective-C accelerator table.
134 virtual void
136
137 /// Emit Apple type accelerator table.
138 virtual void
140
141 /// Emit debug ranges (.debug_ranges, .debug_rnglists) header.
143
144 /// Emit debug ranges (.debug_ranges, .debug_rnglists) fragment.
146 const CompileUnit &Unit, const AddressRanges &LinkedRanges,
147 PatchLocation Patch, DebugDieValuePool &AddrPool) = 0;
148
149 /// Emit debug ranges (.debug_ranges, .debug_rnglists) footer.
151 MCSymbol *EndLabel) = 0;
152
153 /// Emit debug locations (.debug_loc, .debug_loclists) header.
155
156 /// Emit debug locations (.debug_loc, .debug_loclists) fragment.
158 const CompileUnit &Unit,
159 const DWARFLocationExpressionsVector &LinkedLocationExpression,
160 PatchLocation Patch, DebugDieValuePool &AddrPool) = 0;
161
162 /// Emit debug locations (.debug_loc, .debug_loclists) footer.
163 virtual void emitDwarfDebugLocListFooter(const CompileUnit &Unit,
164 MCSymbol *EndLabel) = 0;
165
166 /// Emit .debug_addr header.
168
169 /// Emit the addresses described by \p Addrs into the .debug_addr section.
171 uint8_t AddrSize) = 0;
172
173 /// Emit .debug_addr footer.
174 virtual void emitDwarfDebugAddrsFooter(const CompileUnit &Unit,
175 MCSymbol *EndLabel) = 0;
176
177 /// Emit .debug_aranges entries for \p Unit
178 virtual void
180 const AddressRanges &LinkedRanges) = 0;
181
182 /// Emit specified \p LineTable into .debug_line table.
183 virtual void emitLineTableForUnit(const DWARFDebugLine::LineTable &LineTable,
184 const CompileUnit &Unit,
185 OffsetsStringPool &DebugStrPool,
186 OffsetsStringPool &DebugLineStrPool) = 0;
187
188 /// Emit the .debug_pubnames contribution for \p Unit.
189 virtual void emitPubNamesForUnit(const CompileUnit &Unit) = 0;
190
191 /// Emit the .debug_pubtypes contribution for \p Unit.
192 virtual void emitPubTypesForUnit(const CompileUnit &Unit) = 0;
193
194 /// Emit a CIE.
195 virtual void emitCIE(StringRef CIEBytes) = 0;
196
197 /// Emit an FDE with data \p Bytes.
198 virtual void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address,
199 StringRef Bytes) = 0;
200
201 /// Emit the compilation unit header for \p Unit in the
202 /// .debug_info section.
203 ///
204 /// As a side effect, this also switches the current Dwarf version
205 /// of the MC layer to the one of U.getOrigUnit().
207 unsigned DwarfVersion) = 0;
208
209 /// Recursively emit the DIE tree rooted at \p Die.
210 virtual void emitDIE(DIE &Die) = 0;
211
212 /// Emit all available macro tables(DWARFv4 and DWARFv5).
213 /// Use \p UnitMacroMap to get compilation unit by macro table offset.
214 /// Side effects: Fill \p StringPool with macro strings, update
215 /// DW_AT_macro_info, DW_AT_macros attributes for corresponding compile
216 /// units.
217 virtual void emitMacroTables(DWARFContext *Context,
218 const Offset2UnitMap &UnitMacroMap,
219 OffsetsStringPool &StringPool) = 0;
220
221 /// Returns size of generated .debug_line section.
222 virtual uint64_t getLineSectionSize() const = 0;
223
224 /// Returns size of generated .debug_frame section.
225 virtual uint64_t getFrameSectionSize() const = 0;
226
227 /// Returns size of generated .debug_ranges section.
228 virtual uint64_t getRangesSectionSize() const = 0;
229
230 /// Returns size of generated .debug_rnglists section.
231 virtual uint64_t getRngListsSectionSize() const = 0;
232
233 /// Returns size of generated .debug_info section.
235
236 /// Returns size of generated .debug_macinfo section.
238
239 /// Returns size of generated .debug_macro section.
241
242 /// Returns size of generated .debug_loclists section.
243 virtual uint64_t getLocListsSectionSize() const = 0;
244
245 /// Returns size of generated .debug_addr section.
247
248 /// Dump the file to the disk.
249 virtual void finish() = 0;
250
251 /// Emit the swift_ast section stored in \p Buffer.
252 virtual void emitSwiftAST(StringRef Buffer) = 0;
253
254 /// Emit the swift reflection section stored in \p Buffer.
257 StringRef Buffer, uint32_t Alignment, uint32_t Size) = 0;
258
259 /// Returns underlying AsmPrinter.
260 virtual AsmPrinter &getAsmPrinter() const = 0;
261};
262
263class DwarfStreamer;
264using UnitListTy = std::vector<std::unique_ptr<CompileUnit>>;
265
266/// This class represents DWARF information for source file
267/// and its address map.
269public:
270 using UnloadCallbackTy = std::function<void(StringRef FileName)>;
271 DWARFFile(StringRef Name, std::unique_ptr<DWARFContext> Dwarf,
272 std::unique_ptr<AddressesMap> Addresses, UnloadCallbackTy = nullptr)
275
276 /// The object file name.
278
279 /// The source DWARF information.
280 std::unique_ptr<DWARFContext> Dwarf;
281
282 /// Helpful address information(list of valid address ranges, relocations).
283 std::unique_ptr<AddressesMap> Addresses;
284};
285
286typedef std::map<std::string, std::string> swiftInterfacesMap;
287typedef std::map<std::string, std::string> objectPrefixMap;
288
289typedef function_ref<void(const DWARFUnit &Unit)> CompileUnitHandler;
290
291/// The core of the Dwarf linking logic.
292///
293/// The generation of the dwarf information from the object files will be
294/// driven by the selection of 'root DIEs', which are DIEs that
295/// describe variables or functions that resolves to the corresponding
296/// code section(and thus have entries in the Addresses map). All the debug
297/// information that will be generated(the DIEs, but also the line
298/// tables, ranges, ...) is derived from that set of root DIEs.
299///
300/// The root DIEs are identified because they contain relocations that
301/// points to code section(the low_pc for a function, the location for
302/// a variable). These relocations are called ValidRelocs in the
303/// AddressesInfo and are gathered as a very first step when we start
304/// processing a object file.
306public:
307 typedef std::function<void(const Twine &Warning, StringRef Context,
308 const DWARFDie *DIE)>
310 DWARFLinker(messageHandler ErrorHandler, messageHandler WarningHandler,
311 std::function<StringRef(StringRef)> StringsTranslator)
312 : DwarfLinkerClientID(DwarfLinkerClient::Dsymutil),
313 StringsTranslator(StringsTranslator), ErrorHandler(ErrorHandler),
314 WarningHandler(WarningHandler) {}
315
316 static std::unique_ptr<DWARFLinker> createLinker(
317 messageHandler ErrorHandler, messageHandler WarningHandler,
318 std::function<StringRef(StringRef)> StringsTranslator = nullptr) {
319 return std::make_unique<DWARFLinker>(ErrorHandler, WarningHandler,
320 StringsTranslator);
321 }
322
323 /// Type of output file.
324 enum class OutputFileType {
325 Object,
326 Assembly,
327 };
328
329 /// The kind of accelerator tables we should emit.
330 enum class AccelTableKind : uint8_t {
331 Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
332 Pub, ///< .debug_pubnames, .debug_pubtypes
333 DebugNames ///< .debug_names.
334 };
335 typedef std::function<void(const DWARFFile &File, llvm::StringRef Output)> inputVerificationHandler;
336 typedef std::function<ErrorOr<DWARFFile &>(StringRef ContainerName,
337 StringRef Path)>
339
340 Error createEmitter(const Triple &TheTriple, OutputFileType FileType,
341 raw_pwrite_stream &OutFile);
342
344
345 /// Add object file to be linked. Pre-load compile unit die. Call
346 /// \p OnCUDieLoaded for each compile unit die. If specified \p File
347 /// has reference to the Clang module then such module would be
348 /// pre-loaded by \p Loader for !Update case.
349 ///
350 /// \pre NoODR, Update options should be set before call to addObjectFile.
351 void addObjectFile(
352 DWARFFile &File, objFileLoader Loader = nullptr,
353 CompileUnitHandler OnCUDieLoaded = [](const DWARFUnit &) {});
354
355 /// Link debug info for added objFiles. Object files are linked all together.
356 Error link();
357
358 /// A number of methods setting various linking options:
359
360 /// Allows to generate log of linking process to the standard output.
361 void setVerbosity(bool Verbose) { Options.Verbose = Verbose; }
362
363 /// Print statistics to standard output.
364 void setStatistics(bool Statistics) { Options.Statistics = Statistics; }
365
366 /// Verify the input DWARF.
367 void setVerifyInputDWARF(bool Verify) { Options.VerifyInputDWARF = Verify; }
368
369 /// Do not unique types according to ODR.
370 void setNoODR(bool NoODR) { Options.NoODR = NoODR; }
371
372 /// Update index tables only(do not modify rest of DWARF).
373 void setUpdateIndexTablesOnly(bool Update) { Options.Update = Update; }
374
375 /// Allow generating valid, but non-deterministic output.
376 void setAllowNonDeterministicOutput(bool) { /* Nothing to do. */
377 }
378
379 /// Set whether to keep the enclosing function for a static variable.
380 void setKeepFunctionForStatic(bool KeepFunctionForStatic) {
381 Options.KeepFunctionForStatic = KeepFunctionForStatic;
382 }
383
384 /// Use specified number of threads for parallel files linking.
385 void setNumThreads(unsigned NumThreads) { Options.Threads = NumThreads; }
386
387 /// Add kind of accelerator tables to be generated.
389 assert(!llvm::is_contained(Options.AccelTables, Kind));
390 Options.AccelTables.emplace_back(Kind);
391 }
392
393 /// Set prepend path for clang modules.
394 void setPrependPath(const std::string &Ppath) { Options.PrependPath = Ppath; }
395
396 /// Set estimated objects files amount, for preliminary data allocation.
397 void setEstimatedObjfilesAmount(unsigned ObjFilesNum) {
398 ObjectContexts.reserve(ObjFilesNum);
399 }
400
401 /// Set verification handler which would be used to report verification
402 /// errors.
404 Options.InputVerificationHandler = Handler;
405 }
406
407 /// Set map for Swift interfaces.
409 Options.ParseableSwiftInterfaces = Map;
410 }
411
412 /// Set prefix map for objects.
414 Options.ObjectPrefixMap = Map;
415 }
416
417 /// Set target DWARF version.
419 if ((TargetDWARFVersion < 1) || (TargetDWARFVersion > 5))
420 return createStringError(std::errc::invalid_argument,
421 "unsupported DWARF version: %d",
422 TargetDWARFVersion);
423
424 Options.TargetDWARFVersion = TargetDWARFVersion;
425 return Error::success();
426 }
427
428private:
429 /// Flags passed to DwarfLinker::lookForDIEsToKeep
430 enum TraversalFlags {
431 TF_Keep = 1 << 0, ///< Mark the traversed DIEs as kept.
432 TF_InFunctionScope = 1 << 1, ///< Current scope is a function scope.
433 TF_DependencyWalk = 1 << 2, ///< Walking the dependencies of a kept DIE.
434 TF_ParentWalk = 1 << 3, ///< Walking up the parents of a kept DIE.
435 TF_ODR = 1 << 4, ///< Use the ODR while keeping dependents.
436 TF_SkipPC = 1 << 5, ///< Skip all location attributes.
437 };
438
439 /// The distinct types of work performed by the work loop.
440 enum class WorklistItemType {
441 /// Given a DIE, look for DIEs to be kept.
442 LookForDIEsToKeep,
443 /// Given a DIE, look for children of this DIE to be kept.
444 LookForChildDIEsToKeep,
445 /// Given a DIE, look for DIEs referencing this DIE to be kept.
446 LookForRefDIEsToKeep,
447 /// Given a DIE, look for parent DIEs to be kept.
448 LookForParentDIEsToKeep,
449 /// Given a DIE, update its incompleteness based on whether its children are
450 /// incomplete.
451 UpdateChildIncompleteness,
452 /// Given a DIE, update its incompleteness based on whether the DIEs it
453 /// references are incomplete.
454 UpdateRefIncompleteness,
455 /// Given a DIE, mark it as ODR Canonical if applicable.
456 MarkODRCanonicalDie,
457 };
458
459 /// This class represents an item in the work list. The type defines what kind
460 /// of work needs to be performed when processing the current item. The flags
461 /// and info fields are optional based on the type.
462 struct WorklistItem {
463 DWARFDie Die;
464 WorklistItemType Type;
465 CompileUnit &CU;
466 unsigned Flags;
467 union {
468 const unsigned AncestorIdx;
469 CompileUnit::DIEInfo *OtherInfo;
470 };
471
472 WorklistItem(DWARFDie Die, CompileUnit &CU, unsigned Flags,
473 WorklistItemType T = WorklistItemType::LookForDIEsToKeep)
474 : Die(Die), Type(T), CU(CU), Flags(Flags), AncestorIdx(0) {}
475
476 WorklistItem(DWARFDie Die, CompileUnit &CU, WorklistItemType T,
477 CompileUnit::DIEInfo *OtherInfo = nullptr)
478 : Die(Die), Type(T), CU(CU), Flags(0), OtherInfo(OtherInfo) {}
479
480 WorklistItem(unsigned AncestorIdx, CompileUnit &CU, unsigned Flags)
481 : Type(WorklistItemType::LookForParentDIEsToKeep), CU(CU), Flags(Flags),
482 AncestorIdx(AncestorIdx) {}
483 };
484
485 /// Verify the given DWARF file.
486 void verifyInput(const DWARFFile &File);
487
488 /// returns true if we need to translate strings.
489 bool needToTranslateStrings() { return StringsTranslator != nullptr; }
490
491 void reportWarning(const Twine &Warning, const DWARFFile &File,
492 const DWARFDie *DIE = nullptr) const {
493 if (WarningHandler != nullptr)
494 WarningHandler(Warning, File.FileName, DIE);
495 }
496
497 void reportError(const Twine &Warning, const DWARFFile &File,
498 const DWARFDie *DIE = nullptr) const {
499 if (ErrorHandler != nullptr)
500 ErrorHandler(Warning, File.FileName, DIE);
501 }
502
503 void copyInvariantDebugSection(DWARFContext &Dwarf);
504
505 /// Keep information for referenced clang module: already loaded DWARF info
506 /// of the clang module and a CompileUnit of the module.
507 struct RefModuleUnit {
508 RefModuleUnit(DWARFFile &File, std::unique_ptr<CompileUnit> Unit)
509 : File(File), Unit(std::move(Unit)) {}
510 RefModuleUnit(RefModuleUnit &&Other)
511 : File(Other.File), Unit(std::move(Other.Unit)) {}
512 RefModuleUnit(const RefModuleUnit &) = delete;
513
514 DWARFFile &File;
515 std::unique_ptr<CompileUnit> Unit;
516 };
517 using ModuleUnitListTy = std::vector<RefModuleUnit>;
518
519 /// Keeps track of data associated with one object during linking.
520 struct LinkContext {
521 DWARFFile &File;
522 UnitListTy CompileUnits;
523 ModuleUnitListTy ModuleUnits;
524 bool Skip = false;
525
526 LinkContext(DWARFFile &File) : File(File) {}
527
528 /// Clear part of the context that's no longer needed when we're done with
529 /// the debug object.
530 void clear() {
531 CompileUnits.clear();
532 File.Addresses->clear();
533 }
534 };
535
536 /// Called before emitting object data
537 void cleanupAuxiliarryData(LinkContext &Context);
538
539 /// Look at the parent of the given DIE and decide whether they should be
540 /// kept.
541 void lookForParentDIEsToKeep(unsigned AncestorIdx, CompileUnit &CU,
542 unsigned Flags,
543 SmallVectorImpl<WorklistItem> &Worklist);
544
545 /// Look at the children of the given DIE and decide whether they should be
546 /// kept.
547 void lookForChildDIEsToKeep(const DWARFDie &Die, CompileUnit &CU,
548 unsigned Flags,
549 SmallVectorImpl<WorklistItem> &Worklist);
550
551 /// Look at DIEs referenced by the given DIE and decide whether they should be
552 /// kept. All DIEs referenced though attributes should be kept.
553 void lookForRefDIEsToKeep(const DWARFDie &Die, CompileUnit &CU,
554 unsigned Flags, const UnitListTy &Units,
555 const DWARFFile &File,
556 SmallVectorImpl<WorklistItem> &Worklist);
557
558 /// Mark context corresponding to the specified \p Die as having canonical
559 /// die, if applicable.
560 void markODRCanonicalDie(const DWARFDie &Die, CompileUnit &CU);
561
562 /// \defgroup FindRootDIEs Find DIEs corresponding to Address map entries.
563 ///
564 /// @{
565 /// Recursively walk the \p DIE tree and look for DIEs to
566 /// keep. Store that information in \p CU's DIEInfo.
567 ///
568 /// The return value indicates whether the DIE is incomplete.
569 void lookForDIEsToKeep(AddressesMap &RelocMgr, const UnitListTy &Units,
570 const DWARFDie &DIE, const DWARFFile &File,
571 CompileUnit &CU, unsigned Flags);
572
573 /// Check whether specified \p CUDie is a Clang module reference.
574 /// if \p Quiet is false then display error messages.
575 /// \return first == true if CUDie is a Clang module reference.
576 /// second == true if module is already loaded.
577 std::pair<bool, bool> isClangModuleRef(const DWARFDie &CUDie,
578 std::string &PCMFile,
579 LinkContext &Context, unsigned Indent,
580 bool Quiet);
581
582 /// If this compile unit is really a skeleton CU that points to a
583 /// clang module, register it in ClangModules and return true.
584 ///
585 /// A skeleton CU is a CU without children, a DW_AT_gnu_dwo_name
586 /// pointing to the module, and a DW_AT_gnu_dwo_id with the module
587 /// hash.
588 bool registerModuleReference(const DWARFDie &CUDie, LinkContext &Context,
589 objFileLoader Loader,
590 CompileUnitHandler OnCUDieLoaded,
591 unsigned Indent = 0);
592
593 /// Recursively add the debug info in this clang module .pcm
594 /// file (and all the modules imported by it in a bottom-up fashion)
595 /// to ModuleUnits.
596 Error loadClangModule(objFileLoader Loader, const DWARFDie &CUDie,
597 const std::string &PCMFile, LinkContext &Context,
598 CompileUnitHandler OnCUDieLoaded, unsigned Indent = 0);
599
600 /// Clone specified Clang module unit \p Unit.
601 Error cloneModuleUnit(LinkContext &Context, RefModuleUnit &Unit,
602 DeclContextTree &ODRContexts,
603 OffsetsStringPool &DebugStrPool,
604 OffsetsStringPool &DebugLineStrPool,
605 DebugDieValuePool &StringOffsetPool,
606 unsigned Indent = 0);
607
608 unsigned shouldKeepDIE(AddressesMap &RelocMgr, const DWARFDie &DIE,
609 const DWARFFile &File, CompileUnit &Unit,
610 CompileUnit::DIEInfo &MyInfo, unsigned Flags);
611
612 /// This function checks whether variable has DWARF expression containing
613 /// operation referencing live address(f.e. DW_OP_addr, DW_OP_addrx...).
614 /// \returns first is true if the expression has an operation referencing an
615 /// address.
616 /// second is the relocation adjustment value if the live address is
617 /// referenced.
618 std::pair<bool, std::optional<int64_t>>
619 getVariableRelocAdjustment(AddressesMap &RelocMgr, const DWARFDie &DIE);
620
621 /// Check if a variable describing DIE should be kept.
622 /// \returns updated TraversalFlags.
623 unsigned shouldKeepVariableDIE(AddressesMap &RelocMgr, const DWARFDie &DIE,
624 CompileUnit::DIEInfo &MyInfo, unsigned Flags);
625
626 unsigned shouldKeepSubprogramDIE(AddressesMap &RelocMgr, const DWARFDie &DIE,
627 const DWARFFile &File, CompileUnit &Unit,
628 CompileUnit::DIEInfo &MyInfo,
629 unsigned Flags);
630
631 /// Resolve the DIE attribute reference that has been extracted in \p
632 /// RefValue. The resulting DIE might be in another CompileUnit which is
633 /// stored into \p ReferencedCU. \returns null if resolving fails for any
634 /// reason.
635 DWARFDie resolveDIEReference(const DWARFFile &File, const UnitListTy &Units,
636 const DWARFFormValue &RefValue,
637 const DWARFDie &DIE, CompileUnit *&RefCU);
638
639 /// @}
640
641 /// \defgroup Methods used to link the debug information
642 ///
643 /// @{
644
645 struct DWARFLinkerOptions;
646
647 class DIECloner {
648 DWARFLinker &Linker;
649 DwarfEmitter *Emitter;
650 DWARFFile &ObjFile;
651 OffsetsStringPool &DebugStrPool;
652 OffsetsStringPool &DebugLineStrPool;
653 DebugDieValuePool &StringOffsetPool;
654 DebugDieValuePool AddrPool;
655
656 /// Allocator used for all the DIEValue objects.
657 BumpPtrAllocator &DIEAlloc;
658
659 std::vector<std::unique_ptr<CompileUnit>> &CompileUnits;
660
661 /// Keeps mapping from offset of the macro table to corresponding
662 /// compile unit.
663 Offset2UnitMap UnitMacroMap;
664
665 bool Update;
666
667 public:
668 DIECloner(DWARFLinker &Linker, DwarfEmitter *Emitter, DWARFFile &ObjFile,
669 BumpPtrAllocator &DIEAlloc,
670 std::vector<std::unique_ptr<CompileUnit>> &CompileUnits,
671 bool Update, OffsetsStringPool &DebugStrPool,
672 OffsetsStringPool &DebugLineStrPool,
673 DebugDieValuePool &StringOffsetPool)
674 : Linker(Linker), Emitter(Emitter), ObjFile(ObjFile),
675 DebugStrPool(DebugStrPool), DebugLineStrPool(DebugLineStrPool),
676 StringOffsetPool(StringOffsetPool), DIEAlloc(DIEAlloc),
677 CompileUnits(CompileUnits), Update(Update) {}
678
679 /// Recursively clone \p InputDIE into an tree of DIE objects
680 /// where useless (as decided by lookForDIEsToKeep()) bits have been
681 /// stripped out and addresses have been rewritten according to the
682 /// address map.
683 ///
684 /// \param OutOffset is the offset the cloned DIE in the output
685 /// compile unit.
686 /// \param PCOffset (while cloning a function scope) is the offset
687 /// applied to the entry point of the function to get the linked address.
688 /// \param Die the output DIE to use, pass NULL to create one.
689 /// \returns the root of the cloned tree or null if nothing was selected.
690 DIE *cloneDIE(const DWARFDie &InputDIE, const DWARFFile &File,
691 CompileUnit &U, int64_t PCOffset, uint32_t OutOffset,
692 unsigned Flags, bool IsLittleEndian, DIE *Die = nullptr);
693
694 /// Construct the output DIE tree by cloning the DIEs we
695 /// chose to keep above. If there are no valid relocs, then there's
696 /// nothing to clone/emit.
697 uint64_t cloneAllCompileUnits(DWARFContext &DwarfContext,
698 const DWARFFile &File, bool IsLittleEndian);
699
700 /// Emit the .debug_addr section for the \p Unit.
701 void emitDebugAddrSection(CompileUnit &Unit,
702 const uint16_t DwarfVersion) const;
703
704 using ExpressionHandlerRef = function_ref<void(
705 SmallVectorImpl<uint8_t> &, SmallVectorImpl<uint8_t> &,
706 int64_t AddrRelocAdjustment)>;
707
708 /// Compute and emit debug locations (.debug_loc, .debug_loclists)
709 /// for \p Unit, patch the attributes referencing it.
710 void generateUnitLocations(CompileUnit &Unit, const DWARFFile &File,
711 ExpressionHandlerRef ExprHandler);
712
713 private:
714 using AttributeSpec = DWARFAbbreviationDeclaration::AttributeSpec;
715
716 /// Information gathered and exchanged between the various
717 /// clone*Attributes helpers about the attributes of a particular DIE.
718 struct AttributesInfo {
719 /// Names.
720 DwarfStringPoolEntryRef Name, MangledName, NameWithoutTemplate;
721
722 /// Offsets in the string pool.
723 uint32_t NameOffset = 0;
724 uint32_t MangledNameOffset = 0;
725
726 /// Offset to apply to PC addresses inside a function.
727 int64_t PCOffset = 0;
728
729 /// Does the DIE have a low_pc attribute?
730 bool HasLowPc = false;
731
732 /// Does the DIE have a ranges attribute?
733 bool HasRanges = false;
734
735 /// Is this DIE only a declaration?
736 bool IsDeclaration = false;
737
738 /// Is there a DW_AT_str_offsets_base in the CU?
739 bool AttrStrOffsetBaseSeen = false;
740
741 AttributesInfo() = default;
742 };
743
744 /// Helper for cloneDIE.
745 unsigned cloneAttribute(DIE &Die, const DWARFDie &InputDIE,
746 const DWARFFile &File, CompileUnit &U,
747 const DWARFFormValue &Val,
748 const AttributeSpec AttrSpec, unsigned AttrSize,
749 AttributesInfo &AttrInfo, bool IsLittleEndian);
750
751 /// Clone a string attribute described by \p AttrSpec and add
752 /// it to \p Die.
753 /// \returns the size of the new attribute.
754 unsigned cloneStringAttribute(DIE &Die, AttributeSpec AttrSpec,
755 const DWARFFormValue &Val, const DWARFUnit &U,
756 AttributesInfo &Info);
757
758 /// Clone an attribute referencing another DIE and add
759 /// it to \p Die.
760 /// \returns the size of the new attribute.
761 unsigned cloneDieReferenceAttribute(DIE &Die, const DWARFDie &InputDIE,
762 AttributeSpec AttrSpec,
763 unsigned AttrSize,
764 const DWARFFormValue &Val,
765 const DWARFFile &File,
766 CompileUnit &Unit);
767
768 /// Clone a DWARF expression that may be referencing another DIE.
769 void cloneExpression(DataExtractor &Data, DWARFExpression Expression,
770 const DWARFFile &File, CompileUnit &Unit,
771 SmallVectorImpl<uint8_t> &OutputBuffer,
772 int64_t AddrRelocAdjustment, bool IsLittleEndian);
773
774 /// Clone an attribute referencing another DIE and add
775 /// it to \p Die.
776 /// \returns the size of the new attribute.
777 unsigned cloneBlockAttribute(DIE &Die, const DWARFDie &InputDIE,
778 const DWARFFile &File, CompileUnit &Unit,
779 AttributeSpec AttrSpec,
780 const DWARFFormValue &Val,
781 bool IsLittleEndian);
782
783 /// Clone an attribute referencing another DIE and add
784 /// it to \p Die.
785 /// \returns the size of the new attribute.
786 unsigned cloneAddressAttribute(DIE &Die, const DWARFDie &InputDIE,
787 AttributeSpec AttrSpec, unsigned AttrSize,
788 const DWARFFormValue &Val,
789 const CompileUnit &Unit,
790 AttributesInfo &Info);
791
792 /// Clone a scalar attribute and add it to \p Die.
793 /// \returns the size of the new attribute.
794 unsigned cloneScalarAttribute(DIE &Die, const DWARFDie &InputDIE,
795 const DWARFFile &File, CompileUnit &U,
796 AttributeSpec AttrSpec,
797 const DWARFFormValue &Val, unsigned AttrSize,
798 AttributesInfo &Info);
799
800 /// Get the potential name and mangled name for the entity
801 /// described by \p Die and store them in \Info if they are not
802 /// already there.
803 /// \returns is a name was found.
804 bool getDIENames(const DWARFDie &Die, AttributesInfo &Info,
805 OffsetsStringPool &StringPool, bool StripTemplate = false);
806
807 uint32_t hashFullyQualifiedName(DWARFDie DIE, CompileUnit &U,
808 const DWARFFile &File,
809 int RecurseDepth = 0);
810
811 /// Helper for cloneDIE.
812 void addObjCAccelerator(CompileUnit &Unit, const DIE *Die,
813 DwarfStringPoolEntryRef Name,
814 OffsetsStringPool &StringPool, bool SkipPubSection);
815
816 void rememberUnitForMacroOffset(CompileUnit &Unit);
817
818 /// Clone and emit the line table for the specified \p Unit.
819 /// Translate directories and file names if necessary.
820 /// Relocate address ranges.
821 void generateLineTableForUnit(CompileUnit &Unit);
822 };
823
824 /// Assign an abbreviation number to \p Abbrev
825 void assignAbbrev(DIEAbbrev &Abbrev);
826
827 /// Compute and emit debug ranges(.debug_aranges, .debug_ranges,
828 /// .debug_rnglists) for \p Unit, patch the attributes referencing it.
829 void generateUnitRanges(CompileUnit &Unit, const DWARFFile &File,
830 DebugDieValuePool &AddrPool) const;
831
832 /// Emit the accelerator entries for \p Unit.
833 void emitAcceleratorEntriesForUnit(CompileUnit &Unit);
834
835 /// Patch the frame info for an object file and emit it.
836 void patchFrameInfoForObject(LinkContext &Context);
837
838 /// FoldingSet that uniques the abbreviations.
839 FoldingSet<DIEAbbrev> AbbreviationsSet;
840
841 /// Storage for the unique Abbreviations.
842 /// This is passed to AsmPrinter::emitDwarfAbbrevs(), thus it cannot be
843 /// changed to a vector of unique_ptrs.
844 std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
845
846 /// DIELoc objects that need to be destructed (but not freed!).
847 std::vector<DIELoc *> DIELocs;
848
849 /// DIEBlock objects that need to be destructed (but not freed!).
850 std::vector<DIEBlock *> DIEBlocks;
851
852 /// Allocator used for all the DIEValue objects.
853 BumpPtrAllocator DIEAlloc;
854 /// @}
855
856 std::unique_ptr<DwarfStreamer> TheDwarfEmitter;
857 std::vector<LinkContext> ObjectContexts;
858
859 /// The CIEs that have been emitted in the output section. The actual CIE
860 /// data serves a the key to this StringMap, this takes care of comparing the
861 /// semantics of CIEs defined in different object files.
862 StringMap<uint32_t> EmittedCIEs;
863
864 /// Offset of the last CIE that has been emitted in the output
865 /// .debug_frame section.
866 uint32_t LastCIEOffset = 0;
867
868 /// Apple accelerator tables.
869 AccelTable<DWARF5AccelTableStaticData> DebugNames;
870 AccelTable<AppleAccelTableStaticOffsetData> AppleNames;
871 AccelTable<AppleAccelTableStaticOffsetData> AppleNamespaces;
872 AccelTable<AppleAccelTableStaticOffsetData> AppleObjc;
873 AccelTable<AppleAccelTableStaticTypeData> AppleTypes;
874
875 /// Mapping the PCM filename to the DwoId.
876 StringMap<uint64_t> ClangModules;
877
878 DwarfLinkerClient DwarfLinkerClientID;
879
880 std::function<StringRef(StringRef)> StringsTranslator = nullptr;
881
882 /// A unique ID that identifies each compile unit.
883 unsigned UniqueUnitID = 0;
884
885 // error handler
887
888 // warning handler
889 messageHandler WarningHandler = nullptr;
890
891 /// linking options
892 struct DWARFLinkerOptions {
893 /// DWARF version for the output.
894 uint16_t TargetDWARFVersion = 0;
895
896 /// Generate processing log to the standard output.
897 bool Verbose = false;
898
899 /// Print statistics.
900 bool Statistics = false;
901
902 /// Verify the input DWARF.
903 bool VerifyInputDWARF = false;
904
905 /// Do not unique types according to ODR
906 bool NoODR = false;
907
908 /// Update
909 bool Update = false;
910
911 /// Whether we want a static variable to force us to keep its enclosing
912 /// function.
913 bool KeepFunctionForStatic = false;
914
915 /// Number of threads.
916 unsigned Threads = 1;
917
918 /// The accelerator table kinds
919 SmallVector<AccelTableKind, 1> AccelTables;
920
921 /// Prepend path for the clang modules.
922 std::string PrependPath;
923
924 // input verification handler
925 inputVerificationHandler InputVerificationHandler = nullptr;
926
927 /// A list of all .swiftinterface files referenced by the debug
928 /// info, mapping Module name to path on disk. The entries need to
929 /// be uniqued and sorted and there are only few entries expected
930 /// per compile unit, which is why this is a std::map.
931 /// this is dsymutil specific fag.
932 swiftInterfacesMap *ParseableSwiftInterfaces = nullptr;
933
934 /// A list of remappings to apply to file paths.
935 objectPrefixMap *ObjectPrefixMap = nullptr;
936 } Options;
937};
938
939} // end namespace llvm
940
941#endif // LLVM_DWARFLINKER_DWARFLINKER_H
This file contains support for writing accelerator tables.
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
dxil DXContainer Global Emitter
This file defines the DenseMap class.
std::string Name
uint64_t Size
LLVMContext & Context
ppc ctr loops PowerPC CTR Loops Verify
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
Definition: AccelTable.h:194
The AddressRanges class helps normalize address range collections.
AddressesMap represents information about valid addresses used by debug information.
Definition: DWARFLinker.h:37
virtual bool applyValidRelocs(MutableArrayRef< char > Data, uint64_t BaseOffset, bool IsLittleEndian)=0
Apply the valid relocations to the buffer Data, taking into account that Data is at BaseOffset in the...
virtual void clear()=0
Erases all data.
virtual bool hasValidRelocs()=0
Checks that there are valid relocations against a .debug_info section.
virtual std::optional< int64_t > getExprOpAddressRelocAdjustment(DWARFUnit &U, const DWARFExpression::Operation &Op, uint64_t StartOffset, uint64_t EndOffset)=0
Checks that the specified DWARF expression operand Op references live code section and returns the re...
virtual std::optional< int64_t > getSubprogramRelocAdjustment(const DWARFDie &DIE)=0
Checks that the specified subprogram DIE references the live code section and returns the relocation ...
virtual ~AddressesMap()
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:85
Stores all information relating to a compile unit, be it in its original instance in the object file ...
A structured debug information entry.
Definition: DIE.h:819
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Definition: DWARFContext.h:48
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition: DWARFDie.h:42
This class represents an Operation in the Expression.
This class represents DWARF information for source file and its address map.
Definition: DWARFLinker.h:268
std::unique_ptr< AddressesMap > Addresses
Helpful address information(list of valid address ranges, relocations).
Definition: DWARFLinker.h:283
DWARFFile(StringRef Name, std::unique_ptr< DWARFContext > Dwarf, std::unique_ptr< AddressesMap > Addresses, UnloadCallbackTy=nullptr)
Definition: DWARFLinker.h:271
std::function< void(StringRef FileName)> UnloadCallbackTy
Definition: DWARFLinker.h:270
StringRef FileName
The object file name.
Definition: DWARFLinker.h:277
std::unique_ptr< DWARFContext > Dwarf
The source DWARF information.
Definition: DWARFLinker.h:280
The core of the Dwarf linking logic.
Definition: DWARFLinker.h:305
void setVerbosity(bool Verbose)
A number of methods setting various linking options:
Definition: DWARFLinker.h:361
void setStatistics(bool Statistics)
Print statistics to standard output.
Definition: DWARFLinker.h:364
OutputFileType
Type of output file.
Definition: DWARFLinker.h:324
std::function< void(const DWARFFile &File, llvm::StringRef Output)> inputVerificationHandler
Definition: DWARFLinker.h:335
std::function< ErrorOr< DWARFFile & >(StringRef ContainerName, StringRef Path)> objFileLoader
Definition: DWARFLinker.h:338
std::function< void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)> messageHandler
Definition: DWARFLinker.h:309
void setNumThreads(unsigned NumThreads)
Use specified number of threads for parallel files linking.
Definition: DWARFLinker.h:385
void setKeepFunctionForStatic(bool KeepFunctionForStatic)
Set whether to keep the enclosing function for a static variable.
Definition: DWARFLinker.h:380
Error link()
Link debug info for added objFiles. Object files are linked all together.
DwarfEmitter * getEmitter()
void setObjectPrefixMap(objectPrefixMap *Map)
Set prefix map for objects.
Definition: DWARFLinker.h:413
void setPrependPath(const std::string &Ppath)
Set prepend path for clang modules.
Definition: DWARFLinker.h:394
AccelTableKind
The kind of accelerator tables we should emit.
Definition: DWARFLinker.h:330
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
@ Pub
.debug_pubnames, .debug_pubtypes
void setAllowNonDeterministicOutput(bool)
Allow generating valid, but non-deterministic output.
Definition: DWARFLinker.h:376
void setUpdateIndexTablesOnly(bool Update)
Update index tables only(do not modify rest of DWARF).
Definition: DWARFLinker.h:373
void setEstimatedObjfilesAmount(unsigned ObjFilesNum)
Set estimated objects files amount, for preliminary data allocation.
Definition: DWARFLinker.h:397
DWARFLinker(messageHandler ErrorHandler, messageHandler WarningHandler, std::function< StringRef(StringRef)> StringsTranslator)
Definition: DWARFLinker.h:310
void addAccelTableKind(AccelTableKind Kind)
Add kind of accelerator tables to be generated.
Definition: DWARFLinker.h:388
void setSwiftInterfacesMap(swiftInterfacesMap *Map)
Set map for Swift interfaces.
Definition: DWARFLinker.h:408
void addObjectFile(DWARFFile &File, objFileLoader Loader=nullptr, CompileUnitHandler OnCUDieLoaded=[](const DWARFUnit &) {})
Add object file to be linked.
Error setTargetDWARFVersion(uint16_t TargetDWARFVersion)
Set target DWARF version.
Definition: DWARFLinker.h:418
Error createEmitter(const Triple &TheTriple, OutputFileType FileType, raw_pwrite_stream &OutFile)
void setNoODR(bool NoODR)
Do not unique types according to ODR.
Definition: DWARFLinker.h:370
void setVerifyInputDWARF(bool Verify)
Verify the input DWARF.
Definition: DWARFLinker.h:367
static std::unique_ptr< DWARFLinker > createLinker(messageHandler ErrorHandler, messageHandler WarningHandler, std::function< StringRef(StringRef)> StringsTranslator=nullptr)
Definition: DWARFLinker.h:316
void setInputVerificationHandler(inputVerificationHandler Handler)
Set verification handler which would be used to report verification errors.
Definition: DWARFLinker.h:403
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:155
iterator end()
Definition: DenseMap.h:84
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:220
DwarfEmitter presents interface to generate all debug info tables.
Definition: DWARFLinker.h:98
virtual void emitCIE(StringRef CIEBytes)=0
Emit a CIE.
virtual void emitPubNamesForUnit(const CompileUnit &Unit)=0
Emit the .debug_pubnames contribution for Unit.
virtual void emitDwarfDebugArangesTable(const CompileUnit &Unit, const AddressRanges &LinkedRanges)=0
Emit .debug_aranges entries for Unit.
virtual uint64_t getLineSectionSize() const =0
Returns size of generated .debug_line section.
virtual MCSymbol * emitDwarfDebugRangeListHeader(const CompileUnit &Unit)=0
Emit debug ranges (.debug_ranges, .debug_rnglists) header.
virtual void emitAppleNames(AccelTable< AppleAccelTableStaticOffsetData > &Table)=0
Emit Apple names accelerator table.
virtual void emitDwarfDebugAddrsFooter(const CompileUnit &Unit, MCSymbol *EndLabel)=0
Emit .debug_addr footer.
virtual void emitCompileUnitHeader(CompileUnit &Unit, unsigned DwarfVersion)=0
Emit the compilation unit header for Unit in the .debug_info section.
virtual void emitDebugNames(AccelTable< DWARF5AccelTableStaticData > &Table)=0
Emit DWARF debug names.
virtual MCSymbol * emitDwarfDebugAddrsHeader(const CompileUnit &Unit)=0
Emit .debug_addr header.
virtual uint64_t getRngListsSectionSize() const =0
Returns size of generated .debug_rnglists section.
virtual void emitStrings(const NonRelocatableStringpool &Pool)=0
Emit the string table described by Pool into .debug_str table.
virtual void emitPubTypesForUnit(const CompileUnit &Unit)=0
Emit the .debug_pubtypes contribution for Unit.
virtual MCSymbol * emitDwarfDebugLocListHeader(const CompileUnit &Unit)=0
Emit debug locations (.debug_loc, .debug_loclists) header.
virtual void emitDwarfDebugLocListFragment(const CompileUnit &Unit, const DWARFLocationExpressionsVector &LinkedLocationExpression, PatchLocation Patch, DebugDieValuePool &AddrPool)=0
Emit debug locations (.debug_loc, .debug_loclists) fragment.
virtual void emitAppleNamespaces(AccelTable< AppleAccelTableStaticOffsetData > &Table)=0
Emit Apple namespaces accelerator table.
virtual void emitSwiftReflectionSection(llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind, StringRef Buffer, uint32_t Alignment, uint32_t Size)=0
Emit the swift reflection section stored in Buffer.
virtual uint64_t getDebugAddrSectionSize() const =0
Returns size of generated .debug_addr section.
virtual AsmPrinter & getAsmPrinter() const =0
Returns underlying AsmPrinter.
virtual void emitLineTableForUnit(const DWARFDebugLine::LineTable &LineTable, const CompileUnit &Unit, OffsetsStringPool &DebugStrPool, OffsetsStringPool &DebugLineStrPool)=0
Emit specified LineTable into .debug_line table.
virtual void emitMacroTables(DWARFContext *Context, const Offset2UnitMap &UnitMacroMap, OffsetsStringPool &StringPool)=0
Emit all available macro tables(DWARFv4 and DWARFv5).
virtual uint64_t getLocListsSectionSize() const =0
Returns size of generated .debug_loclists section.
virtual void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address, StringRef Bytes)=0
Emit an FDE with data Bytes.
virtual uint64_t getRangesSectionSize() const =0
Returns size of generated .debug_ranges section.
virtual uint64_t getDebugInfoSectionSize() const =0
Returns size of generated .debug_info section.
virtual ~DwarfEmitter()
virtual void finish()=0
Dump the file to the disk.
virtual void emitStringOffsets(const SmallVector< uint64_t > &StringOffsets, uint16_t TargetDWARFVersion)=0
Emit the debug string offset table described by StringOffsets into the .debug_str_offsets table.
virtual uint64_t getDebugMacInfoSectionSize() const =0
Returns size of generated .debug_macinfo section.
virtual void emitAbbrevs(const std::vector< std::unique_ptr< DIEAbbrev > > &Abbrevs, unsigned DwarfVersion)=0
Emit the abbreviation table Abbrevs to the .debug_abbrev section.
virtual void emitDIE(DIE &Die)=0
Recursively emit the DIE tree rooted at Die.
virtual void emitAppleTypes(AccelTable< AppleAccelTableStaticTypeData > &Table)=0
Emit Apple type accelerator table.
virtual void emitDwarfDebugRangeListFragment(const CompileUnit &Unit, const AddressRanges &LinkedRanges, PatchLocation Patch, DebugDieValuePool &AddrPool)=0
Emit debug ranges (.debug_ranges, .debug_rnglists) fragment.
virtual void emitDwarfDebugAddrs(const SmallVector< uint64_t > &Addrs, uint8_t AddrSize)=0
Emit the addresses described by Addrs into the .debug_addr section.
virtual void emitLineStrings(const NonRelocatableStringpool &Pool)=0
Emit the string table described by Pool into .debug_line_str table.
virtual void emitDwarfDebugLocListFooter(const CompileUnit &Unit, MCSymbol *EndLabel)=0
Emit debug locations (.debug_loc, .debug_loclists) footer.
virtual void emitDwarfDebugRangeListFooter(const CompileUnit &Unit, MCSymbol *EndLabel)=0
Emit debug ranges (.debug_ranges, .debug_rnglists) footer.
virtual uint64_t getDebugMacroSectionSize() const =0
Returns size of generated .debug_macro section.
virtual void emitSectionContents(StringRef SecData, StringRef SecName)=0
Emit section named SecName with data SecData.
virtual void emitSwiftAST(StringRef Buffer)=0
Emit the swift_ast section stored in Buffer.
virtual uint64_t getFrameSectionSize() const =0
Returns size of generated .debug_frame section.
virtual void emitAppleObjc(AccelTable< AppleAccelTableStaticOffsetData > &Table)=0
Emit Apple Objective-C accelerator table.
The Dwarf streaming logic.
Definition: DWARFStreamer.h:41
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:334
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
A string table that doesn't need relocations.
size_t size() const
Definition: SmallVector.h:91
void push_back(const T &Elt)
Definition: SmallVector.h:416
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Helper for making strong types.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
LLVM Value Representation.
Definition: Value.h:74
An efficient, type-erasing, non-owning reference to a callable.
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:428
Swift5ReflectionSectionKind
Definition: Swift.h:14
DWARFAbbreviationDeclaration::AttributeSpec AttributeSpec
Definition: LVELFReader.h:31
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:48
function_ref< void(const ErrorInfoBase &, StringRef)> ErrorHandler
Definition: DIPrinter.h:65
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::vector< std::unique_ptr< CompileUnit > > UnitListTy
Definition: DWARFLinker.h:264
function_ref< void(const DWARFUnit &Unit)> CompileUnitHandler
Definition: DWARFLinker.h:289
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1244
std::vector< DWARFLocationExpression > DWARFLocationExpressionsVector
Represents a set of absolute location expressions.
DwarfLinkerClient
Definition: DWARFLinker.h:31
@ Dwarf
DWARF v5 .debug_names.
StrongType< NonRelocatableStringpool, OffsetsTag > OffsetsStringPool
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition: Allocator.h:375
std::map< std::string, std::string > swiftInterfacesMap
Definition: DWARFLinker.h:286
@ Other
Any other memory.
DenseMap< uint64_t, CompileUnit * > Offset2UnitMap
Definition: DWARFLinker.h:76
std::map< std::string, std::string > objectPrefixMap
Definition: DWARFLinker.h:287
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1854
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition: STLExtras.h:1884
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
uint64_t getValueIndex(uint64_t Value)
Definition: DWARFLinker.h:82
SmallVector< uint64_t > DieValues
Definition: DWARFLinker.h:80
DenseMap< uint64_t, uint64_t > DieValueMap
Definition: DWARFLinker.h:79