Index: llvm/include/llvm/DWARFLinker/DWARFLinker.h =================================================================== --- llvm/include/llvm/DWARFLinker/DWARFLinker.h +++ llvm/include/llvm/DWARFLinker/DWARFLinker.h @@ -143,6 +143,17 @@ virtual void emitDwarfDebugLocListFooter(const CompileUnit &Unit, MCSymbol *EndLabel) = 0; + /// Emit .debug_addr header. + virtual MCSymbol *emitDwarfDebugAddrsHeader(const CompileUnit &Unit) = 0; + + /// Emit the addresses described by \p Addrs into the .debug_addr section. + virtual void emitDwarfDebugAddrs(const SmallVector &Addrs, + uint8_t AddrSize) = 0; + + /// Emit .debug_addr footer. + virtual void emitDwarfDebugAddrsFooter(const CompileUnit &Unit, + MCSymbol *EndLabel) = 0; + /// Emit .debug_aranges entries for \p Unit virtual void emitDwarfDebugArangesTable(const CompileUnit &Unit, @@ -211,6 +222,9 @@ /// Returns size of generated .debug_loclists section. virtual uint64_t getLocListsSectionSize() const = 0; + /// Returns size of generated .debug_addr section. + virtual uint64_t getDebugAddrSectionSize() const = 0; + /// Dump the file to the disk. virtual void finish() = 0; @@ -623,6 +637,28 @@ OffsetsStringPool &DebugStrPool; OffsetsStringPool &DebugLineStrPool; + 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); + } + return It->second; + } + + void clear() { + AddrIndexMap.clear(); + Addrs.clear(); + } + + }; + + DebugAddrPool AddrPool; + /// Allocator used for all the DIEValue objects. BumpPtrAllocator &DIEAlloc; @@ -665,6 +701,10 @@ uint64_t cloneAllCompileUnits(DWARFContext &DwarfContext, const DWARFFile &File, bool IsLittleEndian); + /// Emit the .debug_addr section for the \p Unit. + void emitDebugAddrSection(CompileUnit &Unit, + const uint16_t DwarfVersion) const; + private: using AttributeSpec = DWARFAbbreviationDeclaration::AttributeSpec; Index: llvm/include/llvm/DWARFLinker/DWARFStreamer.h =================================================================== --- llvm/include/llvm/DWARFLinker/DWARFStreamer.h +++ llvm/include/llvm/DWARFLinker/DWARFStreamer.h @@ -107,6 +107,17 @@ /// Emit debug locations(.debug_loc, .debug_loclists) header. MCSymbol *emitDwarfDebugLocListHeader(const CompileUnit &Unit) override; + /// Emit .debug_addr header. + MCSymbol *emitDwarfDebugAddrsHeader(const CompileUnit &Unit) override; + + /// Emit the addresses described by \p Addrs into .debug_addr table. + void emitDwarfDebugAddrs(const SmallVector &Addrs, + uint8_t AddrSize) override; + + /// Emit .debug_addr footer. + void emitDwarfDebugAddrsFooter(const CompileUnit &Unit, + MCSymbol *EndLabel) override; + /// Emit debug ranges(.debug_loc, .debug_loclists) fragment. void emitDwarfDebugLocListFragment( const CompileUnit &Unit, @@ -185,6 +196,8 @@ return LocListsSectionSize; } + uint64_t getDebugAddrSectionSize() const override { return AddrSectionSize; } + void emitMacroTables(DWARFContext *Context, const Offset2UnitMap &UnitMacroMap, OffsetsStringPool &StringPool) override; @@ -277,6 +290,7 @@ uint64_t DebugInfoSectionSize = 0; uint64_t MacInfoSectionSize = 0; uint64_t MacroSectionSize = 0; + uint64_t AddrSectionSize = 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 @@ -1383,25 +1383,18 @@ *Addr += Info.PCOffset; } - switch (AttrSpec.Form) { - case dwarf::DW_FORM_addrx: - case dwarf::DW_FORM_addrx1: - case dwarf::DW_FORM_addrx2: - case dwarf::DW_FORM_addrx3: - case dwarf::DW_FORM_addrx4: { - // DWARFLinker does not use addrx forms since it generates relocated - // addresses. Replace DW_FORM_addrx* with DW_FORM_addr here. - AttrSpec.Form = dwarf::DW_FORM_addr; - break; - } - default: - // Nothing to do. - break; + if (AttrSpec.Form == dwarf::DW_FORM_addr) { + Die.addValue(DIEAlloc, static_cast(AttrSpec.Attr), + AttrSpec.Form, DIEInteger(*Addr)); + return Unit.getOrigUnit().getAddressByteSize(); } - Die.addValue(DIEAlloc, static_cast(AttrSpec.Attr), - AttrSpec.Form, DIEInteger(*Addr)); - return Unit.getOrigUnit().getAddressByteSize(); + auto AddrIndex = AddrPool.getAddrIndex(*Addr); + + return Die + .addValue(DIEAlloc, static_cast(AttrSpec.Attr), + dwarf::Form::DW_FORM_addrx, DIEInteger(AddrIndex)) + ->sizeOf(Unit.getOrigUnit().getFormParams()); } unsigned DWARFLinker::DIECloner::cloneScalarAttribute( @@ -1665,9 +1658,6 @@ case dwarf::DW_AT_high_pc: case dwarf::DW_AT_ranges: return !Update && SkipPC; - case dwarf::DW_AT_addr_base: - // In case !Update the .debug_addr table is not generated/preserved. - return !Update; case dwarf::DW_AT_rnglists_base: // In case !Update the .debug_addr table is not generated/preserved. // Thus instead of DW_FORM_rnglistx the DW_FORM_sec_offset is used. @@ -2001,6 +1991,36 @@ TheDwarfEmitter->emitDwarfDebugLocListFooter(Unit, EndLabel); } +static void patchAddrBase(DIE &Die, DIEInteger Offset) { + for (auto &V : Die.values()) + if (V.getAttribute() == dwarf::DW_AT_addr_base) { + V = DIEValue(V.getAttribute(), V.getForm(), Offset); + return; + } + + llvm_unreachable("Didn't find a DW_AT_addr_base in cloned DIE!"); +} + +void DWARFLinker::DIECloner::emitDebugAddrSection( + CompileUnit &Unit, + const uint16_t DwarfVersion) const { + + if (LLVM_UNLIKELY(Linker.Options.Update)) + return; + + if (DwarfVersion < 5) + return; + + if (AddrPool.Addrs.empty()) + return; + + MCSymbol *EndLabel = Emitter->emitDwarfDebugAddrsHeader(Unit); + patchAddrBase(*Unit.getOutputUnitDIE(), + DIEInteger(Emitter->getDebugAddrSectionSize())); + Emitter->emitDwarfDebugAddrs(AddrPool.Addrs, Unit.getOrigUnit().getAddressByteSize()); + Emitter->emitDwarfDebugAddrsFooter(Unit, EndLabel); +} + /// Insert the new line info sequence \p Seq into the current /// set of already linked line info \p Rows. static void insertLineSequence(std::vector &Seq, @@ -2566,7 +2586,9 @@ IsLittleEndian); }; Linker.generateUnitLocations(*CurrentUnit, File, ProcessExpr); + emitDebugAddrSection(*CurrentUnit, DwarfVersion); } + AddrPool.clear(); } if (Emitter != nullptr) { Index: llvm/lib/DWARFLinker/DWARFStreamer.cpp =================================================================== --- llvm/lib/DWARFLinker/DWARFStreamer.cpp +++ llvm/lib/DWARFLinker/DWARFStreamer.cpp @@ -606,6 +606,57 @@ LocSectionSize += AddressSize; } +/// Emit .debug_addr header. +MCSymbol *DwarfStreamer::emitDwarfDebugAddrsHeader(const CompileUnit &Unit) { + + // Make .debug_addr the current section. + MS->switchSection(MC->getObjectFileInfo()->getDwarfAddrSection()); + + MCSymbol *BeginLabel = Asm->createTempSymbol("Bdebugaddr"); + MCSymbol *EndLabel = Asm->createTempSymbol("Edebugaddr"); + unsigned AddrSize = Unit.getOrigUnit().getAddressByteSize(); + + // Emit length. + Asm->emitLabelDifference(EndLabel, BeginLabel, sizeof(uint32_t)); + Asm->OutStreamer->emitLabel(BeginLabel); + AddrSectionSize += sizeof(uint32_t); + + // Emit version. + Asm->emitInt16(5); + AddrSectionSize += 2; + + // Emit address size. + Asm->emitInt8(AddrSize); + AddrSectionSize += 1; + + // Emit segment size. + Asm->emitInt8(0); + AddrSectionSize += 1; + + return EndLabel; +} + +/// Emit the .debug_addr addresses stored in \p Addrs. +void DwarfStreamer::emitDwarfDebugAddrs(const SmallVector &Addrs, + uint8_t AddrSize) { + Asm->OutStreamer->switchSection(MOFI->getDwarfAddrSection()); + for (auto Addr : Addrs) { + Asm->OutStreamer->emitIntValue(Addr, AddrSize); + AddrSectionSize += AddrSize; + } +} + +/// Emit .debug_addr footer. +void DwarfStreamer::emitDwarfDebugAddrsFooter(const CompileUnit &Unit, + MCSymbol *EndLabel) { + + // Make .debug_addr the current section. + MS->switchSection(MC->getObjectFileInfo()->getDwarfAddrSection()); + + if (EndLabel != nullptr) + Asm->OutStreamer->emitLabel(EndLabel); +} + /// Emit piece of .debug_loclists for \p LinkedLocationExpression. void DwarfStreamer::emitDwarfDebugLocListsTableFragment( const CompileUnit &Unit, Index: llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map =================================================================== --- llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map +++ llvm/test/tools/dsymutil/ARM/dummy-debug-map-amr64.map @@ -14,5 +14,8 @@ - filename: 2.o symbols: - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x20000, size: 0x10 } + - filename: 3.o + symbols: + - { sym: __Z3foov, objAddr: 0x0, binAddr: 0x30000, size: 0x10 } ... Index: llvm/test/tools/dsymutil/ARM/dwarf5-addr_base.test =================================================================== --- /dev/null +++ llvm/test/tools/dsymutil/ARM/dwarf5-addr_base.test @@ -0,0 +1,153 @@ +; This test checks to ensure that if three DWARFv5 object files have correct values for the DW_AT_addr_base in their compile units. + +; 1.o was produced with the source file: + +; a.cpp +; __attribute__((section("1,__text_foo"))) void foo() {} +; +; int foo2(int a) { +; return a+5; +; } +; +; int foo3(int x) { +; return x+2; +; } +; +; int main () { +; return 1; +; } + +; clang -g -c -O1 a.cpp -gdwarf-5 -o 1.o + +; 2.o was produced with the following source file: + +; b.cpp +; __attribute__((section("1,__text_foo"))) void bar() {} +; +; int bar2(int a) { +; return a+5; +; } +; +; int bar3(int x) { +; return x+2; +; } + +; clang -g -c -O1 b.cpp -gdwarf-5 -o 2.o + +; 3.o was produced with the following source file: + +; c.cpp +; +; int baz(int x) { +; return x+2; +; } + +; clang -g -c -O1 c.cpp -gdwarf-5 -o 3.o + + +RUN: rm -rf %t.dir && mkdir -p %t.dir +RUN: dsymutil -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr_base -o %t.dir/dwarf5-addr_base.dSYM +RUN: llvm-dwarfdump %t.dir/dwarf5-addr_base.dSYM -a --verbose | FileCheck %s + +RUN: dsymutil --update -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5-addr_base -o %t.dir/dwarf5-addr_base.dSYM +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: 0x0000000c: DW_TAG_compile_unit [1] * +CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) + +CHECK: 0x00000037: 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: 0x00000071: DW_TAG_compile_unit [1] * +CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000018) + +CHECK: 0x0000009c: DW_TAG_subprogram [2] * (0x00000071) +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: 0x000000d6: DW_TAG_compile_unit [5] * +CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000028) + +CHECK: 0x000000fa: DW_TAG_subprogram [2] * (0x000000d6) +CHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x[[ADDR3:[0-9a-f]+]]) + +CHECK: .debug_addr contents: +CHECK-NEXT: 0x00000000: Address table header: length = 0x0000000c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00 +CHECK-NEXT: Addrs: [ +CHECK-NEXT: 0x[[ADDR1]] +CHECK-NEXT: ] +CHECK-NEXT: 0x00000010: Address table header: length = 0x0000000c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00 +CHECK-NEXT: Addrs: [ +CHECK-NEXT: 0x[[ADDR2]] +CHECK-NEXT: ] +CHECK-NEXT: 0x00000020: Address table header: length = 0x0000000c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00 +CHECK-NEXT: Addrs: [ +CHECK-NEXT: 0x[[ADDR3]] +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: 0x0000000c: DW_TAG_compile_unit [1] * +UPD: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) + +UPD: 0x0000003c: 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-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000000000) + +UPD: 0x00000071: 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-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: 0x000000ba: DW_TAG_compile_unit [1] * +UPD: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) + +UPD: 0x000000ea: DW_TAG_subprogram [2] (0x000000ba) +UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000018) + +UPD: 0x000000fc: DW_TAG_subprogram [3] * (0x000000ba) +UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000000000) + +UPD: 0x0000011f: DW_TAG_subprogram [3] * (0x000000ba) +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: 0x00000156: DW_TAG_compile_unit [7] * +UPD: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) + +UPD: 0x0000017e: DW_TAG_subprogram [3] * (0x00000156) +UPD-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000018) + +UPD: .debug_addr contents: +UPD-NEXT: 0x00000000: Address table header: length = 0x00000024, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00 +UPD-NEXT: Addrs: [ +UPD-NEXT: 0x0000000000000018 +UPD-NEXT: 0x0000000000000000 +UPD-NEXT: 0x0000000000000008 +UPD-NEXT: 0x0000000000000010 +UPD-NEXT: ] +UPD-NEXT: 0x00000028: Address table header: length = 0x0000001c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00 +UPD-NEXT: Addrs: [ +UPD-NEXT: 0x0000000000000010 +UPD-NEXT: 0x0000000000000000 +UPD-NEXT: 0x0000000000000008 +UPD-NEXT: ] +UPD-NEXT: 0x00000048: Address table header: length = 0x0000000c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00 +UPD-NEXT: Addrs: [ +UPD-NEXT: 0x0000000000000000 +UPD-NEXT: ] 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 @@ -31,7 +31,7 @@ CHECK-NOT: error: DEBUGINFO: DW_TAG_subprogram -DEBUGINFO: DW_AT_low_pc [DW_FORM_addr] (0x0000000100003f4c) +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") 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,23 +39,24 @@ CHECK-NEXT: Abbrev table for offset: 0x00000000 CHECK: .debug_info contents: -CHECK: 0x00000000: Compile Unit: length = 0x00000064, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 +CHECK: 0x00000000: Compile Unit: length = 0x00000061, 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: 0x00000033: DW_TAG_subprogram [2] * (0x0000000c) -CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,LOCLIST_LOWPC:]]) -CHECK: 0x00000050: DW_TAG_formal_parameter [3] (0x00000033) +CHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) +CHECK: 0x00000037: 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-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: 0x00000068: Compile Unit: length = 0x00000072, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 +CHECK: 0x00000065: 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:0x0000009a: DW_TAG_subprogram [2] * (0x00000073) +CHECK: 0x00000097: DW_TAG_subprogram [6] * (0x00000070) CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,LOC_LOWPC:]]) -CHECK:0x000000b7: DW_TAG_formal_parameter [3] (0x0000009a) +CHECK: 0x000000b4: DW_TAG_formal_parameter [3] (0x00000097) 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,12 +25,13 @@ CHECK-NEXT: Abbrev table for offset: 0x00000000 CHECK: .debug_info contents: -CHECK-NEXT: 0x00000000: Compile Unit: length = 0x00000064, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 +CHECK-NEXT: Compile Unit: length = 0x00000061, 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: 0x00000033: DW_TAG_subprogram [2] * (0x0000000c) -CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,LOCLIST_LOWPC:]]) -CHECK: 0x00000050: DW_TAG_formal_parameter [3] (0x00000033) +CHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) +CHECK: 0x00000037: 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-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 @@ -56,45 +56,45 @@ DWARF: DW_TAG_compile_unit DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "dwarf5-addrx.c" -DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000eb0) +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_addr] (0x0000000100000eb0) +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_TAG_subprogram -DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000ec0) +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_TAG_subprogram -DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000ed0) +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_TAG_subprogram -DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000ee0) +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_TAG_subprogram -DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000ef0) +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_TAG_subprogram -DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f00) +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_TAG_subprogram -DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f10) +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_TAG_subprogram -DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f20) +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_TAG_subprogram -DWARF: DW_AT_low_pc [DW_FORM_addr] (0x0000000100000f30) +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-NOT: .debug_addr contents UPDATE-DWARF: DW_TAG_compile_unit UPDATE-DWARF: DW_AT_name [DW_FORM_strp] {{.*}} "dwarf5-addrx.c" Index: llvm/test/tools/dsymutil/X86/dwarf5-dw-op-addrx.test =================================================================== --- llvm/test/tools/dsymutil/X86/dwarf5-dw-op-addrx.test +++ llvm/test/tools/dsymutil/X86/dwarf5-dw-op-addrx.test @@ -57,7 +57,6 @@ #DWARF-CHECK: DW_TAG_variable #DWARF-CHECK: DW_AT_name {{.*}}"arr9" #DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100009000) -#DWARF-CHECK-NOT: .debug_addr #UPD-DWARF-CHECK: DW_TAG_compile_unit #UPD-DWARF-CHECK: DW_AT_name {{.*}}"dwarf5-dw-op-addrx.c" Index: llvm/test/tools/dsymutil/X86/dwarf5-rnglists.test =================================================================== --- llvm/test/tools/dsymutil/X86/dwarf5-rnglists.test +++ llvm/test/tools/dsymutil/X86/dwarf5-rnglists.test @@ -40,20 +40,20 @@ #CHECK: No errors. #DWARF-CHECK: DW_TAG_compile_unit +#DWARF-CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) #DWARF-CHECK: DW_TAG_lexical_block #DWARF-CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x0000000c #DWARF-CHECK: [0x0000000100000f79, 0x0000000100000f96) #DWARF-CHECK: [0x0000000100000fad, 0x0000000100000fb4)) -#DWARF-CHECK-NOT: debug_addr #DWARF-CHECK: .debug_rnglists contents: #DWARF-CHECK: 0x00000000: range list header: length = 0x0000001d, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000 #DWARF-CHECK: ranges: #DWARF-CHECK: 0x0000000c: [DW_RLE_start_length]: 0x0000000100000f79, 0x000000000000001d => [0x0000000100000f79, 0x0000000100000f96) #DWARF-CHECK: 0x00000016: [DW_RLE_start_length]: 0x0000000100000fad, 0x0000000000000007 => [0x0000000100000fad, 0x0000000100000fb4) #DWARF-CHECK: 0x00000020: [DW_RLE_end_of_list ] -#DWARF-CHECK-NOT: debug_addr # #UPD-DWARF-CHECK: DW_TAG_compile_unit +#UPD-DWARF-CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) #UPD-DWARF-CHECK: DW_TAG_lexical_block #UPD-DWARF-CHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000010 #UPD-DWARF-CHECK: [0x0000000000000009, 0x0000000000000026) 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: 0x000000ae: DW_TAG_base_type +DSYM: 0x0000009a: 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: 0x000000d5: DW_TAG_formal_parameter -DSYM: DW_AT_location (DW_OP_breg2 RCX+0, DW_OP_constu 0xff, DW_OP_and, DW_OP_convert (0x000000ae) "DW_ATE_unsigned_1", DW_OP_convert (0x000000b5) "DW_ATE_unsigned_8", DW_OP_stack_value) +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: DW_AT_name ("b") -DSYM: DW_AT_type (0x000000f3 "_Bool") +DSYM: DW_AT_type (0x000000d8 "_Bool") Index: llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-addresses.test =================================================================== --- llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-addresses.test +++ llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-addresses.test @@ -25,31 +25,31 @@ #DWARF-CHECK: DW_TAG_compile_unit #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "CU1" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001130) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000001130) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000060) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo1" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001130) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000001130) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo2" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001140) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000001140) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo3" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001150) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002) address = 0x0000000000001150) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo4" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001160) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000003) address = 0x0000000000001160) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo5" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001170) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000004) address = 0x0000000000001170) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo6" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001180) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000005) address = 0x0000000000001180) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_variable #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "var1" Index: llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-rnglists.test =================================================================== --- llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-rnglists.test +++ llvm/test/tools/llvm-dwarfutil/ELF/X86/dwarf5-rnglists.test @@ -20,42 +20,48 @@ #DWARF-CHECK: DW_TAG_compile_unit #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "CU1" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001130) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000001130) #DWARF-CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[CURANGE_OFF:[0-9a-f]*]] #DWARF-CHECK: [0x0000000000001130, 0x0000000000001170)) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo1" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001130) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000001130) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_lexical_block #DWARF-CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[F1RANGE_OFF:[0-9a-f]*]] #DWARF-CHECK: [0x0000000000001130, 0x0000000000001140)) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo2" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001140) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = 0x0000000000001140) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_lexical_block #DWARF-CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[F2RANGE_OFF:[0-9a-f]*]] #DWARF-CHECK: [0x0000000000001140, 0x0000000000001150)) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo3" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001150) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002) address = 0x0000000000001150) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_lexical_block #DWARF-CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[F3RANGE_OFF:[0-9a-f]*]] #DWARF-CHECK: [0x0000000000001150, 0x0000000000001160)) #DWARF-CHECK: DW_TAG_subprogram #DWARF-CHECK: DW_AT_name [DW_FORM_strp] {{.*}} "foo4" -#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addr] (0x0000000000001160) +#DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000003) address = 0x0000000000001160) #DWARF-CHECK: DW_AT_high_pc [DW_FORM_data8] (0x0000000000000010) #DWARF-CHECK: DW_TAG_lexical_block #DWARF-CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[F4RANGE_OFF:[0-9a-f]*]] #DWARF-CHECK: [0x0000000000001160, 0x0000000000001170)) -#DWARF-CHECK-NOT: .debug_addr contents: #DWARF-CHECK: .debug_aranges contents: #DWARF-CHECK: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00 #DWARF-CHECK: [0x0000000000001130, 0x0000000000001170) -#DWARF-CHECK-NOT: .debug_addr contents: +#DWARF-CHECK: .debug_addr contents: +#DWARF-CHECK: 0x00000000: Address table header: length = 0x00000024, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00 +#DWARF-CHECK: Addrs: [ +#DWARF-CHECK: 0x0000000000001130 +#DWARF-CHECK: 0x0000000000001140 +#DWARF-CHECK: 0x0000000000001150 +#DWARF-CHECK: 0x0000000000001160 +#DWARF-CHECK: ] #DWARF-CHECK: .debug_rnglists contents: #DWARF-CHECK: 0x00000000: range list header: length = 0x0000003f, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000 #DWARF-CHECK: ranges: @@ -69,7 +75,6 @@ #DWARF-CHECK: {{.*}} [DW_RLE_end_of_list ] #DWARF-CHECK: 0x[[CURANGE_OFF]]: [DW_RLE_start_length]: 0x0000000000001130, 0x0000000000000040 => [0x0000000000001130, 0x0000000000001170) #DWARF-CHECK: {{.*}} [DW_RLE_end_of_list ] -#DWARF-CHECK-NOT: .debug_addr contents: #UPD-DWARF-CHECK: DW_TAG_compile_unit #UPD-DWARF-CHECK: DW_AT_name {{.*}}"CU1"