Index: llvm/include/llvm/DWARFLinker/DWARFLinker.h =================================================================== --- llvm/include/llvm/DWARFLinker/DWARFLinker.h +++ llvm/include/llvm/DWARFLinker/DWARFLinker.h @@ -75,22 +75,22 @@ using Offset2UnitMap = DenseMap; -struct DebugAddrPool { - DenseMap AddrIndexMap; - SmallVector Addrs; - - uint64_t getAddrIndex(uint64_t Addr) { - DenseMap::iterator It = AddrIndexMap.find(Addr); - if (It == AddrIndexMap.end()) { - It = AddrIndexMap.insert(std::make_pair(Addr, Addrs.size())).first; - Addrs.push_back(Addr); +struct DebugDieValuePool { + DenseMap DieValueMap; + SmallVector DieValues; + + uint64_t getValueIndex(uint64_t Value) { + DenseMap::iterator It = DieValueMap.find(Value); + if (It == DieValueMap.end()) { + It = DieValueMap.insert(std::make_pair(Value, DieValues.size())).first; + DieValues.push_back(Value); } return It->second; } void clear() { - AddrIndexMap.clear(); - Addrs.clear(); + DieValueMap.clear(); + DieValues.clear(); } }; @@ -113,6 +113,11 @@ /// Emit the string table described by \p Pool into .debug_str table. virtual void emitStrings(const NonRelocatableStringpool &Pool) = 0; + /// Emit the debug string offset table described by \p StringOffsets into the + /// .debug_string_offset table. + virtual void + emitStringOffsets(const SmallVector &StringOffsets, bool AttrStrOffsetBaseSeen) = 0; + /// Emit the string table described by \p Pool into .debug_line_str table. virtual void emitLineStrings(const NonRelocatableStringpool &Pool) = 0; @@ -142,7 +147,7 @@ /// Emit debug ranges (.debug_ranges, .debug_rnglists) fragment. virtual void emitDwarfDebugRangeListFragment( const CompileUnit &Unit, const AddressRanges &LinkedRanges, - PatchLocation Patch, DebugAddrPool &AddrPool) = 0; + PatchLocation Patch, DebugDieValuePool &AddrPool) = 0; /// Emit debug ranges (.debug_ranges, .debug_rnglists) footer. virtual void emitDwarfDebugRangeListFooter(const CompileUnit &Unit, @@ -155,7 +160,7 @@ virtual void emitDwarfDebugLocListFragment( const CompileUnit &Unit, const DWARFLocationExpressionsVector &LinkedLocationExpression, - PatchLocation Patch, DebugAddrPool &AddrPool) = 0; + PatchLocation Patch, DebugDieValuePool &AddrPool) = 0; /// Emit debug locations (.debug_loc, .debug_loclists) footer. virtual void emitDwarfDebugLocListFooter(const CompileUnit &Unit, @@ -607,6 +612,7 @@ DeclContextTree &ODRContexts, OffsetsStringPool &DebugStrPool, OffsetsStringPool &DebugLineStrPool, + DebugDieValuePool &StringOffsetPool, unsigned Indent = 0); unsigned shouldKeepDIE(AddressesMap &RelocMgr, const DWARFDie &DIE, @@ -654,7 +660,9 @@ DWARFFile &ObjFile; OffsetsStringPool &DebugStrPool; OffsetsStringPool &DebugLineStrPool; - DebugAddrPool AddrPool; + DebugDieValuePool &StringOffsetPool; + DebugDieValuePool AddrPool; + bool StrxFoundInCU; /// Allocator used for all the DIEValue objects. BumpPtrAllocator &DIEAlloc; @@ -672,10 +680,12 @@ BumpPtrAllocator &DIEAlloc, std::vector> &CompileUnits, bool Update, OffsetsStringPool &DebugStrPool, - OffsetsStringPool &DebugLineStrPool) + OffsetsStringPool &DebugLineStrPool, + DebugDieValuePool &StringOffsetPool) : Linker(Linker), Emitter(Emitter), ObjFile(ObjFile), DebugStrPool(DebugStrPool), DebugLineStrPool(DebugLineStrPool), - DIEAlloc(DIEAlloc), CompileUnits(CompileUnits), Update(Update) {} + StringOffsetPool(StringOffsetPool), DIEAlloc(DIEAlloc), + CompileUnits(CompileUnits), Update(Update) {} /// Recursively clone \p InputDIE into an tree of DIE objects /// where useless (as decided by lookForDIEsToKeep()) bits have been @@ -825,7 +835,7 @@ /// Compute and emit debug ranges(.debug_aranges, .debug_ranges, /// .debug_rnglists) for \p Unit, patch the attributes referencing it. void generateUnitRanges(CompileUnit &Unit, const DWARFFile &File, - DebugAddrPool &AddrPool) const; + DebugDieValuePool &AddrPool) const; /// Emit the accelerator entries for \p Unit. void emitAcceleratorEntriesForUnit(CompileUnit &Unit); @@ -863,6 +873,8 @@ /// .debug_frame section. uint32_t LastCIEOffset = 0; + bool AttrStrOffsetBaseSeen = false; + /// Apple accelerator tables. AccelTable DebugNames; AccelTable AppleNames; Index: llvm/include/llvm/DWARFLinker/DWARFStreamer.h =================================================================== --- llvm/include/llvm/DWARFLinker/DWARFStreamer.h +++ llvm/include/llvm/DWARFLinker/DWARFStreamer.h @@ -81,6 +81,10 @@ /// Emit the string table described by \p Pool into .debug_str table. void emitStrings(const NonRelocatableStringpool &Pool) override; + /// Emit the debug string offset table described by \p StringOffsets into the + /// .debug_string_offset table. + void emitStringOffsets(const SmallVector &StringOffset, bool AttrStrOffsetBaseSeen) override; + /// Emit the string table described by \p Pool into .debug_line_str table. void emitLineStrings(const NonRelocatableStringpool &Pool) override; @@ -99,7 +103,7 @@ void emitDwarfDebugRangeListFragment(const CompileUnit &Unit, const AddressRanges &LinkedRanges, PatchLocation Patch, - DebugAddrPool &AddrPool) override; + DebugDieValuePool &AddrPool) override; /// Emit debug ranges(.debug_ranges, .debug_rnglists) footer. void emitDwarfDebugRangeListFooter(const CompileUnit &Unit, @@ -123,7 +127,7 @@ void emitDwarfDebugLocListFragment( const CompileUnit &Unit, const DWARFLocationExpressionsVector &LinkedLocationExpression, - PatchLocation Patch, DebugAddrPool &AddrPool) override; + PatchLocation Patch, DebugDieValuePool &AddrPool) override; /// Emit debug ranges(.debug_loc, .debug_loclists) footer. void emitDwarfDebugLocListFooter(const CompileUnit &Unit, @@ -222,7 +226,7 @@ void emitDwarfDebugRngListsTableFragment(const CompileUnit &Unit, const AddressRanges &LinkedRanges, PatchLocation Patch, - DebugAddrPool &AddrPool); + DebugDieValuePool &AddrPool); /// Emit piece of .debug_loc for \p LinkedRanges. void emitDwarfDebugLocTableFragment( @@ -234,7 +238,7 @@ void emitDwarfDebugLocListsTableFragment( const CompileUnit &Unit, const DWARFLocationExpressionsVector &LinkedLocationExpression, - PatchLocation Patch, DebugAddrPool &AddrPool); + PatchLocation Patch, DebugDieValuePool &AddrPool); /// \defgroup Line table emission /// @{ @@ -293,6 +297,7 @@ uint64_t MacInfoSectionSize = 0; uint64_t MacroSectionSize = 0; uint64_t AddrSectionSize = 0; + uint64_t StrOffsetSectionSize = 0; /// Keep track of emitted CUs and their Unique ID. struct EmittedUnit { Index: llvm/lib/DWARFLinker/DWARFLinker.cpp =================================================================== --- llvm/lib/DWARFLinker/DWARFLinker.cpp +++ llvm/lib/DWARFLinker/DWARFLinker.cpp @@ -1044,32 +1044,41 @@ unsigned DWARFLinker::DIECloner::cloneStringAttribute(DIE &Die, AttributeSpec AttrSpec, const DWARFFormValue &Val, - const DWARFUnit &, + const DWARFUnit &U, AttributesInfo &Info) { std::optional String = dwarf::toString(Val); if (!String) return 0; - DwarfStringPoolEntryRef StringEntry; if (AttrSpec.Form == dwarf::DW_FORM_line_strp) { StringEntry = DebugLineStrPool.getEntry(*String); } else { StringEntry = DebugStrPool.getEntry(*String); - // Update attributes info. if (AttrSpec.Attr == dwarf::DW_AT_name) Info.Name = StringEntry; else if (AttrSpec.Attr == dwarf::DW_AT_MIPS_linkage_name || AttrSpec.Attr == dwarf::DW_AT_linkage_name) Info.MangledName = StringEntry; - + if (AttrSpec.Form == dwarf::DW_FORM_strx || + (AttrSpec.Form >= dwarf::DW_FORM_strx1 && + AttrSpec.Form <= dwarf::DW_FORM_strx4)) { + auto StringOffsetIndex = + StringOffsetPool.getValueIndex(StringEntry.getOffset()); + // Mark StrxFoundInCU as true if a DW_FORM_strx* is found in any Die of a + // CU, use it to throw an error if a DW_AT_str_offsets_base is not found + // in the CU. + StrxFoundInCU = true; + return Die + .addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr), + dwarf::DW_FORM_strx, DIEInteger(StringOffsetIndex)) + ->sizeOf(U.getFormParams()); + } // Switch everything to out of line strings. AttrSpec.Form = dwarf::DW_FORM_strp; } - Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr), AttrSpec.Form, DIEInteger(StringEntry.getOffset())); - return 4; } @@ -1389,7 +1398,7 @@ return Unit.getOrigUnit().getAddressByteSize(); } - auto AddrIndex = AddrPool.getAddrIndex(*Addr); + auto AddrIndex = AddrPool.getValueIndex(*Addr); return Die .addValue(DIEAlloc, static_cast(AttrSpec.Attr), @@ -1664,9 +1673,6 @@ // Since DW_AT_rnglists_base is used for only DW_FORM_rnglistx the // DW_AT_rnglists_base is removed. return !Update; - case dwarf::DW_AT_str_offsets_base: - // FIXME: Use the string offset table with Dwarf 5. - return true; case dwarf::DW_AT_loclists_base: // In case !Update the .debug_addr table is not generated/preserved. // Thus instead of DW_FORM_loclistx the DW_FORM_sec_offset is used. @@ -1774,6 +1780,12 @@ Val.extractValue(Data, &Offset, U.getFormParams(), &U); AttrSize = Offset - AttrSize; + // Mark AttrStrOffsetBaseSeen as true, if any CU has an + // DW_AT_str_offsets_base, so a .debug_str_offsets section header is + // emitted. + if (AttrSpec.Attr == dwarf::DW_AT_str_offsets_base) + Linker.AttrStrOffsetBaseSeen = true; + OutOffset += cloneAttribute(*Die, InputDIE, File, Unit, Val, AttrSpec, AttrSize, AttrInfo, IsLittleEndian); } @@ -1869,7 +1881,7 @@ /// entries and emit them in the output file. Update the relevant attributes /// to point at the new entries. void DWARFLinker::generateUnitRanges(CompileUnit &Unit, const DWARFFile &File, - DebugAddrPool &AddrPool) const { + DebugDieValuePool &AddrPool) const { if (LLVM_UNLIKELY(Options.Update)) return; @@ -2001,6 +2013,18 @@ llvm_unreachable("Didn't find a DW_AT_addr_base in cloned DIE!"); } +static void patchStrOffsetsBase(DIE &Die, DIEInteger Offset, bool StrxFoundInCU) { + for (auto &V : Die.values()) + if (V.getAttribute() == dwarf::DW_AT_str_offsets_base) { + V = DIEValue(V.getAttribute(), V.getForm(), Offset); + return; + } + // If there are no DW_FORM_strx* in the Compile Unit, do not expect to find a + // DW_AT_str_offsets_base. + if (StrxFoundInCU) + llvm_unreachable("Didn't find a DW_AT_str_offsets_base in cloned DIE!"); +} + void DWARFLinker::DIECloner::emitDebugAddrSection( CompileUnit &Unit, const uint16_t DwarfVersion) const { @@ -2011,13 +2035,14 @@ if (DwarfVersion < 5) return; - if (AddrPool.Addrs.empty()) + if (AddrPool.DieValues.empty()) return; MCSymbol *EndLabel = Emitter->emitDwarfDebugAddrsHeader(Unit); patchAddrBase(*Unit.getOutputUnitDIE(), DIEInteger(Emitter->getDebugAddrSectionSize())); - Emitter->emitDwarfDebugAddrs(AddrPool.Addrs, Unit.getOrigUnit().getAddressByteSize()); + Emitter->emitDwarfDebugAddrs(AddrPool.DieValues, + Unit.getOrigUnit().getAddressByteSize()); Emitter->emitDwarfDebugAddrsFooter(Unit, EndLabel); } @@ -2543,6 +2568,7 @@ const uint64_t StartOutputDebugInfoSize = OutputDebugInfoSize; for (auto &CurrentUnit : CompileUnits) { + StrxFoundInCU = false; const uint16_t DwarfVersion = CurrentUnit->getOrigUnit().getVersion(); const uint32_t UnitHeaderSize = DwarfVersion >= 5 ? 12 : 11; auto InputDIE = CurrentUnit->getOrigUnit().getUnitDIE(); @@ -2558,6 +2584,12 @@ rememberUnitForMacroOffset(*CurrentUnit); cloneDIE(InputDIE, File, *CurrentUnit, 0 /* PC offset */, UnitHeaderSize, 0, IsLittleEndian, CurrentUnit->getOutputUnitDIE()); + // dsymutil will emit only one .debug_str_offset contribution for all + // compile units, therefore the DW_AT_str_offsets_base for all CUs needs + // to be patched up to be the start of the section after the header, which + // will be 8 bytes. + if (DwarfVersion >= 5) + patchStrOffsetsBase(*CurrentUnit->getOutputUnitDIE(), DIEInteger(8), StrxFoundInCU); } OutputDebugInfoSize = CurrentUnit->computeNextUnitOffset(DwarfVersion); @@ -2731,6 +2763,7 @@ // reproducibility. OffsetsStringPool DebugStrPool(StringsTranslator, true); OffsetsStringPool DebugLineStrPool(StringsTranslator, false); + DebugDieValuePool StringOffsetPool; // ODR Contexts for the optimize. DeclContextTree ODRContexts; @@ -2797,7 +2830,7 @@ for (auto &CU : OptContext.ModuleUnits) { if (Error Err = cloneModuleUnit(OptContext, CU, ODRContexts, DebugStrPool, - DebugLineStrPool)) + DebugLineStrPool, StringOffsetPool)) reportWarning(toString(std::move(Err)), CU.File); } } @@ -2894,7 +2927,7 @@ SizeByObject[OptContext.File.FileName].Output = DIECloner(*this, TheDwarfEmitter.get(), OptContext.File, DIEAlloc, OptContext.CompileUnits, Options.Update, DebugStrPool, - DebugLineStrPool) + DebugLineStrPool, StringOffsetPool) .cloneAllCompileUnits(*OptContext.File.Dwarf, OptContext.File, OptContext.File.Dwarf->isLittleEndian()); } @@ -2911,6 +2944,7 @@ if (TheDwarfEmitter != nullptr) { TheDwarfEmitter->emitAbbrevs(Abbreviations, Options.TargetDWARFVersion); TheDwarfEmitter->emitStrings(DebugStrPool); + TheDwarfEmitter->emitStringOffsets(StringOffsetPool.DieValues, AttrStrOffsetBaseSeen); TheDwarfEmitter->emitLineStrings(DebugLineStrPool); for (AccelTableKind TableKind : Options.AccelTables) { switch (TableKind) { @@ -3027,6 +3061,7 @@ DeclContextTree &ODRContexts, OffsetsStringPool &DebugStrPool, OffsetsStringPool &DebugLineStrPool, + DebugDieValuePool &StringOffsetPool, unsigned Indent) { assert(Unit.Unit.get() != nullptr); @@ -3053,7 +3088,7 @@ CompileUnits.emplace_back(std::move(Unit.Unit)); assert(TheDwarfEmitter); DIECloner(*this, TheDwarfEmitter.get(), Unit.File, DIEAlloc, CompileUnits, - Options.Update, DebugStrPool, DebugLineStrPool) + Options.Update, DebugStrPool, DebugLineStrPool, StringOffsetPool) .cloneAllCompileUnits(*Unit.File.Dwarf, Unit.File, Unit.File.Dwarf->isLittleEndian()); return Error::success(); Index: llvm/lib/DWARFLinker/DWARFStreamer.cpp =================================================================== --- llvm/lib/DWARFLinker/DWARFStreamer.cpp +++ llvm/lib/DWARFLinker/DWARFStreamer.cpp @@ -258,6 +258,39 @@ } } +/// Emit the debug string offset table described by \p StringOffsets into the +/// .debug_string_offset table. +void DwarfStreamer::emitStringOffsets( + const SmallVector &StringOffsets, bool AttrStrOffsetBaseSeen) { + + if (StringOffsets.empty() && !AttrStrOffsetBaseSeen) + return; + + Asm->OutStreamer->switchSection(MOFI->getDwarfStrOffSection()); + + MCSymbol *BeginLabel = Asm->createTempSymbol("Bdebugstroff"); + MCSymbol *EndLabel = Asm->createTempSymbol("Edebugstroff"); + + // Length. + Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t)); + Asm->OutStreamer->emitLabel(BeginLabel); + StrOffsetSectionSize += sizeof(uint32_t); + + // Version. + MS->emitInt16(5); + StrOffsetSectionSize += sizeof(uint16_t); + + // Padding. + MS->emitInt16(0); + StrOffsetSectionSize += sizeof(uint16_t); + + for (auto Off : StringOffsets) { + Asm->OutStreamer->emitInt32(Off); + StrOffsetSectionSize += sizeof(uint32_t); + } + Asm->OutStreamer->emitLabel(EndLabel); +} + /// Emit the debug_line_str section stored in \p Pool. void DwarfStreamer::emitLineStrings(const NonRelocatableStringpool &Pool) { Asm->OutStreamer->switchSection(MOFI->getDwarfLineStrSection()); @@ -455,7 +488,7 @@ void DwarfStreamer::emitDwarfDebugRangeListFragment( const CompileUnit &Unit, const AddressRanges &LinkedRanges, - PatchLocation Patch, DebugAddrPool &AddrPool) { + PatchLocation Patch, DebugDieValuePool &AddrPool) { if (Unit.getOrigUnit().getVersion() < 5) { emitDwarfDebugRangesTableFragment(Unit, LinkedRanges, Patch); return; @@ -478,7 +511,7 @@ void DwarfStreamer::emitDwarfDebugRngListsTableFragment( const CompileUnit &Unit, const AddressRanges &LinkedRanges, - PatchLocation Patch, DebugAddrPool &AddrPool) { + PatchLocation Patch, DebugDieValuePool &AddrPool) { Patch.set(RngListsSectionSize); // Make .debug_rnglists to be current section. @@ -494,7 +527,7 @@ MS->emitInt8(dwarf::DW_RLE_base_addressx); RngListsSectionSize += 1; RngListsSectionSize += - MS->emitULEB128IntValue(AddrPool.getAddrIndex(*BaseAddress)); + MS->emitULEB128IntValue(AddrPool.getValueIndex(*BaseAddress)); } // Emit type of entry. @@ -554,7 +587,7 @@ void DwarfStreamer::emitDwarfDebugLocListFragment( const CompileUnit &Unit, const DWARFLocationExpressionsVector &LinkedLocationExpression, - PatchLocation Patch, DebugAddrPool &AddrPool) { + PatchLocation Patch, DebugDieValuePool &AddrPool) { if (Unit.getOrigUnit().getVersion() < 5) { emitDwarfDebugLocTableFragment(Unit, LinkedLocationExpression, Patch); return; @@ -672,7 +705,7 @@ void DwarfStreamer::emitDwarfDebugLocListsTableFragment( const CompileUnit &Unit, const DWARFLocationExpressionsVector &LinkedLocationExpression, - PatchLocation Patch, DebugAddrPool &AddrPool) { + PatchLocation Patch, DebugDieValuePool &AddrPool) { Patch.set(LocListsSectionSize); // Make .debug_loclists the current section. @@ -691,7 +724,7 @@ MS->emitInt8(dwarf::DW_LLE_base_addressx); LocListsSectionSize += 1; LocListsSectionSize += - MS->emitULEB128IntValue(AddrPool.getAddrIndex(*BaseAddress)); + MS->emitULEB128IntValue(AddrPool.getValueIndex(*BaseAddress)); } // Emit type of entry. Index: llvm/test/tools/dsymutil/ARM/dwarf5-addr_base.test =================================================================== --- llvm/test/tools/dsymutil/ARM/dwarf5-addr_base.test +++ llvm/test/tools/dsymutil/ARM/dwarf5-addr_base.test @@ -53,29 +53,29 @@ RUN: llvm-dwarfdump %t.dir/dwarf5-addr_base.dSYM -a --verbose | FileCheck %s --check-prefix=UPD CHECK: .debug_info contents: -CHECK-NEXT: 0x00000000: Compile Unit: length = 0x00000061, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000065) +CHECK-NEXT: 0x00000000: Compile Unit: length = 0x0000004a, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 CHECK: 0x0000000c: DW_TAG_compile_unit [1] * CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) -CHECK: 0x00000037: DW_TAG_subprogram [2] * (0x0000000c) +CHECK: 0x0000002c: DW_TAG_subprogram [2] * (0x0000000c) CHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x[[ADDR1:[0-9a-f]+]]) -CHECK: 0x00000065: Compile Unit: length = 0x00000061, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x000000ca) +CHECK: 0x0000004e: Compile Unit: length = 0x0000004a, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 -CHECK: 0x00000071: DW_TAG_compile_unit [1] * +CHECK: 0x0000005a: DW_TAG_compile_unit [1] * CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000018) -CHECK: 0x0000009c: DW_TAG_subprogram [2] * (0x00000071) +CHECK: 0x0000007a: DW_TAG_subprogram [2] * (0x0000005a) CHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x[[ADDR2:[0-9a-f]+]]) -CHECK: 0x000000ca: Compile Unit: length = 0x0000005a, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000128) +CHECK: 0x0000009c: Compile Unit: length = 0x00000043, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 -CHECK: 0x000000d6: DW_TAG_compile_unit [5] * +CHECK: 0x000000a8: DW_TAG_compile_unit [5] * CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000028) -CHECK: 0x000000fa: DW_TAG_subprogram [2] * (0x000000d6) +CHECK: 0x000000c1: DW_TAG_subprogram [2] * (0x000000a8) CHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x[[ADDR3:[0-9a-f]+]]) CHECK: .debug_addr contents: @@ -93,44 +93,44 @@ CHECK-NEXT: ] UPD: .debug_info contents: -UPD-NEXT: 0x00000000: Compile Unit: length = 0x000000aa, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x000000ae) +UPD-NEXT: 0x00000000: Compile Unit: length = 0x00000081, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 UPD: 0x0000000c: DW_TAG_compile_unit [1] * UPD: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) -UPD: 0x0000003c: DW_TAG_subprogram [2] (0x0000000c) +UPD: 0x00000031: DW_TAG_subprogram [2] (0x0000000c) UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000018) -UPD: 0x0000004e: DW_TAG_subprogram [3] * (0x0000000c) +UPD: 0x0000003d: DW_TAG_subprogram [3] * (0x0000000c) UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000000000) -UPD: 0x00000071: DW_TAG_subprogram [3] * (0x0000000c) +UPD: 0x00000057: DW_TAG_subprogram [3] * (0x0000000c) UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002) address = 0x0000000000000008) -UPD: 0x00000094: DW_TAG_subprogram [5] (0x0000000c) +UPD: 0x00000071: DW_TAG_subprogram [5] (0x0000000c) UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000003) address = 0x0000000000000010) -UPD: 0x000000ae: Compile Unit: length = 0x00000098, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0000014a) +UPD: 0x00000085: Compile Unit: length = 0x00000072, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 -UPD: 0x000000ba: DW_TAG_compile_unit [1] * +UPD: 0x00000091: DW_TAG_compile_unit [1] * UPD: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) -UPD: 0x000000ea: DW_TAG_subprogram [2] (0x000000ba) +UPD: 0x000000b6: DW_TAG_subprogram [2] (0x00000091) UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000018) -UPD: 0x000000fc: DW_TAG_subprogram [3] * (0x000000ba) +UPD: 0x000000c2: DW_TAG_subprogram [3] * (0x00000091) UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000000000) -UPD: 0x0000011f: DW_TAG_subprogram [3] * (0x000000ba) +UPD: 0x000000dc: DW_TAG_subprogram [3] * (0x00000091) UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002) address = 0x0000000000000008) -UPD: 0x0000014a: Compile Unit: length = 0x0000005b, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x000001a9) +UPD: 0x000000fb: Compile Unit: length = 0x00000044, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 -UPD: 0x00000156: DW_TAG_compile_unit [7] * +UPD: 0x00000107: DW_TAG_compile_unit [7] * UPD: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) -UPD: 0x0000017e: DW_TAG_subprogram [3] * (0x00000156) +UPD: 0x00000124: DW_TAG_subprogram [3] * (0x00000107) UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000018) UPD: .debug_addr contents: Index: llvm/test/tools/dsymutil/ARM/dwarf5-addrx-0x0-last.test =================================================================== --- llvm/test/tools/dsymutil/ARM/dwarf5-addrx-0x0-last.test +++ llvm/test/tools/dsymutil/ARM/dwarf5-addrx-0x0-last.test @@ -33,7 +33,7 @@ DEBUGINFO: DW_TAG_subprogram DEBUGINFO: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000100003f4c) DEBUGINFO: DW_AT_high_pc [DW_FORM_data4] (0x00000054) -DEBUGINFO: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000011c] = "main") +DEBUGINFO: DW_AT_name [DW_FORM_strx] (indexed (00000007) string = "main") DEBUGLINE: 0x0000000100003f4c 4 0 {{.*}} is_stmt DEBUGLINE: 0x0000000100003f6c 5 17 {{.*}} is_stmt prologue_end Index: llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test =================================================================== --- llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test +++ llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test @@ -39,24 +39,24 @@ CHECK-NEXT: Abbrev table for offset: 0x00000000 CHECK: .debug_info contents: -CHECK: 0x00000000: Compile Unit: length = 0x00000061, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 +CHECK: 0x00000000: Compile Unit: length = 0x0000004a, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[RANGELIST_OFFSET:[0-9a-f]+]] CHECK-NEXT: [0x[[RANGELIST_OFFSET_START:[0-9a-f]+]], 0x[[RANGELIST_OFFSET_END:[0-9a-f]+]])) CHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) -CHECK: 0x00000037: DW_TAG_subprogram [2] * (0x0000000c) +CHECK: 0x0000002c: DW_TAG_subprogram [2] * (0x0000000c) CHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x[[#%.16x,LOCLIST_LOWPC:]]) -CHECK: 0x0000004d: DW_TAG_formal_parameter [3] (0x00000037) +CHECK: 0x0000003c: DW_TAG_formal_parameter [3] (0x0000002c) CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOCLIST_OFFSET:[0-9a-f]+]]: CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START:]], 0x[[#%.16x,LOCLIST_PAIR_END:]]): [[LOCLIST_EXPR:.*]] CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START2:]], 0x[[#%.16x,LOCLIST_PAIR_END2:]]): [[LOCLIST_EXPR2:.*]]) -CHECK: 0x00000065: Compile Unit: length = 0x00000072, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 +CHECK: 0x0000004e: Compile Unit: length = 0x00000072, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 CHECK: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,RANGE_LOWPC:]]) CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000 CHECK-NEXT: [0x[[#%.16x,RANGE_START:]], 0x[[#%.16x,RANGE_END:]])) -CHECK: 0x00000097: DW_TAG_subprogram [6] * (0x00000070) +CHECK: 0x00000080: DW_TAG_subprogram [6] * (0x00000059) CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,LOC_LOWPC:]]) -CHECK: 0x000000b4: DW_TAG_formal_parameter [3] (0x00000097) +CHECK: 0x0000009d: DW_TAG_formal_parameter [7] (0x00000080) CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOC_OFFSET:[0-9a-f]+]]: CHECK-NEXT: [0x[[#%.16x,LOC_PAIR_START:]], 0x[[#%.16x,LOC_PAIR_END:]]): [[LOC_EXPR:.*]] CHECK-NEXT: [0x[[#%.16x,LOC_PAIR_START2:]], 0x[[#%.16x,LOC_PAIR_END2:]]): [[LOC_EXPR2:.*]]) Index: llvm/test/tools/dsymutil/ARM/dwarf5-macho.test =================================================================== --- llvm/test/tools/dsymutil/ARM/dwarf5-macho.test +++ llvm/test/tools/dsymutil/ARM/dwarf5-macho.test @@ -25,13 +25,13 @@ CHECK-NEXT: Abbrev table for offset: 0x00000000 CHECK: .debug_info contents: -CHECK-NEXT: Compile Unit: length = 0x00000061, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 +CHECK-NEXT: Compile Unit: length = 0x0000004a, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[RANGELIST_OFFSET:[0-9a-f]+]] CHECK-NEXT: [0x[[RANGELIST_OFFSET_START:[0-9a-f]+]], 0x[[RANGELIST_OFFSET_END:[0-9a-f]+]])) CHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) -CHECK: 0x00000037: DW_TAG_subprogram [2] * (0x0000000c) +CHECK: 0x0000002c: DW_TAG_subprogram [2] * (0x0000000c) CHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x[[#%.16x,LOCLIST_LOWPC:]]) -CHECK: 0x0000004d: DW_TAG_formal_parameter [3] (0x00000037) +CHECK: 0x0000003c: DW_TAG_formal_parameter [3] (0x0000002c) CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOC_OFFSET:[0-9a-f]+]]: CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START:]], 0x[[#%.16x,LOCLIST_PAIR_END:]]): [[LOCLIST_EXPR:.*]] CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START2:]], 0x[[#%.16x,LOCLIST_PAIR_END2:]]): [[LOCLIST_EXPR2:.*]]) Index: llvm/test/tools/dsymutil/X86/dwarf5-addrx.test =================================================================== --- llvm/test/tools/dsymutil/X86/dwarf5-addrx.test +++ llvm/test/tools/dsymutil/X86/dwarf5-addrx.test @@ -55,87 +55,87 @@ CHECK-NOT: error: DWARF: DW_TAG_compile_unit -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "dwarf5-addrx.c" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "dwarf5-addrx.c" DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000100000eb0) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000103) DWARF: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) DWARF: DW_TAG_subprogram DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000100000eb0) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo1" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo1" DWARF: DW_TAG_subprogram DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000100000ec0) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo2" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo2" DWARF: DW_TAG_subprogram DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002) address = 0x0000000100000ed0) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo3" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo3" DWARF: DW_TAG_subprogram DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000003) address = 0x0000000100000ee0) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo4" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo4" DWARF: DW_TAG_subprogram DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000004) address = 0x0000000100000ef0) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo5" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo5" DWARF: DW_TAG_subprogram DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000005) address = 0x0000000100000f00) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo6" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo6" DWARF: DW_TAG_subprogram DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000006) address = 0x0000000100000f10) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo7" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo7" DWARF: DW_TAG_subprogram DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000007) address = 0x0000000100000f20) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo8" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo8" DWARF: DW_TAG_subprogram DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000008) address = 0x0000000100000f30) DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000083) -DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "main" +DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "main" UPDATE-DWARF: DW_TAG_compile_unit -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "dwarf5-addrx.c" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "dwarf5-addrx.c" UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000000) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000103) UPDATE-DWARF: DW_TAG_subprogram UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000000) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo1" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo1" UPDATE-DWARF: DW_TAG_subprogram UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000000010) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo2" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo2" UPDATE-DWARF: DW_TAG_subprogram UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002) address = 0x0000000000000020) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo3" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo3" UPDATE-DWARF: DW_TAG_subprogram UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000003) address = 0x0000000000000030) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo4" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo4" UPDATE-DWARF: DW_TAG_subprogram UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000004) address = 0x0000000000000040) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo5" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo5" UPDATE-DWARF: DW_TAG_subprogram UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000005) address = 0x0000000000000050) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo6" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo6" UPDATE-DWARF: DW_TAG_subprogram UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000006) address = 0x0000000000000060) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo7" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo7" UPDATE-DWARF: DW_TAG_subprogram UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000007) address = 0x0000000000000070) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000010) -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "foo8" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "foo8" UPDATE-DWARF: DW_TAG_subprogram UPDATE-DWARF: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000008) address = 0x0000000000000080) UPDATE-DWARF: DW_AT_high_pc [DW_FORM_data4] (0x00000083) -UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "main" +UPDATE-DWARF: DW_AT_name [DW_FORM_strx] {{.*}} "main" UPDATE-DWARF: .debug_addr contents: UPDATE-DWARF: 0x00000000: Address table header: length = 0x0000004c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00 UPDATE-DWARF: Addrs: [ Index: llvm/test/tools/dsymutil/X86/dwarf5-loclists.test =================================================================== --- llvm/test/tools/dsymutil/X86/dwarf5-loclists.test +++ llvm/test/tools/dsymutil/X86/dwarf5-loclists.test @@ -65,7 +65,7 @@ #UPD-DWARF-CHECK: DW_TAG_compile_unit #UPD-DWARF-CHECK: DW_AT_name {{.*}} "dwarf5-loclists.c" #UPD-DWARF-CHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x0000000c) -#UPD-DWARF-CHECK: DW_TAG_formal_parameter [8] (0x00000058) +#UPD-DWARF-CHECK: DW_TAG_formal_parameter [8] (0x00000047) #UPD-DWARF-CHECK: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x00000014: #UPD-DWARF-CHECK: [0x0000000000000000, 0x0000000000000017): DW_OP_reg5 RDI #UPD-DWARF-CHECK: [0x0000000000000017, 0x0000000000000023): DW_OP_reg3 RBX @@ -73,7 +73,7 @@ #UPD-DWARF-CHECK: [0x0000000000000030, 0x0000000000000033): DW_OP_reg3 RBX #UPD-DWARF-CHECK: [0x0000000000000033, 0x000000000000004c): DW_OP_breg6 RBP-20) #UPD-DWARF-CHECK: DW_AT_name {{.*}} "argv" -#UPD-DWARF-CHECK: DW_TAG_formal_parameter [8] (0x00000058) +#UPD-DWARF-CHECK: DW_TAG_formal_parameter [8] (0x00000047) #UPD-DWARF-CHECK: DW_AT_location [DW_FORM_loclistx] (indexed (0x1) loclist = 0x0000002f: #UPD-DWARF-CHECK: [0x0000000000000000, 0x0000000000000019): DW_OP_reg4 RSI #UPD-DWARF-CHECK: [0x0000000000000019, 0x000000000000004c): DW_OP_entry_value(DW_OP_reg4 RSI), DW_OP_stack_value) Index: llvm/test/tools/dsymutil/X86/op-convert-offset.test =================================================================== --- llvm/test/tools/dsymutil/X86/op-convert-offset.test +++ llvm/test/tools/dsymutil/X86/op-convert-offset.test @@ -34,12 +34,12 @@ OBJ: DW_AT_name ("b") OBJ: DW_AT_type (0x000000af "_Bool") -DSYM: 0x0000009a: DW_TAG_base_type +DSYM: 0x00000084: DW_TAG_base_type DSYM: DW_AT_name ("DW_ATE_unsigned_1") DSYM: DW_AT_encoding (DW_ATE_unsigned) DSYM: DW_AT_byte_size (0x01) -DSYM: 0x000000ba: DW_TAG_formal_parameter -DSYM: DW_AT_location (DW_OP_breg2 RCX+0, DW_OP_constu 0xff, DW_OP_and, DW_OP_convert (0x0000009a) "DW_ATE_unsigned_1", DW_OP_convert (0x000000a1) "DW_ATE_unsigned_8", DW_OP_stack_value) +DSYM: 0x0000009b: DW_TAG_formal_parameter +DSYM: DW_AT_location (DW_OP_breg2 RCX+0, DW_OP_constu 0xff, DW_OP_and, DW_OP_convert (0x00000084) "DW_ATE_unsigned_1", DW_OP_convert (0x00000088) "DW_ATE_unsigned_8", DW_OP_stack_value) DSYM: DW_AT_name ("b") -DSYM: DW_AT_type (0x000000d8 "_Bool") +DSYM: DW_AT_type (0x000000b6 "_Bool")