DWARF v5: emit DW_AT_addr_base if DW_AT_low_pc references .debug_addr
The condition !AddrPool.empty() is tested before attachRangesOrLowHighPC(), which may add an entry to AddrPool. We emit DW_AT_low_pc (DW_FORM_addrx) but may incorrectly omit DW_AT_addr_base for LineTablesOnly. This can be easily reproduced: clang -gdwarf-5 -gmlt -c a.cc Fix this by moving !AddrPool.empty() below. This was discovered while investigating an lld crash (fixed by D61889) on such object files: ld.lld --gdb-index a.o Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D61891 llvm-svn: 360678
This commit is contained in:
parent
22561972af
commit
2f6ef2fc92
|
@ -901,13 +901,6 @@ void DwarfDebug::finalizeModuleInfo() {
|
||||||
// ranges for all subprogram DIEs for mach-o.
|
// ranges for all subprogram DIEs for mach-o.
|
||||||
DwarfCompileUnit &U = SkCU ? *SkCU : TheCU;
|
DwarfCompileUnit &U = SkCU ? *SkCU : TheCU;
|
||||||
|
|
||||||
// We don't keep track of which addresses are used in which CU so this
|
|
||||||
// is a bit pessimistic under LTO.
|
|
||||||
if (!AddrPool.isEmpty() &&
|
|
||||||
(getDwarfVersion() >= 5 ||
|
|
||||||
(SkCU && !empty(TheCU.getUnitDie().children()))))
|
|
||||||
U.addAddrTableBase();
|
|
||||||
|
|
||||||
if (unsigned NumRanges = TheCU.getRanges().size()) {
|
if (unsigned NumRanges = TheCU.getRanges().size()) {
|
||||||
if (NumRanges > 1 && useRangesSection())
|
if (NumRanges > 1 && useRangesSection())
|
||||||
// A DW_AT_low_pc attribute may also be specified in combination with
|
// A DW_AT_low_pc attribute may also be specified in combination with
|
||||||
|
@ -920,6 +913,13 @@ void DwarfDebug::finalizeModuleInfo() {
|
||||||
U.attachRangesOrLowHighPC(U.getUnitDie(), TheCU.takeRanges());
|
U.attachRangesOrLowHighPC(U.getUnitDie(), TheCU.takeRanges());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We don't keep track of which addresses are used in which CU so this
|
||||||
|
// is a bit pessimistic under LTO.
|
||||||
|
if (!AddrPool.isEmpty() &&
|
||||||
|
(getDwarfVersion() >= 5 ||
|
||||||
|
(SkCU && !empty(TheCU.getUnitDie().children()))))
|
||||||
|
U.addAddrTableBase();
|
||||||
|
|
||||||
if (getDwarfVersion() >= 5) {
|
if (getDwarfVersion() >= 5) {
|
||||||
if (U.hasRangeLists())
|
if (U.hasRangeLists())
|
||||||
U.addRnglistsBase();
|
U.addRnglistsBase();
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
; RUN: %llc_dwarf -filetype=obj %s -o - | llvm-dwarfdump -v -debug-info - | FileCheck %s
|
||||||
|
|
||||||
|
;; In DWARF v5, emit DW_AT_addr_base as DW_AT_addr_base is used for DW_AT_low_pc.
|
||||||
|
; CHECK: DW_AT_low_pc [DW_FORM_addrx]
|
||||||
|
; CHECK: DW_AT_addr_base
|
||||||
|
|
||||||
|
define i64 @foo() !dbg !7 {
|
||||||
|
entry:
|
||||||
|
ret i64 0
|
||||||
|
}
|
||||||
|
|
||||||
|
!llvm.dbg.cu = !{!0}
|
||||||
|
!llvm.module.flags = !{!3, !4}
|
||||||
|
|
||||||
|
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, emissionKind: LineTablesOnly, enums: !2, nameTableKind: None)
|
||||||
|
!1 = !DIFile(filename: "a.cc", directory: "/tmp")
|
||||||
|
!2 = !{}
|
||||||
|
!3 = !{i32 2, !"Dwarf Version", i32 5}
|
||||||
|
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
||||||
|
!7 = distinct !DISubprogram(name: "a", scope: !1, file: !1, line: 22, type: !8, scopeLine: 22, unit: !0, retainedNodes: !2)
|
||||||
|
!8 = !DISubroutineType(types: !2)
|
|
@ -11,9 +11,9 @@
|
||||||
; DW5-CHECK-NEXT: DW_AT_str_offsets_base (0x00000008)
|
; DW5-CHECK-NEXT: DW_AT_str_offsets_base (0x00000008)
|
||||||
; DW5-CHECK-NEXT: DW_AT_stmt_list (0x00000000)
|
; DW5-CHECK-NEXT: DW_AT_stmt_list (0x00000000)
|
||||||
; DW5-CHECK-NEXT: DW_AT_comp_dir {{.*}}
|
; DW5-CHECK-NEXT: DW_AT_comp_dir {{.*}}
|
||||||
; DW5-CHECK-NEXT: DW_AT_addr_base (0x00000008)
|
|
||||||
; DW5-CHECK-NEXT: DW_AT_low_pc (0x0000000000000000)
|
; DW5-CHECK-NEXT: DW_AT_low_pc (0x0000000000000000)
|
||||||
; DW5-CHECK-NEXT: DW_AT_high_pc (0x0000000000000007)
|
; DW5-CHECK-NEXT: DW_AT_high_pc (0x0000000000000007)
|
||||||
|
; DW5-CHECK-NEXT: DW_AT_addr_base (0x00000008)
|
||||||
; DW5-CHECK-NEXT: DW_AT_loclists_base (0x0000000c)
|
; DW5-CHECK-NEXT: DW_AT_loclists_base (0x0000000c)
|
||||||
; DW5-CHECK-EMPTY:
|
; DW5-CHECK-EMPTY:
|
||||||
; DW5-CHECK-NEXT: 0x00000027: DW_TAG_base_type
|
; DW5-CHECK-NEXT: 0x00000027: DW_TAG_base_type
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
; CHECK-NEXT: DW_AT_GNU_dwo_name
|
; CHECK-NEXT: DW_AT_GNU_dwo_name
|
||||||
; CHECK-NEXT: DW_AT_GNU_dwo_id
|
; CHECK-NEXT: DW_AT_GNU_dwo_id
|
||||||
; CHECK-NEXT: DW_AT_GNU_ranges_base
|
; CHECK-NEXT: DW_AT_GNU_ranges_base
|
||||||
|
; CHECK-NEXT: DW_AT_low_pc
|
||||||
|
; CHECK-NEXT: DW_AT_high_pc
|
||||||
; CHECK-NEXT: DW_AT_GNU_addr_base [DW_FORM_sec_offset] (0x00000000)
|
; CHECK-NEXT: DW_AT_GNU_addr_base [DW_FORM_sec_offset] (0x00000000)
|
||||||
|
|
||||||
; CHECK: .debug_info.dwo contents:
|
; CHECK: .debug_info.dwo contents:
|
||||||
|
|
Loading…
Reference in New Issue