Lines Matching +full:unit +full:- +full:address
1 //=== DWARFLinker.cpp -----------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
55 for (auto &Unit : Dwarf.compile_units()) {
56 Size += Unit->getLength();
66 return LHS < RHS->getOrigUnit().getNextUnitOffset();
68 return CU != Units.end() ? CU->get() : nullptr;
82 RefOffset = RefValue.getUnit()->getOffset() + *Off;
90 if (const auto RefDie = RefCU->getOrigUnit().getDIEForOffset(RefOffset)) {
282 Info.Prune &= Info.Ctxt && Info.Ctxt->getCanonicalDIEOffset();
284 Info.Prune &= Info.Ctxt && Info.Ctxt->getCanonicalDIEOffset() > 0 &&
285 Info.Ctxt->getCanonicalDIEOffset() <= ModulesEndOffset;
297 /// gather the child->parent relationships in the original compile unit.
333 // "The module-id should consist of only a single identifier,
343 // We treat non-C++ modules like namespaces for this reason.
363 Info.Ctxt->setDefinedInClangModule(Info.InModuleScope);
402 I->~DIEBlock();
404 I->~DIELoc();
428 Abbrev->findAttributeIndex(dwarf::DW_AT_location);
434 Abbrev->getAttributeOffsetFromIndex(*LocationIdx, DIE.getOffset(), *U);
438 Abbrev->getAttributeValueFromOffset(*LocationIdx, AttrOffset, *U);
445 std::optional<ArrayRef<uint8_t>> Expr = LocationValue->getAsBlock();
450 DataExtractor Data(toStringRef(*Expr), U->getContext().isLittleEndian(),
451 U->getAddressByteSize());
452 DWARFExpression Expression(Data, U->getAddressByteSize(),
453 U->getFormParams().Format);
470 if (NextIt == Expression.end() || !isTlsAddressCode(NextIt->getCode()))
475 // Check relocation for the address.
486 DIE.getDwarfUnit()->getIndexedAddressOffset(
488 // Check relocation for the address.
492 *AddressOffset + DIE.getDwarfUnit()->getAddressByteSize(),
517 Abbrev->findAttributeIndex(dwarf::DW_AT_const_value)) {
558 CompileUnit &Unit, CompileUnit::DIEInfo &MyInfo, unsigned Flags) {
565 assert(LowPc && "low_pc attribute is not an address.");
583 if (Unit.hasLabelAt(*LowPc))
586 DWARFUnit &OrigUnit = Unit.getOrigUnit();
587 // FIXME: dsymutil-classic compat. dsymutil-classic doesn't consider labels
594 Unit.addLabelLowPc(*LowPc, MyInfo.AddrAdjust);
613 Unit.addFunctionRange(*LowPc, *HighPc, MyInfo.AddrAdjust);
620 const DWARFFile &File, CompileUnit &Unit,
629 return shouldKeepSubprogramDIE(RelocMgr, DIE, File, Unit, MyInfo, Flags);
737 !Info.Ctxt->hasCanonicalDIE())
738 Info.Ctxt->setHasCanonicalDIE();
750 DWARFUnit &Unit = CU.getOrigUnit();
751 DWARFDataExtractor Data = Unit.getDebugInfoExtractor();
753 uint64_t Offset = Die.getOffset() + getULEB128Size(Abbrev->getCode());
756 for (const auto &AttrSpec : Abbrev->attributes()) {
761 Unit.getFormParams());
765 Val.extractValue(Data, &Offset, Unit.getFormParams(), &Unit);
769 CompileUnit::DIEInfo &Info = ReferencedCU->getInfo(RefDie);
774 // FIXME: compatibility with dsymutil-classic. UseODR shouldn't
776 // ReferencedCU->hasODR() && CU.hasODR().
778 // FIXME: compatibility with dsymutil-classic. There is no
782 Info.Ctxt->hasCanonicalDIE())
787 Info.Ctxt->hasCanonicalDIE()))
817 DWARFUnit &Unit = CU.getOrigUnit();
818 DWARFDie ParentDIE = Unit.getDIEAtIndex(AncestorIdx);
1020 Abbrev.setNumber(InSet->getNumber());
1026 Abbreviations.back()->AddAttribute(Attr);
1030 Abbreviations.back()->setNumber(Abbreviations.size());
1051 ObjFile.Addresses->getLibraryInstallName()) {
1069 ->sizeOf(U.getFormParams());
1082 CompileUnit &Unit) {
1083 const DWARFUnit &U = Unit.getOrigUnit();
1086 Ref = Val.getUnit()->getOffset() + *Off;
1102 CompileUnit::DIEInfo &RefInfo = RefUnit->getInfo(RefDie);
1107 RefInfo.Ctxt->getCanonicalDIEOffset()) {
1108 assert(RefInfo.Ctxt->hasCanonicalDIE() &&
1110 DIEInteger Attr(RefInfo.Ctxt->getCanonicalDIEOffset());
1125 (Unit.hasODR() && isODRAttribute(AttrSpec.Attr))) {
1128 // to find the unit offset. (We don't have a DwarfDebug)
1135 RefUnit->getStartOffset() + NewRefDie->getOffset();
1142 Unit.noteForwardReference(
1158 CompileUnit &Unit, SmallVectorImpl<uint8_t> &OutputBuffer,
1162 uint8_t OrigAddressByteSize = Unit.getOrigUnit().getAddressByteSize();
1167 // DW_OP_const_type is variable-length and has 3
1177 // This code assumes that the other non-typeref operand fits into 1 byte.
1179 uint32_t ULEBsize = Op.getEndOffset() - OpOffset - 1;
1197 RefOffset += Unit.getOrigUnit().getOffset();
1198 auto RefDie = Unit.getOrigUnit().getDIEForOffset(RefOffset);
1199 CompileUnit::DIEInfo &Info = Unit.getInfo(RefDie);
1201 Offset = Clone->getOffset();
1218 Unit.getOrigUnit().getAddrOffsetSectionItem(
1225 uint64_t LinkedAddress = SA->Address + AddrRelocAdjustment;
1236 Unit.getOrigUnit().getAddrOffsetSectionItem(
1252 formatv(("unsupported address size: {0}."), OrigAddressByteSize),
1259 uint64_t LinkedAddress = SA->Address + AddrRelocAdjustment;
1280 CompileUnit &Unit, AttributeSpec AttrSpec, const DWARFFormValue &Val,
1296 DWARFUnit &OrigUnit = Unit.getOrigUnit();
1308 cloneExpression(Data, Expr, File, Unit, Buffer,
1309 Unit.getInfo(InputDIE).AddrAdjust, IsLittleEndian);
1313 Attr->addValue(DIEAlloc, static_cast<dwarf::Attribute>(0),
1318 // Attr->setSize(Bytes.size()).
1320 Loc->setSize(Bytes.size());
1322 Block->setSize(Bytes.size());
1341 return Die.addValue(DIEAlloc, Value)->sizeOf(OrigUnit.getFormParams());
1346 unsigned AttrSize, const DWARFFormValue &Val, const CompileUnit &Unit,
1357 // Cloned Die may have address attributes relocated to a
1359 // - If high_pc is an address (Dwarf version == 2), then it might have been
1360 // relocated to a totally unrelated value (because the end address in the
1361 // object file might be start address of another function which got moved
1363 // - If address relocated in an inline_subprogram that happens at the
1366 // applyValidRelocs and here), read address attribute from InputDIE and apply
1373 std::optional<uint64_t> Addr = AddrAttribute->getAsAddress();
1375 Linker.reportWarning("Cann't read address attribute value.", ObjFile);
1381 if (std::optional<uint64_t> LowPC = Unit.getLowPc())
1387 if (uint64_t HighPc = Unit.getHighPc())
1398 return Unit.getOrigUnit().getAddressByteSize();
1406 ->sizeOf(Unit.getOrigUnit().getFormParams());
1411 CompileUnit &Unit, AttributeSpec AttrSpec, const DWARFFormValue &Val,
1419 const llvm::DWARFDebugMacro *Macro = File.Dwarf->getDebugMacinfo();
1420 if (Macro == nullptr || !Macro->hasEntryForOffset(*Offset))
1427 const llvm::DWARFDebugMacro *Macro = File.Dwarf->getDebugMacro();
1428 if (Macro == nullptr || !Macro->hasEntryForOffset(*Offset))
1441 ->sizeOf(Unit.getOrigUnit().getFormParams());
1481 Unit.getOrigUnit().getRnglistOffset(*Index);
1490 AttrSize = Unit.getOrigUnit().getFormParams().getDwarfOffsetByteSize();
1502 Unit.getOrigUnit().getLoclistOffset(*Index);
1511 AttrSize = Unit.getOrigUnit().getFormParams().getDwarfOffsetByteSize();
1514 std::optional<uint64_t> LowPC = Unit.getLowPc();
1517 // Dwarf >= 4 high_pc is an size, not an address.
1518 Value = Unit.getHighPc() - *LowPC;
1537 Unit.noteRangeAttribute(Die, Patch);
1542 Unit.getOrigUnit().getVersion())) {
1544 CompileUnit::DIEInfo &LocationDieInfo = Unit.getInfo(InputDIE);
1545 Unit.noteLocationAttribute({Patch, LocationDieInfo.InDebugMap
1563 CompileUnit &Unit, const DWARFFormValue &Val, const AttributeSpec AttrSpec,
1565 const DWARFUnit &U = Unit.getOrigUnit();
1583 File, Unit);
1589 return cloneBlockAttribute(Die, InputDIE, File, Unit, AttrSpec, Val,
1597 return cloneAddressAttribute(Die, InputDIE, AttrSpec, AttrSize, Val, Unit,
1611 return cloneScalarAttribute(Die, InputDIE, File, Unit, AttrSpec, Val,
1623 void DWARFLinker::DIECloner::addObjCAccelerator(CompileUnit &Unit,
1632 Unit.addNameAccelerator(Die, StringPool.getEntry(Names->Selector),
1634 Unit.addObjCAccelerator(Die, StringPool.getEntry(Names->ClassName),
1636 if (Names->ClassNameNoCategory)
1637 Unit.addObjCAccelerator(
1638 Die, StringPool.getEntry(*Names->ClassNameNoCategory), SkipPubSection);
1639 if (Names->MethodNameNoCategory)
1640 Unit.addNameAccelerator(
1641 Die, StringPool.getEntry(*Names->MethodNameNoCategory), SkipPubSection);
1680 const DWARFFile &File, CompileUnit &Unit,
1684 DWARFUnit &U = Unit.getOrigUnit();
1686 CompileUnit::DIEInfo &Info = Unit.getInfo(Idx);
1689 if (!Unit.getInfo(Idx).Keep)
1702 assert(Die->getTag() == InputDIE.getTag());
1703 Die->setOffset(OutOffset);
1704 if (isODRCanonicalCandidate(InputDIE, Unit) && Info.Ctxt &&
1705 (Info.Ctxt->getCanonicalDIEOffset() == 0)) {
1706 if (!Info.Ctxt->hasCanonicalDIE())
1707 Info.Ctxt->setHasCanonicalDIE();
1711 Info.Ctxt->setCanonicalDIEOffset(OutOffset + Unit.getStartOffset());
1718 // DW_TAG_compile_unit without any children, point to the next unit.
1727 SmallString<40> DIECopy(Data.getData().substr(Offset, NextOffset - Offset));
1732 ObjFile.Addresses->applyValidRelocs(DIECopy, Offset, Data.isLittleEndian());
1739 Offset += getULEB128Size(Abbrev->getCode());
1742 if (Die->getTag() == dwarf::DW_TAG_subprogram)
1746 if (Abbrev->getTag() == dwarf::DW_TAG_subprogram) {
1750 } else if (Abbrev->getTag() == dwarf::DW_TAG_variable) {
1751 // Function-local globals could be in the debug map even when the function
1755 // Location expressions referencing an address which is not in debug map
1763 ObjFile.Addresses->getLibraryInstallName();
1765 for (const auto &AttrSpec : Abbrev->attributes()) {
1775 Unit.getStartOffset() + OutOffset - CurAttrFixup.InputAttrStartOffset;
1781 AttrSize = Offset - AttrSize;
1784 cloneAttribute(*Die, InputDIE, File, Unit, Val, AttrSpec, AttrSize,
1786 if (FinalAttrSize != 0 && ObjFile.Addresses->needToSaveValidRelocs())
1793 // Add the DW_AT_APPLE_origin attribute to Compile Unit die if we have
1800 Die->addValue(DIEAlloc, dwarf::Attribute(dwarf::DW_AT_APPLE_origin),
1815 Unit.addNameAccelerator(Die, AttrInfo.MangledName,
1819 Unit.addNameAccelerator(Die, AttrInfo.NameWithoutTemplate,
1821 Unit.addNameAccelerator(Die, AttrInfo.Name,
1825 addObjCAccelerator(Unit, Die, AttrInfo.Name, DebugStrPool,
1831 Unit.addNamespaceAccelerator(Die, AttrInfo.Name);
1833 Unit.addNamespaceAccelerator(Die, AttrInfo.Name);
1837 uint32_t Hash = hashFullyQualifiedName(InputDIE, Unit, File);
1846 Unit.addTypeAccelerator(Die, AttrInfo.Name, ObjCClassIsImplementation,
1854 if (Unit.getInfo(Idx).Keep) {
1860 if (Unit.getOrigUnit().getVersion() >= 5 && !AttrInfo.AttrStrOffsetBaseSeen &&
1861 Die->getTag() == dwarf::DW_TAG_compile_unit) {
1863 Die->addValue(DIEAlloc, dwarf::DW_AT_str_offsets_base,
1868 DIEAbbrev NewAbbrev = Die->generateAbbrev();
1873 Die->setAbbrevNumber(NewAbbrev.getNumber());
1875 uint64_t AbbrevNumberSize = getULEB128Size(Die->getAbbrevNumber());
1885 ObjFile.Addresses->updateAndSaveValidRelocs(
1886 Unit.getOrigUnit().getVersion() >= 5, Unit.getOrigUnit().getOffset(),
1891 Die->setSize(OutOffset - Die->getOffset());
1897 if (DIE *Clone = cloneDIE(Child, File, Unit, PCOffset, OutOffset, Flags,
1899 Die->addChild(Clone);
1900 OutOffset = Clone->getOffset() + Clone->getSize();
1907 Die->setSize(OutOffset - Die->getOffset());
1914 void DWARFLinker::generateUnitRanges(CompileUnit &Unit, const DWARFFile &File,
1919 const auto &FunctionRanges = Unit.getFunctionRanges();
1921 // Build set of linked address ranges for unit function ranges.
1929 TheDwarfEmitter->emitDwarfDebugArangesTable(Unit, LinkedFunctionRanges);
1931 RngListAttributesTy AllRngListAttributes = Unit.getRangesAttributes();
1933 Unit.getUnitRangesAttribute();
1937 MCSymbol *EndLabel = TheDwarfEmitter->emitDwarfDebugRangeListHeader(Unit);
1939 // Read original address ranges, apply relocation value, emit linked address
1946 Unit.getOrigUnit().findRnglistFromOffset(AttributePatch.get())) {
1949 if (!CachedRange || !CachedRange->Range.contains(Range.LowPC))
1959 LinkedRanges.insert({Range.LowPC + CachedRange->Value,
1960 Range.HighPC + CachedRange->Value});
1968 TheDwarfEmitter->emitDwarfDebugRangeListFragment(
1969 Unit, LinkedRanges, AttributePatch, AddrPool);
1972 // Emit ranges for Unit AT_ranges attribute.
1974 TheDwarfEmitter->emitDwarfDebugRangeListFragment(
1975 Unit, LinkedFunctionRanges, *UnitRngListAttribute, AddrPool);
1978 TheDwarfEmitter->emitDwarfDebugRangeListFooter(Unit, EndLabel);
1983 CompileUnit &Unit, const DWARFFile &File,
1989 Unit.getLocationAttributes();
1995 MCSymbol *EndLabel = Emitter->emitDwarfDebugLocListHeader(Unit);
2001 Unit.getOrigUnit().findLoclistFromOffset(CurLocAttr.get());
2014 // Relocate address range.
2016 CurExpression.Range->LowPC + CurLocAttr.RelocAdjustment,
2017 CurExpression.Range->HighPC + CurLocAttr.RelocAdjustment};
2029 Emitter->emitDwarfDebugLocListFragment(Unit, LinkedLocationExpressions,
2034 Emitter->emitDwarfDebugLocListFooter(Unit, EndLabel);
2048 CompileUnit &Unit, const uint16_t DwarfVersion) const {
2059 MCSymbol *EndLabel = Emitter->emitDwarfDebugAddrsHeader(Unit);
2060 patchAddrBase(*Unit.getOutputUnitDIE(),
2061 DIEInteger(Emitter->getDebugAddrSectionSize()));
2062 Emitter->emitDwarfDebugAddrs(AddrPool.getValues(),
2063 Unit.getOrigUnit().getAddressByteSize());
2064 Emitter->emitDwarfDebugAddrsFooter(Unit, EndLabel);
2074 if (!Rows.empty() && Rows.back().Address < Seq.front().Address) {
2080 object::SectionedAddress Front = Seq.front().Address;
2082 Rows, [=](const DWARFDebugLine::Row &O) { return O.Address < Front; });
2088 if (InsertPoint != Rows.end() && InsertPoint->Address == Front &&
2089 InsertPoint->EndSequence) {
2109 void DWARFLinker::DIECloner::rememberUnitForMacroOffset(CompileUnit &Unit) {
2110 DWARFUnit &OrigUnit = Unit.getOrigUnit();
2115 UnitMacroMap.insert(std::make_pair(*MacroAttr, &Unit));
2121 UnitMacroMap.insert(std::make_pair(*MacroAttr, &Unit));
2126 void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
2131 DWARFDie CUDie = Unit.getOrigUnit().getUnitDIE();
2137 if (auto *OutputDIE = Unit.getOutputUnitDIE())
2138 patchStmtList(*OutputDIE, DIEInteger(Emitter->getLineSectionSize()));
2141 ObjFile.Dwarf->getLineTableForUnit(&Unit.getOrigUnit())) {
2146 LineTable.Prologue = LT->Prologue;
2150 LineTable.Rows = LT->Rows;
2156 LineTable.Sequences = LT->Sequences;
2160 NewRows.reserve(LT->Rows.size());
2166 const auto &FunctionRanges = Unit.getFunctionRanges();
2180 for (DWARFDebugLine::Row Row : LT->Rows) {
2182 // half-open, but consider accept the end address of the range if
2186 if (!CurrRange || !CurrRange->Range.contains(Row.Address.Address)) {
2190 CurrRange ? CurrRange->Range.end() + CurrRange->Value : -1ULL;
2191 CurrRange = FunctionRanges.getRangeThatContains(Row.Address.Address);
2192 if (StopAddress != -1ULL && !Seq.empty()) {
2193 // Insert end sequence row with the computed end address, but
2196 NextLine.Address.Address = StopAddress;
2213 // Relocate row address and add it to the current sequence.
2214 Row.Address.Address += CurrRange->Value;
2224 Emitter->emitLineTableForUnit(LineTable, Unit, DebugStrPool,
2230 void DWARFLinker::emitAcceleratorEntriesForUnit(CompileUnit &Unit) {
2235 for (const auto &Namespace : Unit.getNamespaces())
2236 AppleNamespaces.addName(Namespace.Name, Namespace.Die->getOffset() +
2237 Unit.getStartOffset());
2239 for (const auto &Pubname : Unit.getPubnames())
2241 Pubname.Die->getOffset() + Unit.getStartOffset());
2243 for (const auto &Pubtype : Unit.getPubtypes())
2245 Pubtype.Name, Pubtype.Die->getOffset() + Unit.getStartOffset(),
2246 Pubtype.Die->getTag(),
2251 for (const auto &ObjC : Unit.getObjC())
2253 ObjC.Die->getOffset() + Unit.getStartOffset());
2256 TheDwarfEmitter->emitPubNamesForUnit(Unit);
2257 TheDwarfEmitter->emitPubTypesForUnit(Unit);
2260 for (const auto &Namespace : Unit.getNamespaces())
2262 Namespace.Name, Namespace.Die->getOffset(),
2264 Namespace.Die->getTag(), Unit.getUniqueID(),
2265 Unit.getTag() == dwarf::DW_TAG_type_unit);
2266 for (const auto &Pubname : Unit.getPubnames())
2268 Pubname.Name, Pubname.Die->getOffset(),
2270 Pubname.Die->getTag(), Unit.getUniqueID(),
2271 Unit.getTag() == dwarf::DW_TAG_type_unit);
2272 for (const auto &Pubtype : Unit.getPubtypes())
2274 Pubtype.Name, Pubtype.Die->getOffset(),
2276 Pubtype.Die->getTag(), Unit.getUniqueID(),
2277 Unit.getTag() == dwarf::DW_TAG_type_unit);
2298 for (std::unique_ptr<CompileUnit> &Unit : Context.CompileUnits) {
2299 for (auto CurRange : Unit->getFunctionRanges())
2321 // The -4 is to account for the CIEId we just read.
2322 InputOffset += InitialLength - 4;
2329 // the function entry point, thus we can't just lookup the address
2350 std::make_pair(CIEData, TheDwarfEmitter->getFrameSectionSize()));
2353 LastCIEOffset = TheDwarfEmitter->getFrameSectionSize();
2354 IteratorInserted.first->getValue() = LastCIEOffset;
2355 TheDwarfEmitter->emitCIE(CIEData);
2358 // Emit the FDE with updated address and CIE pointer.
2361 unsigned FDERemainingBytes = InitialLength - (4 + SrcAddrSize);
2362 TheDwarfEmitter->emitFDE(IteratorInserted.first->getValue(), SrcAddrSize,
2363 Loc + Range->Value,
2386 if (!Ref->isFormClass(DWARFFormValue::FC_Reference))
2393 OrigUnit = &RefCU->getOrigUnit();
2398 unsigned Idx = OrigUnit->getDIEIndex(DIE);
2402 if (CU->getInfo(Idx).ParentIdx == 0 ||
2403 // FIXME: dsymutil-classic compatibility. Ignore modules.
2404 CU->getOrigUnit().getDIEAtIndex(CU->getInfo(Idx).ParentIdx).getTag() ==
2408 DWARFDie Die = OrigUnit->getDIEAtIndex(CU->getInfo(Idx).ParentIdx);
2480 if (!Quiet && Options.Verbose && (Cached->second != DwoId))
2535 // Don't use the cached binary holder because we have no thread-safety
2548 std::unique_ptr<CompileUnit> Unit;
2549 for (const auto &CU : ErrOrObj->Dwarf->compile_units()) {
2552 auto ChildCUDie = CU->getUnitDIE();
2557 if (Unit) {
2560 ": Clang modules are expected to have exactly 1 compile unit.\n");
2580 Unit = std::make_unique<CompileUnit>(*CU, UniqueUnitID++, !Options.NoODR,
2585 if (Unit)
2586 Context.ModuleUnits.emplace_back(RefModuleUnit{*ErrOrObj, std::move(Unit)});
2594 (Emitter == nullptr) ? 0 : Emitter->getDebugInfoSectionSize();
2598 const uint16_t DwarfVersion = CurrentUnit->getOrigUnit().getVersion();
2600 auto InputDIE = CurrentUnit->getOrigUnit().getUnitDIE();
2601 CurrentUnit->setStartOffset(OutputDebugInfoSize);
2603 OutputDebugInfoSize = CurrentUnit->computeNextUnitOffset(DwarfVersion);
2606 if (CurrentUnit->getInfo(0).Keep) {
2607 // Clone the InputDIE into your Unit DIE in our compile unit since it
2609 CurrentUnit->createOutputDIE();
2612 0, IsLittleEndian, CurrentUnit->getOutputUnitDIE());
2615 OutputDebugInfoSize = CurrentUnit->computeNextUnitOffset(DwarfVersion);
2631 DWARFUnit &OrigUnit = CurrentUnit->getOrigUnit();
2649 Emitter->emitMacroTables(File.Dwarf.get(), UnitMacroMap, DebugStrPool);
2651 // Emit all the compile unit's debug information.
2653 CurrentUnit->fixupForwardReferences();
2655 if (!CurrentUnit->getOutputUnitDIE())
2658 unsigned DwarfVersion = CurrentUnit->getOrigUnit().getVersion();
2660 assert(Emitter->getDebugInfoSectionSize() ==
2661 CurrentUnit->getStartOffset());
2662 Emitter->emitCompileUnitHeader(*CurrentUnit, DwarfVersion);
2663 Emitter->emitDIE(*CurrentUnit->getOutputUnitDIE());
2664 assert(Emitter->getDebugInfoSectionSize() ==
2665 CurrentUnit->computeNextUnitOffset(DwarfVersion));
2669 return OutputDebugInfoSize - StartOutputDebugInfoSize;
2673 TheDwarfEmitter->emitSectionContents(Dwarf.getDWARFObj().getLocSection().Data,
2675 TheDwarfEmitter->emitSectionContents(
2678 TheDwarfEmitter->emitSectionContents(
2680 TheDwarfEmitter->emitSectionContents(Dwarf.getDWARFObj().getArangesSection(),
2682 TheDwarfEmitter->emitSectionContents(
2684 TheDwarfEmitter->emitSectionContents(
2687 TheDwarfEmitter->emitSectionContents(
2698 ObjectContexts.back().File.Dwarf->compile_units()) {
2699 DWARFDie CUDie = CU->getUnitDIE();
2741 // Look for relocations that correspond to address map entries.
2746 !OptContext.File.Addresses->hasValidRelocs()) {
2761 if (!OptContext.File.Dwarf->types_section_units().empty()) {
2772 OptContext.File.Dwarf->getNumCompileUnits());
2773 for (const auto &CU : OptContext.File.Dwarf->compile_units()) {
2774 auto CUDie = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/true);
2776 outs() << "Input compilation unit:";
2798 : TheDwarfEmitter->getDebugInfoSectionSize();
2807 // parallel with emitting the previous compile unit.
2814 for (const auto &CU : Context.File.Dwarf->compile_units()) {
2815 // Previously we only extracted the unit DIEs. We need the full debug info
2817 auto CUDie = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/false);
2829 auto CUDie = CurrentUnit->getOrigUnit().getUnitDIE();
2832 analyzeContextInfo(CurrentUnit->getOrigUnit().getUnitDIE(), 0,
2856 // cross-cu references require the ParentIdx to be setup for every CU in
2860 CurrentUnit->markEverythingAsKept();
2865 CurrentUnit->getOrigUnit().getUnitDIE(),
2876 if (OptContext.File.Addresses->hasValidRelocs() ||
2885 OptContext.File.Dwarf->isLittleEndian());
2891 // Clean-up before starting working on the next object.
2898 TheDwarfEmitter->emitAbbrevs(Abbreviations, Options.TargetDWARFVersion);
2899 TheDwarfEmitter->emitStrings(DebugStrPool);
2900 TheDwarfEmitter->emitStringOffsets(StringOffsetPool.getValues(),
2902 TheDwarfEmitter->emitLineStrings(DebugLineStrPool);
2906 TheDwarfEmitter->emitAppleNamespaces(AppleNamespaces);
2907 TheDwarfEmitter->emitAppleNames(AppleNames);
2908 TheDwarfEmitter->emitAppleTypes(AppleTypes);
2909 TheDwarfEmitter->emitAppleObjc(AppleObjc);
2916 TheDwarfEmitter->emitDebugNames(DebugNames);
2973 auto ComputePercentange = [](int64_t Input, int64_t Output) -> float {
2974 const float Difference = Output - Input;
2983 const char *FormatStr = "{0,-45} {1,10}b {2,10}b {3,8:P}\n";
2987 outs() << "----------------------------------------------------------------"
2988 "---------------\n";
2991 outs() << "----------------------------------------------------------------"
2992 "---------------\n";
3003 outs() << "----------------------------------------------------------------"
3004 "---------------\n";
3007 outs() << "----------------------------------------------------------------"
3008 "---------------\n\n";
3014 Error DWARFLinker::cloneModuleUnit(LinkContext &Context, RefModuleUnit &Unit,
3020 assert(Unit.Unit.get() != nullptr);
3022 if (!Unit.Unit->getOrigUnit().getUnitDIE().hasChildren())
3027 outs() << "cloning .debug_info from " << Unit.File.FileName << "\n";
3031 analyzeContextInfo(Unit.Unit->getOrigUnit().getUnitDIE(), 0, *(Unit.Unit),
3038 Unit.Unit->markEverythingAsKept();
3040 // Clone unit.
3042 CompileUnits.emplace_back(std::move(Unit.Unit));
3044 DIECloner(*this, TheDwarfEmitter, Unit.File, DIEAlloc, CompileUnits,
3046 .cloneAllCompileUnits(*Unit.File.Dwarf, Unit.File,
3047 Unit.File.Dwarf->isLittleEndian());
3057 if (!File.Dwarf->verify(OS, DumpOpts.noImplicitRecursion())) {